Forum

> > CS2D > Scripts > error in lua
Forums overviewCS2D overview Scripts overviewLog in to reply

English error in lua

8 replies
To the start Previous 1 Next To the start

old error in lua

Jhony
User Off Offline

Quote
what my error
i created one menu
1
menu(id,""..player(pl,"name")..","..player(pl,"name").."")

ERROR :
1
LUA ERROR: sys/lua/impos.lua:36: bad argument #1 to 'player' (number expected, got nil)

help pls
sorry inglish

old Re: error in lua

VADemon
User Off Offline

Quote
1
menu(id,""..player(id,"name")..","..player(id,"name").."")

Why so?

I will describe it in an example:
You sends a letter (function) to your friend with a number in it (id). In his language id is pl
So, we call a function: menu(id) but the friend receives it and for him it's so: menu(pl). The only local variable in this function he can use is pl. That's why you have to look which variable names you have in this function.

Well I hope I didn't many mistakes (english) and you understood that.

WRONG:
1
2
3
function msg(id)
msg("The ID is:"..pl)
end

RIGHT:
1
2
3
function msg(pl)
msg("The ID is:"..pl)
end

ALSO RIGHT:
1
2
3
function msg(num,id)
msg("The ID is:"..id.." And the number is:"..num)
end

old =T

Jhony
User Off Offline

Quote
look

1
LUA ERROR: sys/lua/impos.lua:52: bad argument #1 to 'player' (number expected, got nil)

and

1
2
addhook("menu","action2")
function action2(id,tittle,button,pl)

and
Error in line 52 :

1
menu(id,"USGN,"..player(pl,"name")..","..player(pl,"name")..","..player(pl,"name")..","..player(pl,"name")..","..player(pl,"name")..","..player(pl,"name")..","..player(pl,"name")..","..player(pl,"name").."")


help me urgent

old Re: error in lua

Jhony
User Off Offline

Quote
user Yates has written
@user Jhony: pl = id, remove it from the function and replace all pl with id.


not
I do not want to change the ID function
only want the "pl" is to choose the player

old Re: error in lua

Yates
Reviewer Off Offline

Quote
Since pl won't work you are either forced to make it work with a function, but that would be changing id into pl which is a waste of time or listen to me and change it. It's not like the world will fall apart because of this. I'm trying to help, in fact.

old Re: error in lua

Bowlinghead
User Off Offline

Quote
Just change the parameter "id" to "pl".

1
2
addhook("menu","action2")
function action2(pl,tittle,button)

And the code is right!
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview