Forum

> > CS2D > Scripts > Number Expected, Got Nil.
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Number Expected, Got Nil.

4 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt Number Expected, Got Nil.

Mami Tomoe
User Off Offline

Zitieren
I searched for a fix but all I got was a fixed code and since I use a different code I cant use it...

Spoiler >


Error:
1
2
3
4
LUA ERROR: sys/lua/autorun/exp.lua:108: bad argument #1 to 'player' (number expected,
got nil)
 -> [C]: in function 'player'
 -> sys/lua/autorun/exp.lua:108: in function <sys/lua/autorun/exp.lua:107>

alt Re: Number Expected, Got Nil.

DC
Admin Off Offline

Zitieren
The error is very self-explanatory actually.

• The erroneous line is 108 which is in your code
1
name = player(id,"name")

• The problem is argument #1 of the function call "player". So it's id

• The actual value of the argument (id) is nil (= undefined) but a number is expected by CS2D. Otherwise CS2D cannot know of which player you want to get the name!

√ Solution: You either have to save a value in id or you have to replace id with another variable which contains a valid value.

You are actually calling that function from the hook cs2d lua hook ms100 which does NOT provide a player ID because it is not related to any specific player. So the question is for what player do you want to do this stuff? For every player? Then you should build a loop around it. Or for just one? Then you should just pass the right ID!
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht