Jump to content

Hunger Sistem Error


mancebomozo

Recommended Posts

It's about making a system by which users are hungry and will lower the life every hour, forcing them to eat.

  
function texto(texto)  
    outputChatBox ( "Aviso: " .. texto ) 
end 
  
setTimer(texto,3600000,0,"Tienes hambre, come un poco") 
  
  
function startResource() 
    local nivel = getElementData (source, "nivel") 
    if nivel == 1 then 
        setElementHealth  ( source, getElementHealth  ( source ) - 70 ) 
    end 
    setTimer(startResource, 3600000, 0, true) 
     
     
end 
addEventHandler("onResourceStart", getResourceRootElement(), startResource) 

Help please someone tell me the error

Link to comment
  • Moderators

Check your bugs:(admin)

/debugscript 3

I am not sure, but should this not be a:1

setTimer(startResource, 10000,1, true) --14 

Because, he is already triggering him zelf again.

Don't you need to use: localPlayer ? localPlayer = getLocalPlayer ( )

  
Player = getLocalPlayer ( ) 
  
      
    function texto(texto) 
        outputChatBox ( "Aviso: " .. texto ) 
    end 
      
    setTimer(texto,3600000,0,"Tienes hambre, come un poco") 
      
      
    function startResource() 
        local nivel = getElementData (player, "nivel") 
        if nivel == 1 then 
            setElementHealth  ( player, getElementHealth  ( player ) - 70 ) 
        end 
        setTimer(startResource, 3600000, 1, true) 
    end 
    addEventHandler("onResourceStart", getResourceRootElement(), startResource) 
  

Link to comment
  • Moderators

you can try this:

  
  
function texto(texto) 
    outputChatBox ( "Aviso: " .. texto ) 
end 
  
setTimer(texto,3600000,0,"Tienes hambre, come un poco") 
  
  
function startResource() 
    for k,player in ipairs(getAlivePlayers())  
        local nivel = getElementData (player, "nivel") 
            if nivel == 1 then 
                setElementHealth  ( player, getElementHealth  ( player ) - 70 ) 
            end 
        setTimer(startResource, 3600000, 1, true) 
    end 
end 
  
addEventHandler("onResourceStart", getResourceRootElement(), startResource) 
  

I don't think this is going to work because....

I am to tired to rebuild it :(

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