Forum

> > CS2D > Scripts > T spawns in buyzone, CT spawns randomly
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch T spawns in buyzone, CT spawns randomly

8 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt T spawns in buyzone, CT spawns randomly

Torque
User Off Offline

Zitieren
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?

alt Re: T spawns in buyzone, CT spawns randomly

Rainoth
Moderator Off Offline

Zitieren
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.

alt Re: T spawns in buyzone, CT spawns randomly

Rainoth
Moderator Off Offline

Zitieren
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.

alt Re: T spawns in buyzone, CT spawns randomly

gotya2
GAME BANNED Off Offline

Zitieren
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.

alt Re: T spawns in buyzone, CT spawns randomly

Avo
User Off Offline

Zitieren
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.

alt Re: T spawns in buyzone, CT spawns randomly

MikuAuahDark
User Off Offline

Zitieren
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

alt Re: T spawns in buyzone, CT spawns randomly

omg
User Off Offline

Zitieren
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
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht