Jump to content

killtimer


boro

Recommended Posts

Hi i have stamina script, it work good but when i am killed and then respawned then timers dont are killed why? i have set killtimer for ( checktimer ). ty for help

stamina = 100 
addEventHandler ( "onClientPlayerSpawn", getLocalPlayer(), 
function () 
stamina = 100 
if isTimer( checktimer ) then 
killTimer ( checktimer ) 
else 
local checktimer = setTimer(checkKeyone,1000,0) -- this timer dont are killed 
end 
end) 
  
function checkKeyone() 
if ( getControlState ( "sprint" ) ) and stamina ~= 0 then 
stamina = stamina -1 
end 
if ( stamina == 0 ) then 
local updatetimer = setTimer(updateStamina,10000,1) 
setControlState( "sprint", false ) 
end 
end 
  
function updateStamina() 
if stamina == 0 and getControlState ( "sprint" ) == false then 
stamina = stamina +100 
if isTimer( updatetimer ) then 
killTimer ( updatetimer ) 
end 
end 
end 

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