Forum

> > CS2D > Scripts > Number Expected, Got Nil.
Forums overviewCS2D overview Scripts overviewLog in to reply

English Number Expected, Got Nil.

4 replies
To the start Previous 1 Next To the start

old Number Expected, Got Nil.

Mami Tomoe
User Off Offline

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

old Re: Number Expected, Got Nil.

DC
Admin Off Offline

Quote
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!
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview