Phase Posted May 11 Share Posted May 11 Hello guys. I want to make a script for my mta server. The Player have hunger and thirst, I want to make a script what kills the player if the players hunger or thirst went down 0. I show you my script. setTimer( function() local hunger = getElementData(localPlayer, "Player:Hunger") if (hunger > 0) then setElementData(localPlayer, "Player:Hunger", hunger - 2) end local thirst = getElementData(localPlayer, "Player:Thirst") if (thirst > 0) then setElementData(localPlayer, "Player:Thirst", thirst - 3) end end , 150000,0) function ehenhalt ( localPlayer ) if (hunger < 0) then killPed ( localPlayer) end addCommandHandler ( "kill", ehenhalt ) Please help me, god bless yall. Link to comment
Flashmyname Posted May 11 Share Posted May 11 You should try like this. if hunger > 7 then random = math.random(4, 7) setElementData(localPlayer, "Player:Hunger", hunger - random) elseif hunger ~= 0 and hunger <= 7 then setElementData(localPlayer, "Player:Hunger", 0) end 1 Link to comment
Hydra Posted May 11 Share Posted May 11 (edited) function checkHungerAndThirst() local getHunger = getElementData(localPlayer, "Player:Hunger") local getThirst = getElementData(localPlayer, "Player:Thirst") if getHunger <= 0 then setElementHealth(localPlayer, 0) end if getThirst <= 0 then setElementHealth(localPlayer, 0) end end setTimer(checkHungerAndThirst, 1000, 0) Edited May 11 by Hydra 1 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