VenomOG Posted December 6, 2018 Share Posted December 6, 2018 How can i siable a weapon while there is a timer? CODE: elseif (weapon == 42) then if isTimer(cancelTimer["Explosion"]) then return end toggleControl("fire", false) toggleControl("action", false) local tick = getTickCount() enableTime2 = tick+9000 removeEventHandler("onClientRender",root,dxDrawC) addEventHandler("onClientRender",root,dxDrawC) cancelTimer["Explosion"] = setTimer( function() toggleControl("fire", true) toggleControl("action", true) --killTimer(cancelTimer) removeEventHandler("onClientRender",root,dxDrawC) end, 9000, 1 ) I wanna disable grenade while this timer is still there. Link to comment
Moderators Patrick Posted December 6, 2018 Moderators Share Posted December 6, 2018 Something like that -- SERVER local changeStateDelay = 30000 -- 30 sec delay between changes local state = false -- current state setTimer(function() state = not state triggerClientEvent(root, "changeGrenadeState", root, state) end, changeStateDelay, 0) -- CLIENT addEvent("changeGrenadeState", true) addEventHandler("changeGrenadeState", root, function(newState) if newState then -- enable addEventHandler("onClientRender", root, dxDrawC) else removeEventHandler("onClientRender", root, dxDrawC) end toggleControl("fire", newState) end) 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