Jump to content

setControlState for next weapon triggers only once


Raziru

Recommended Posts

 for i =1,(4) do
        setControlState ( "next_weapon", true )
        outputChatBox("next_fail")
        end 

outputChatBox triggers 3 times while setControlState triggers only once.

I'd like to have next_weapon 3 times, but it only works once. How can I do it?

  • Sad 1
Link to comment

I've tried to set them having instantly switch to sniper but
the trick is
if you were to bind 4>Fist, 4>Sniper
It wont instantly switch to both.
It will switch to 1 of them.
so i'm trying to toggle "next_weapon" control till i reach the weapon i desire.

Link to comment

addEventHandler("onClientResourceStart", resourceRoot,
    function()


        wnd = guiCreateWindow(455, 191, 425, 227, "", false)
        guiWindowSetSizable(wnd, false)

        butt1 = guiCreateButton(14, 30, 133, 32, "deagle", false, wnd)
        butt2 = guiCreateButton(199, 38, 150, 34, "shotgun", false, wnd)
		butt3 = guiCreateButton(300, 10, 150, 34, "2", false, wnd)
        ebox = guiCreateEdit(139, 111, 182, 45, "", false, wnd) 
		
		 addEventHandler( "onClientGUIClick", butt1, function()
		 if (source==butt1) then
		slot1= tostring(guiGetText (ebox)) 
		bindKey(slot1,"down",function()
		cslot1= getPedWeaponSlot ( localPlayer )
		if ((2-cslot1) > 0) then
		for i =1,(2-cslot1) do
		setControlState ( "next_weapon", true )
		outputChatBox("next_fail")
		end
		elseif((2-cslot1)<0) then
		for i =1,(cslot1-2) do
		setControlState ( "previous_weapon", true )
		outputChatBox("pre_fail")
		end
			
		end
		end)
		end
		end)
		end)

that's when i tried "next_weapon" control.


addEventHandler("onClientResourceStart", resourceRoot,
    function()


        wnd = guiCreateWindow(455, 191, 425, 227, "", false)
        guiWindowSetSizable(wnd, false)

        butt1 = guiCreateButton(14, 30, 133, 32, "deagle", false, wnd)
        butt2 = guiCreateButton(199, 38, 150, 34, "shotgun", false, wnd)
		butt3 = guiCreateButton(300, 10, 150, 34, "2", false, wnd)
        ebox = guiCreateEdit(139, 111, 182, 45, "", false, wnd) 
		
		 addEventHandler( "onClientGUIClick", butt1, function()
		 if (source==butt1) then
		slot1= tostring(guiGetText (ebox)) 
		bindKey(slot1,"down",function()
		setPedWeaponSlot (localPlayer,2)
		end)
		end
		end)
		addEventHandler( "onClientGUIClick", butt2, function()
		 if (source==butt2) then
		slot2= tostring(guiGetText (ebox)) 
		bindKey(slot2,"down",function()
		setPedWeaponSlot (localPlayer,3)
		end)
		end
		end)
		
		
		end)

that one when i tried to bind one key for 2 functions
only the 2nd entered function will work.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...