Forum

> > CS2D > Scripts > Script error.
Forums overviewCS2D overview Scripts overviewLog in to reply

English Script error.

10 replies
To the start Previous 1 Next To the start

old Script error.

Yates
Reviewer Off Offline

Quote
Lol, just started. Thought I should give it a try.
I get an error, server.lua:5: ')' expected near ','
I fail, and I know nothing about scripting and the commands, reading them now actually..
1
2
3
4
5
6
7
8
USGN = {21431}

addhook("fgspawn","spawn")
function spawn(id,usgn)
if (id,usgn) = USGN
then player spawn x==1 y==1
end
end
I'm humiliating myself now aren't I?
Spoiler >

I didn't know what to call the thread, so I did this oO
But, if there are more errors tell me what I did wrong, don't just give me a script I wouldn't learn.

old Re: Script error.

Yates
Reviewer Off Offline

Quote
Yes, because I fail..
but, what I wanted to do was if you have a certain USGN you would spawn somewhere else..
I could fill in the x and y..

old Re: Script error.

FiNEX
User Off Offline

Quote
this is totally wrong, i dont know but i think the hook "fgspawn" doesn't exists, try this for your script:
1
2
3
4
5
6
7
8
9
10
usgn = "21431" --your usgn
x = 1 --the xpos for spawn
y = 1 --the ypos for spawn

addhook("spawn,","fgspawn")
function fgspawn(id)
	if player(id,"usgn")==usgn then
		parse("setpos "..id.." "..x.." "..y)
	end
end
edited 3×, last 29.03.11 08:13:07 pm

old Re: Script error.

DC
Admin Off Offline

Quote
@Yates:
I'm sorry but I have to tell you that everything there is horribly wrong.

please read a Lua tutorial. just guessing how things work doesn't work. you need a basic understanding of how to write Lua scripts.

× the spawn hook has no USGN id parameter
× the expression "if (id,usgn) = USGN" doesn't make sense
× the expression "player spawn x==1 y==1" doesn't make any sense as well

leon7070's script is not fully correct either. in Lua you use "==" to compare if two values are equal. "=" is for assignments.

old Re: Script error.

Yates
Reviewer Off Offline

Quote
Don't be sorry xP
I suck, and I know it..
I will read more about lua.
But for the time being it's fixed..

1
2
3
4
5
6
7
8
addhook("spawn","fgspawn")
function fgspawn(id)
 for id=1,32 do
  if player(id,"usgn")==21431 then
   parse("setpos "..id.." 100 100)
  end
 end
end
edited 1×, last 29.03.11 08:17:36 pm

old Re: Script error.

RAVENOUS
BANNED Off Offline

Quote
DC has written
Long quote, short sense

I already told him the right answer, next time he's asking me

old Re: Script error.

FiNEX
User Off Offline

Quote
Yates has written
Don't be sorry xP
I suck, and I know it..
I will read more about lua.
But for the time being it's fixed..

1
2
3
4
5
6
7
8
addhook("spawn","fgspawn")
function fgspawn(id)
 for id=1,32 do
  if player(id,"usgn")==21431 then
   parse("setpos "..id.." 100 100)
  end
 end
end


you dont need "for id=1,32 do", its already in the function "fgspawn(id)".

old Re: Script error.

Yasday
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
usgns = { 21431 }
the_x_value = 100
the_y_value = 100

addhook("spawn","fgspawn")
function fgspawn(id)
	for _, id in ipairs(player(0, "table")) do
		for __, us in ipairs(usgns) do
			if player(id,"usgn") == us then
				parse("setpos "..id.." "..(the_x_value * 32 + 16).." "..the_y_value * 32 + 16)
				return
			end
		end
	end
end
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview