Disy Posted April 30, 2017 Share Posted April 30, 2017 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
Disy Posted April 30, 2017 Author Share Posted April 30, 2017 (edited) After a few tests, I noticed that it doesn't work only with the mouse click, with others keys it works correctly but I need to fix it. Edited April 30, 2017 by Disy Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now