Forum

> > CS2D > Scripts > What is this and this?
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch What is this and this?

5 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt What is this and this?

Eternal
User Off Offline

Zitieren
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.

alt Re: What is this and this?

Avo
User Off Offline

Zitieren
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)
2× editiert, zuletzt 23.07.12 12:25:35

alt Re: What is this and this?

Eternal
User Off Offline

Zitieren
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

alt Re: What is this and this?

DC
Admin Off Offline

Zitieren
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.

alt Re: What is this and this?

Eternal
User Off Offline

Zitieren
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

alt Re: What is this and this?

DC
Admin Off Offline

Zitieren
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)
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht