itHyperoX Posted January 4, 2017 Posted January 4, 2017 (edited) HeyGuys. I'm trying to make a script, which is very simple. Example: If player only have 1 ammo in his weapon , he can't shoot the last ammo .. gMe = getLocalPlayer() addEventHandler('onClientPlayerWeaponSwitch',gMe,function(prevSlot,currSlot) if(getPedTotalAmmo(prevSlot) == 1) then toggleControl('fire',true) end if(getPedTotalAmmo(currSlot) == 1) then toggleControl('fire',false) end Whats the problem? Edited January 4, 2017 by TheMOG forgot
Miika Posted January 4, 2017 Posted January 4, 2017 addEventHandler("onClientWeaponFire", root, function() local weapon = getPedPedWeapon(getLocalPlayer()) if getWeaponAmmo(weapon) == 1 then cancelEvent() end end)
itHyperoX Posted January 4, 2017 Author Posted January 4, 2017 Not working dude. Still taking the weapon.
iPrestege Posted January 4, 2017 Posted January 4, 2017 int getPedTotalAmmo ( ped thePed, [ int weaponSlot = current ] ) it's not a weapon first argument is the ped.
N3xT Posted January 4, 2017 Posted January 4, 2017 addEventHandler("onClientPedWeaponFire", root, function(_, ammo) if ammo == 1 then cancelEvent() end end )
itHyperoX Posted January 4, 2017 Author Posted January 4, 2017 still no working, i dont know whats wrong @iPrestege i tryed another version, (from facebook group) but still taking the weapon.
iPrestege Posted January 4, 2017 Posted January 4, 2017 local aNotToDisable = { [0]=true;[1]=true;[2]=true;[3]=true;[4]=true;[5]=true; [6]=true;[7]=true;[8]=true;[9]=true;[10]=true;[11]=true;[12]=true;[14]=true; [15]=true;[44]=true;[45]=true;[46]=true;[40]=true }; aDisableLastShoot = function ( ) if aNotToDisable[getPedWeapon(source)] then return false end; if getPedTotalAmmo ( source ) == 1 then toggleControl( 'fire',false ); outputChatBox ('You can not shoot now get more ammo!'); else toggleControl( 'fire',true ); end end addEventHandler ( 'onClientPlayerWeaponSwitch',localPlayer,aDisableLastShoot ); addEventHandler ( 'onClientPlayerWeaponFire',localPlayer,aDisableLastShoot ); You can try with this . @TheMOG
itHyperoX Posted January 4, 2017 Author Posted January 4, 2017 Man.. You are a hero! Thankyou very much, And thanks the help again. In my country nobody help to anyone with script.. Thanks again!
itHyperoX Posted January 4, 2017 Author Posted January 4, 2017 @iPrestege is that okey, i can't hit with "fist" ?
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