English timer

5 replies
Goto Page
To the start Previous 1 Next To the start
14.07.15 05:06:41 pm
Up
vanyok2011
User
Offline Off
i have a timer
Code:
1
timer(100,'antisp',id)

that start this function
Code:
1
2
3
function antisp(id)
antisp2[id]=antisp2[id]-1
end

there is error
LUA ERROR: sys/lua/my/scripts/chat.lua:83: attempt to perform arithmetic on field '?' (a nil value)
how fix that?


-----------------
thx timequest
-----------------
edited 2×, last 14.07.15 05:46:53 pm
14.07.15 05:12:14 pm
Up
TimeQuesT
User
Offline Off
The argument will be given as string. So you have to force it to be a number again.
Code:
1
2
3
4
function antisp(id)
     id = tonumber(id);
     antisp2[id] = antip2[id]-1;
end
Muh
14.07.15 05:13:45 pm
Up
gamus
User
Offline Off
Post the whole script...
14.07.15 05:27:43 pm
Up
vanyok2011
User
Offline Off
TimeQust,

Code:
1
id=math.tonumber(id)

LUA ERROR: sys/lua/my/scripts/chat.lua:78: attempt to call field 'tonumber' (a nil value)
14.07.15 05:29:15 pm
Up
TimeQuesT
User
Offline Off
It is in the global namespace. I have no idea why you looked it up in the math ones.

Code:
1
id = tonumber(id);
Muh
14.07.15 05:33:51 pm
Up
Joni And Friends
User
Offline Off
@user vanyok2011: This file cs2d Timer Extra function(timerEx) v4.0 (12) should help you for creating cs2d lua cmd timer
Web | file File does not exist (15501) | file File does not exist (15463) | file cs2d [JAF] Adventure (19) | file File does not exist (15919)
To the start Previous 1 Next To the start