Jump to content

Possibly MTA bug with timers.


xScatta

Recommended Posts

Hi all i have a problem i will put code now and the description of problem will be under.

function healMedic() 
    for key, player in ipairs(getElementsByType( "player")) do 
    local hp = getElementHealth(player) 
    setElementHealth(player,hp+1) 
    end 
end 
  
setTimer(healMedic,1000,0) 

So. why my health raises only one time?

But if i replace "+" with "-" it will fall down but when it is "+" then it raises only once.

Any help.?

Thanks.

Link to comment

you can check if player health no is full, here work if health max is 100.

function healMedic() 
    for key, player in ipairs(getElementsByType( "player")) do 
    local hp = getElementHealth(player) 
    if(hp<=99)then 
    setElementHealth(player,hp+1) 
        end 
    end 
end 
  
setTimer(healMedic,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...