Jump to content

account data problem


Castillo

Recommended Posts

hey, i've got a problem with a script of account data dunno why it keeps saying bad argument at triggerClientEvent and all seems fine, here is a piece of my code,

function onLoginStuff() 
              local acc = getPlayerAccount ( source ) 
              local zombieKills = getAccountData(acc, "zombieKills") 
              if (tonumber(getAccountData (acc,"level")) == 1) then 
                                   killsTimer = setTimer (function ( ) local killsData = getAccountData(acc,"zombieKills") triggerClientEvent(source,"updateKills",source,killsData,100) end,1000,0) 
              elseif (tonumber(getAccountData (acc,"level")) == 2) then 
                                   killsTimer = setTimer (function ( ) local killsData = getAccountData(acc,"zombieKills") triggerClientEvent(source,"updateKills",source,killsData,200) end,1000,0) 
            end 
        end 
addEventHandler( "onPlayerLogin", getRootElement(), onLoginStuff) 

Link to comment

I think it might be because you need pass source to that function inside the timer.

so: killsTimer = setTimer (function ( ) local to: killsTimer = setTimer (function (source) local

and you may also need to put source as an arguement in setTimer so:

triggerClientEvent(source,"updateKills",source,killsData,200) end,1000,0) to:

triggerClientEvent(source,"updateKills",source,killsData,200) end,1000,0,source)

Link to comment
I think it might be because you need pass source to that function inside the timer.

so: killsTimer = setTimer (function ( ) local to: killsTimer = setTimer (function (source) local

and you may also need to put source as an arguement in setTimer so:

triggerClientEvent(source,"updateKills",source,killsData,200) end,1000,0) to:

triggerClientEvent(source,"updateKills",source,killsData,200) end,1000,0,source)

thanks it worked.

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