Forum

> > CS2D > Scripts > T spawns in buyzone, CT spawns randomly
Forums overviewCS2D overview Scripts overviewLog in to reply

English T spawns in buyzone, CT spawns randomly

8 replies
To the start Previous 1 Next To the start

old T spawns in buyzone, CT spawns randomly

Torque
User Off Offline

Quote
Hi guys,
I need some help with a lua script. I want to make it so that the terrorist forces spawn in their buyzone, but the counterterrorists spawn randomly inside the map, like with mp_randomspawn 1.
I was thinking to setpos the terrorists to a normal spawnpoint in the map, but how do I find those positions?

old Re: T spawns in buyzone, CT spawns randomly

Rainoth
Moderator Off Offline

Quote
Open map editor and look up tile coordinates.
E.g. 17|32

Then multiply them by 32 to get the starting pixel of that tile.

In setpos command you can add "+16" to both x and y so it would spawn the player in center of tile.

old Re: T spawns in buyzone, CT spawns randomly

Rainoth
Moderator Off Offline

Quote
well. If not like that, you could use an entity in map you're making that does basically nothing but you give it a certain name then using a hook you could make "do whatever you want" on those types of entities. You won't have to find coordinates that way.

old Re: T spawns in buyzone, CT spawns randomly

gotya2
GAME BANNED Off Offline

Quote
You could spawn on botnodes ..
This works on all maps that have botnodes in them ( dust, dust2 etc. )

1
x,y=randomentity(19)

i believe 19 is the id for info_botnode, not sure though.

old Re: T spawns in buyzone, CT spawns randomly

Avo
User Off Offline

Quote
1
2
3
4
5
6
7
8
parse("mp_randomspawn 1")
addhook("spawn", "HookSpawn_")
HookSpawn_ = function(id)
	if player(id, "team") == 1 then
		local x, y = randomentity(0)
		parse("setpos "..id.." "..(x * 32 + 16).." "..(y * 32 + 16))
	end
end
Here you are.

old Re: T spawns in buyzone, CT spawns randomly

MikuAuahDark
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
13
addhook("spawn","gelap")
function gelap(id)
	if player(id,"team")==2 then
		local len_x,len_y=map("xsize"),map("ysize")
		local x,y=0,0
		local r=math.random
		local t=tile
		repeat
			x,y=r(0,len_x),r(0,len_y)
		until t(x,y,"walkable")==true and t(x,y,"frame")>0
		parse("spawnplayer "..id.." "..(x*32+16).." "..(y*32+16))
	end
end
I hope i am not ending with infinite loop

old Re: T spawns in buyzone, CT spawns randomly

omg
User Off Offline

Quote
easy. all u have to do is play with cs2d a bit and u learn better solutions

1
2
3
4
5
6
addhook("spawn","small_penis")
function small_penis(id)
	if player(id,"team")==2 then
		parse("spawnplayer "..id.." 999999 999999")
	end
end

always works (unless your map is gigantic) and doesnt require mapping

Spoiler >


the t(x,y,"frame")>0 isnt necessary
unless theres no walkable tiles, this will eventually work. not very efficient
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview