MasterTobi

SetTimer Problem

Recommended Posts

hey

my Code:

function test() 
account = getClientAccount (source) 
Job =  getAccountData (account,"Job") 
Team =  getAccountData (account, "Team") 
end 
setTimer(test,10000,1) 
  

now if the function start then i have the following error :

Bad Argument @ 'getClientAccount --line3

Bad Argument @ 'getClientAccount --line4

where is the problem ?

thx

Share this post


Link to post
hey

my Code:

function test() 
account = getClientAccount (source) 
Job =  getAccountData (account,"Job") 
Team =  getAccountData (account, "Team") 
end 
setTimer(test,10000,1) 
  

now if the function start then i have the following error :

Bad Argument @ 'getClientAccount --line3

Bad Argument @ 'getClientAccount --line4

where is the problem ?

thx

Hi there, there are a few problems with your code.

Firstly timers have to be declared in a function, your best bet is to do that in a function linked to the onResourceStart Event

Secondly you cannot call the variable 'source' unless it is from an event. Info: Source

Share this post


Link to post

Firstly timers have to be declared in a function, your best bet is to do that in a function linked to the onResourceStart Event

That's not true. You can call setTimer anywhere and anytime you want. Even when it's in the body of your script.

Share this post


Link to post

Firstly timers have to be declared in a function, your best bet is to do that in a function linked to the onResourceStart Event

That's not true. You can call setTimer anywhere and anytime you want. Even when it's in the body of your script.

huh never knew that... but it's just as good to put it in a function handling onResourceStart...

Share this post


Link to post

and what is the source of your function? i think that function cant gets the source of function (sounds not good :P) so thats why you have a warning..

May be you should get all players on server and get their account datas?

Something like this:

function test () 
    for k,players in ipairs (getElementsByType("players")) do 
        local account = getClientAccount ( players ) 
        if not isGuestAccount (account) then 
            local job = getAccountData ( account, "Job" ) 
            local team = getAccountData ( account, "Team" ) 
        end 
    end 
end 
setTimer ( test, 10000, 1 ) 

Share this post


Link to post

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.