Jump to content

[HELP] setTimer to check elementdata


Recommended Posts

Hello, I am trying to make a function which will check if the player´s element data is over 0, and if its not over 0 then it will kill the player, this is what i´ve made so far:

function checkblood(source) 
    local sourceAccount = getPlayerAccount ( source ) 
    if isGuestAccount ( sourceAccount ) then  
    else 
        local blood = getElementData(source, "health" ) 
        if (blood <= "0") then 
            outputChatBox( "SANGRE NEGATIVA",getRootElement(),255,0,0 ) 
        end 
    end 
end 
setTimer(checkblood, 1000, 0, source) 

I have never used setTimer before, and because of that I dont know how can I achieve this, is there any other good alternative? thank you!.

Link to comment
  
function checkblood() 
    for i, source in ipairs(getElementsByType( "player" ) ) do 
        local sourceAccount = getPlayerAccount ( source ) 
        if isGuestAccount ( sourceAccount ) then 
            -- nothing 
        else 
            local blood = getElementData(source, "health" ) 
            if (blood <= "0") then 
                outputChatBox( "SANGRE NEGATIVA",source,255,0,0 ) 
            end 
        end 
    end 
end 
setTimer(checkblood, 1000, 0) 
  

This is how it should be if you want to use setTimer only

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