Jump to content

ToggleControl not working


Disy

Recommended Posts

function disableGunOnSwitch ( prevSlot, newSlot )
	local weaponID = getPedWeapon(getLocalPlayer(), newSlot)
	outputChatBox(tostring(getPedAmmoInClip(getLocalPlayer(), newSlot)))
	if ((getElementData(source, "cf:"..tostring(weaponID)) or getElementData(source, "r:cf:"..tostring(weaponID)) or  getPedAmmoInClip(getLocalPlayer(), newSlot) < 20) and not (weaponID==2 or weaponID==3 or weaponID==4 or weaponID==5 or weaponID==6 or weaponID==7 or weaponID==9 or weaponID==15 or weaponID == 0)) then
    	outputChatBox("Should not fire")
		toggleControl ("fire", false)
	else 
		outputChatBox("Should fire")
		toggleControl("fire", true)
	end
end
addEventHandler ( "onClientPlayerWeaponSwitch", getLocalPlayer(), disableGunOnSwitch )
addEvent ( "onClientPlayerWeaponCheck", true )
addEventHandler ( "onClientPlayerWeaponCheck", getLocalPlayer(), disableGunOnSwitch )

This is the code. It should work but it doesn't. What the function should do is that it doesn't allow you to shoot when you have only one bullet left but it's not working. The conditions are working because the outputChatBox says "Should not fire" in the game but I can fire anyway. What am I doing wrong?

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...