Forum

> > CS2D > Scripts > timer
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch timer

5 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt timer

vader
User Off Offline

Zitieren
i have a timer
1
timer(100,'antisp',id)
that start this function
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
-----------------
2× editiert, zuletzt 14.07.15 17:46:53

alt Re: timer

TimeQuesT
User Off Offline

Zitieren
The argument will be given as string. So you have to force it to be a number again.
1
2
3
4
function antisp(id)
	id = tonumber(id);
	antisp2[id] = antip2[id]-1;
end

alt Re: timer

vader
User Off Offline

Zitieren
TimeQust,

1
id=math.tonumber(id)
LUA ERROR: sys/lua/my/scripts/chat.lua:78: attempt to call field 'tonumber' (a nil value)

alt Re: timer

TimeQuesT
User Off Offline

Zitieren
It is in the global namespace. I have no idea why you looked it up in the math ones.

1
id = tonumber(id);
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht