Jump to content

Health


TheRock254

Recommended Posts

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

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