knightscript Posted March 30, 2016 Share Posted March 30, 2016 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
ozulus Posted March 30, 2016 Share Posted March 30, 2016 Use this event, there is 2 example it's enough for you https://wiki.multitheftauto.com/wiki/On ... DataChange Link to comment
Anubhav Posted March 31, 2016 Share Posted March 31, 2016 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
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