Spawn trable
8 replies



14.01.13 03:56:06 pm
People, I need a script that will spawn a player with id 1 in another place, on coordinates. Please help.
Something like this? Not sure what you really want.
Code:
1
2
3
4
5
6
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
function _spawn(id)
if id == 1 then
parse("setpos 1 xhere yhere") --x and y are in pixels
end
end
I wrote the following:
But in the console gives this error: LUA ERROR: maps/ch_!prolog.lua:45: ')' expected near '5344'
what wrong?
Code:
1
2
3
4
5
6
2
3
4
5
6
addhook("spawn","_spawn")
function _spawn(id)
if id == 1 then
parse("setpos 1 x "5344" y "512"")
end
end
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?
You replaced the strings wrong, this is the way you should do:
Code:
1
2
3
4
5
6
2
3
4
5
6
addhook("spawn","_spawn")
function _spawn(id)
if id == 1 then
parse("setpos 1 5344 512")
end
end
function _spawn(id)
if id == 1 then
parse("setpos 1 5344 512")
end
end
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:
Else, what @
Jynxxx: meant is that you should have replaced xhere yhere with numbers, nothing more.
Code:
1
2
3
4
2
3
4
x = 5
y = 532
parse("setpos 1 "..x.." "..y)
y = 532
parse("setpos 1 "..x.." "..y)
Else, what @

edited 1×, last 15.01.13 08:40:59 pm
i write:
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.
Code:
1
2
3
4
5
6
7
8
9
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
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



