General > Developers Corner
Timer issue
Digital Spit:
I'm working on a little script that'll change the job of a player after a given time, but for some reason I can't get the timer to work, what am I doing wrong? I've tried moving it all to one line and I've also tried rewriting the timer, but alas no result :/
--- Code: ---local Players = player.GetAll()
for i = 1, table.Count(Players) do
local ply = Players[i]
if (ply:Team() == TEAM_DEFAULTED ) then
timer.Create("randomJob", 180, 1,
ply:changeTeam( job_table[randomJob], true),
ply:PrintMessage(HUD_PRINTCENTER, "Your job has been auto-selected")
end)
end
--- End code ---
Cobalt:
Timers have unique ids like hooks. If two are the same they will overwrite.
Digital Spit:
I've changed the ID of the timer, but that give the same error...any other suggestions? :)
--- Code: ---[ERROR] lua/money.lua:55: ')' expected (to close '(' at line 52) near 'end'
1. unknown - lua/money.lua:0
--- End code ---
That's the error I keep getting and I'm not sure why. All of the parenthesis close out perfectly, what am I missing?
An Error Has Occurred!
array_keys(): Argument #1 ($array) must be of type array, null given
[0] Board index
Go to full version