Jump to content

If hunger went down player die (HELP)


Phase

Recommended Posts

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
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 by Hydra
  • Thanks 1
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...