Jump to content

[HELP] setTimer triggering


LabiVila

Recommended Posts

  
function getAll () 
    for i,player in ipairs (getElementsByType ("player")) do  
        local account = getPlayerAccount (player) 
        if account then 
            local name = getAccountName (account) 
            local points = getAccountData (account, "DMpoints") 
            local money = getAccountData (account, "DMmoney") 
            outputChatBox (name.." "..points.." "..money) 
            triggerClientEvent ("info", player, name, points, money) 
        end 
    end 
end 
setTimer (getAll, 1000, 0) 
  

hey, what's wrong with this trigger? outputchatbox works fine but I am not getting the data client-side...

I get: attempt to concatenate local money (a nil value), so it obviously trigger's fault, I'd be glad to know what's wrong tho..

thanks in advance

Link to comment
  • Moderators

It means that the account data hasn't been set yet. It is nil.

Replace line 7 t/m 8 with:

local points = tonumber(getAccountData (account, "DMpoints")) or 0 
local money = tonumber(getAccountData (account, "DMmoney")) or 0 

Which will replace the accountdata with 0, when it hasn't been set/hasn't been set correct.

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