Forum

> > CS2D > Scripts > LUA Question - custom spawn
Forums overviewCS2D overview Scripts overviewLog in to reply

English LUA Question - custom spawn

9 replies
To the start Previous 1 Next To the start

old LUA Question - custom spawn

Deleted User

Quote
ok guys, i wonder is this posssible to make custom spawn with a table?

ok table:
1
2
3
4
spwnt[1] = {x, y}
spwnt[2] = {x, y}
spwnct[1] = {x, y}
spwnct[2] = {x, y}

ok how i can make custom spawn with my table?
i cant do it myself coz i not too good scripter,
i need when t spawn he go on RANDOM position in table [1] or [2] spnt

plzz could somone help me?
edited 1×, last 21.05.11 02:32:42 pm

old Re: LUA Question - custom spawn

EngiN33R
Moderator Off Offline

Quote
1
2
3
4
5
6
7
8
addhook("spawn","customspawn")
function customspawn(id)
	if (player(id,"team")==1) then
		parse("setpos "..id.." "..spwnt[1].." "..spwnt[2])
	elseif (player(id,"team")==2) then
		parse("setpos "..id.." "..spwnct[1].." "..spwnct[2])
	end
end

old Re: LUA Question - custom spawn

EngiN33R
Moderator Off Offline

Quote
user Infinite Rain has written
noo
do like that

parse('spawn '..random spwt[1]..' '..random spwnt[2])

You gonna teach me how I should code the most basic stuff? Oh, please...

I already posted a solution, and DannyDeth even repeated it. It IS the right way to do it.

old Re: LUA Question - custom spawn

Deleted User

Quote
No spwnt[1] = {x, y} - HERE IS ALREADY POS
     spwnt[2] = {x, Y} I NEED RANDOM SPAWN!!
     math.random(1, #spwnt)
can u please make something like that?!

old Re: LUA Question - custom spawn

DannyDeth
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
addhook("spawn","spawn_custom")
function spawn_custom(id)
	local a = math.random(1,#spawnt)
	local b = math.random(1,#spawnct)
	if player(id,"team") == 1 then -- terrorist
		parse("setpos "..spawnt[a].x.." "..spawnt[a].y)
	elseif player(id,"team") == 2 then -- couter-terrorist
		parse("setpos "..spawnct[b].x.." "..spawnct[b].y)
	end
end

There you lazy little bastard.

EDIT: added multi-team thingy so that it works with lots of spawns.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview