TheRock254 Posted March 20, 2014 Share Posted March 20, 2014 local give = false local tick = getTickCount( ) local endTick = nil addEventHandler( "onClientRender", root, function( thePlayer ) if ( getTickCount( ) - tick >= 1000 ) then give = true if ( not endTick ) then endTick = getTickCount( ) + 1000 end if ( getTickCount( ) >= endTick ) then give = false endTick = nil tick = getTickCount( ) end end if ( give ) then setElementHealth ( thePlayer, getElementHealth(thePlayer)+5 ) end end ) Why this is not work? Where is my mistake? Link to comment
cheez3d Posted March 20, 2014 Share Posted March 20, 2014 Your code conains a lot of mistakes and errors. What are you exactly trying to do? Add 5 health points to the player every second? If yes then use a setTimer. Link to comment
Anubhav Posted March 20, 2014 Share Posted March 20, 2014 If he want's to do that easy. function heal(thePlayer) local health = getElementHealth(thePlayer) if health < 100 then setElementHealth(thePlayer,health+5) end end setTimer(heal,1000,0) Link to comment
cheez3d Posted March 20, 2014 Share Posted March 20, 2014 And where exactly is thePlayer defined in your code? Link to comment
Weii. Posted March 20, 2014 Share Posted March 20, 2014 function checkHeal() for index, value in ipairs (getElementsByType("player")) do local health = getElementHealth(value) if (health and health < 100) then setElementHealth(value,health+5) end end end setTimer(checkHeal,1000,0) Link to comment
cheez3d Posted March 20, 2014 Share Posted March 20, 2014 Bad idea to execute a loop every second. Link to comment
Saml1er Posted March 20, 2014 Share Posted March 20, 2014 You can use "onClientPlayerDamage" instead of using onClientRender or timers. 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