Forum

> > CS2D > Scripts > What is this and this?
Forums overviewCS2D overview Scripts overviewLog in to reply

English What is this and this?

5 replies
To the start Previous 1 Next To the start

old What is this and this?

Eternal
User Off Offline

Quote
Hello us
I have 2 questions with these codes.

1 :
1
LUA ERROR:sys/lua/test.lua:48: bad argument#1 to 'menu' (number expected,got string)
This is my first question , what is this? it's cause by?

2 :
1
LUA ERROR:sys/lua/test.lua:48: attempt to concatenate field '1'
This is my second question , what is this? it's cause by?

My code :
1
2
maps = {"de_dust","de_dust2"}
menu("Map Vote,"..maps[1]..","..maps[2].."")
I think my code it's not hard to guess what is this code about.

Thank you.

old Re: What is this and this?

Avo
User Off Offline

Quote
First argument of function menu must be ID of player (1-32 or 0 for all players).

1
2
3
4
5
6
7
8
9
10
11
maplist={ [1]="de_dust", [2]="de_dust2" }

--could be also maplist={"de_dust","de_dust2"}

addhook("serveraction","vote")
function vote(id,action)
	if action==3 then
		menu(id,"Vote for map,"..maplist[1]..","..maplist[2])
	end

end

EDITED (addhooh-->addhook)
edited 2×, last 23.07.12 12:25:35 pm

old Re: What is this and this?

Eternal
User Off Offline

Quote
Oh , i forget "ID" trustfully maybe it's because of i didn't write and work on Lua for a long time that cause me forget everything
anyway Thank you

old Re: What is this and this?

DC
Admin Off Offline

Quote
Also that
1
..""
at the end is totally pointless. You attach (..) an empty string ("") this way - which doesn't change anything and just makes your script slower for no reason. Don't do that. Attaching empty strings changes nothing.

Most people seem to do that mistake. Probably because someone started that bullshit and everyone copies the scripts of that person... I'm not sure.

old Re: What is this and this?

Eternal
User Off Offline

Quote
Spoiler >


I don't know who started this bullshit but since i have ever played this game , i always found (..) in every scripts i used in my server. By the way i haven't ever known that (..) does nothing

old Re: What is this and this?

DC
Admin Off Offline

Quote
No, that's not what I said! You still didn't understand it.
.. = connects two strings. It makes sense.
but .. '' = adds an empty string. This makes no sense!
Example
1
variable = 'lol, '..'hi!'
variable will have the value: 'lol, hi!' afterwards.

1
2
variable = 'lol'
variable = variable..''
variable will have the value lol. Line 2 does nothing. It adds an empty string. This changes nothing because lol + empty string is still = lol
(you could also use " instead of ' in those samples. It's the same thing)
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview