Jump to content

Grenade delay?


Bean666

Recommended Posts

Posted (edited)

hello , is it possible that a player can only throw 1 grenade in 5 seconds? then after 5 seconds he can throw again.

setTimer 
onPlayerWeaponFire 

, these maybe? or am i wrong.

Edited by Guest
Posted (edited)

try this

timer = {} 
addEventHandler("onClientPlayerWeaponFire", localPlayer, 
function(weapon) 
    if  weapon == 16  then 
        setElementData(localPlayer, "anti repeater", true); 
        if ( getElementData(localPlayer, "anti repeater") == true ) then 
            toggleControl("fire", false); 
            timer[source] = setTimer( function() 
            toggleControl("fire", true); 
            setElementData(localPlayer, "anti repeater", false); 
            removeEventHandler("onClientPlayerWeaponSwitch", getRootElement(), cancelShots); 
            end, 5000, 1 ) 
            addEventHandler("onClientPlayerWeaponSwitch", getRootElement(), cancelShots); 
        end 
    end 
end) 
  
function cancelShots() 
    if ( getPedWeapon(localPlayer) == 16 ) then 
        toggleControl("fire", false); 
        else 
        toggleControl("fire", true);    
    end 
end 

Edited by Guest

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