Hi, I`m currently creating a team based gamemode and i need my 2 different teams to spawn at 2 different places.
How would i go about implementing this?
This is a piece of code iv`e been trying but i doesn't work.
shared.lua
[CODE]
team.SetUp( 1, "Green", Color( 0, 255, 137, 255) )
team.SetUp( 2, "Purple", Color( 85, 0, 255, 250) )
team.SetSpawnPoint( 1, { "info_target" } )
team.SetSpawnPoint( 2, { "info_target" } )
//Other gamemode code....
function GM:PlayerSelectSpawn( ply )
print("Player has spawned")
return team.GetSpawnPoint( ply:Team() )
end
[/CODE]
have a look at Set a custom/existing spawn point here [url]https://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index3148.html[/url] you just need to change "info_player_start" to info_target
[QUOTE=taz0;50605419]have a look at Set a custom/existing spawn point here [url]https://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index3148.html[/url] you just need to change "info_player_start" to info_target[/QUOTE]
Thank you!
But how would i go about defining which team the info_target has?
what you would need to do is instead of having just [QUOTE]local spawns = ents.FindByClass( "info_player_start" ) --Make so that we can use spawns instead of info_player_start (they will do the same things)
local random = math.random(spawns) --Random spawn of the info_player_start
if ply:Team() == 1 --If player is in team 1
then
spawns[random] --Make them always spawn from a random point of this class[/QUOTE]
create one for team 2 using a diff entity call it spawns2 so team1 would spawn at spawns and team2 would spawn at spawns2, just change names so it looks better
[QUOTE=taz0;50605908]what you would need to do is instead of having just
create one for team 2 using a diff entity call it spawns2 so team1 would spawn at spawns and team2 would spawn at spawns2, just change names so it looks better[/QUOTE]
Okey, Thank you!
[QUOTE=taz0;50605908]what you would need to do is instead of having just
create one for team 2 using a diff entity call it spawns2 so team1 would spawn at spawns and team2 would spawn at spawns2, just change names so it looks better[/QUOTE]
I`ve been trying this method out and it seems to work pretty fine. However i`ve been trying to use my own SENTs in hammer but thay aren`t found in game!
shared.lua
[CODE]function GM:PlayerSpawn( ply )
if ply:Team() == 1 then
local spawns = ents.FindByClass( "spgreen" )
local spawn = math.random( spawns )
ply:SetPos( spawn:GetPos())
elseif ply:Team() == 2 then
local spawns2 = ents.FindByClass( "sppurple" )
local spawn2 = math.random( spawns )
ply:SetPos( spawn2:GetPos())
end
end[/CODE]
spgreen.lua
[CODE]AddCSLuaFile()
ENT.Type = "point"
ENT.ClassName = "spgreen"
[/CODE]
sppurple.lua
[CODE]AddCSLuaFile()
ENT.Type = "point"
ENT.ClassName = "sppurple"[/CODE]
Adding the ents in hammer
[IMG]https://drive.google.com/open?id=0B9mZiBNX9hIoUU8zOE52T1R2YlU[/IMG]
entities use key:value system could you do it so its like key info_target value spgreen or value sppurple
i.e local spawn =ENT:KeyValue( string info_target, string spgreen )
EDIT
then all you ned to do is name the info_target entities in hammer spgreen or sppurple :)
Sorry, you need to Log In to post a reply to this thread.