Forum

> > CS2D > Scripts > Spawn trable
Forums overviewCS2D overview Scripts overviewLog in to reply

English Spawn trable

8 replies
To the start Previous 1 Next To the start

old Spawn trable

Axel340
User Off Offline

Quote
People, I need a script that will spawn a player with id 1 in another place, on coordinates. Please help.

old Re: Spawn trable

Jynxxx
User Off Offline

Quote
Something like this? Not sure what you really want.
1
2
3
4
5
6
addhook("spawn","_spawn")
function _spawn(id)
	if id == 1 then
		parse("setpos 1 xhere yhere") --x and y are in pixels
	end
end

old Re: Spawn trable

Axel340
User Off Offline

Quote
I wrote the following:
1
2
3
4
5
6
addhook("spawn","_spawn")
function _spawn(id)
     if id == 1 then
          parse("setpos 1 x "5344" y "512"")
     end
end

But in the console gives this error: LUA ERROR: maps/ch_!prolog.lua:45: ')' expected near '5344'

what wrong?

old Re: Spawn trable

EP
User Off Offline

Quote
You replaced the strings wrong, this is the way you should do:
1
2
3
4
5
6
addhook("spawn","_spawn")
function _spawn(id)
     if id == 1 then
          parse("setpos 1 5344 512")
     end
end

old Re: Spawn trable

VADemon
User Off Offline

Quote
Axel, if you want to insert variables (strings or numbers) into a text (string), the variable must be outside any " or ' and be between 2 points:
1
2
3
4
x = 5
y = 532

parse("setpos 1 "..x.." "..y)

Else, what @user Jynxxx: meant is that you should have replaced xhere yhere with numbers, nothing more.
edited 1×, last 15.01.13 08:40:59 pm

old Re: Spawn trable

Axel340
User Off Offline

Quote
i write:
1
2
3
4
5
6
7
8
9
addhook("spawn","_spawn")
function _spawn(id)
     if id == 1 then
x = 512
y =5344

	parse("setpos 1 "..x.." "512" "..y.." "5344")
     end
end

but the previous error...
p.s. Yes I don't know scripts
pp.s Yes, I mixed up x and y.

[edited]

it works, thanks. only caused an error in another script, the script uploads the specified image 4 times, because of what the screen was very dark.
edited 1×, last 15.01.13 06:32:31 pm
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview