• team.SetSpawnPoint() doesent set the spawnpoint.
    6 replies, posted
I use [b][url=http://wiki.garrysmod.com/?title=Team.SetSpawnPoint]Team.SetSpawnPoint [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b] to try to set the spawnpoints of the teams, but it just doesent do it. This is in shared: [lua] team.SetUp( 1, "BLU", Color( 0, 180, 230, 255 ) ) team.SetUp( 2, "RED", Color( 240, 50, 50, 255 ) ) team.SetSpawnPoint(1, "info_player_counterterrorist") team.SetSpawnPoint(2, "info_player_terrorist") [/lua] But the team still spawns everywhere all the possible spawnpoints are. [code] info_player_start info_player_counterterrorist info_player_terrorist [/code] I do have Css if that would be the problem, and I know that the map got those spawnpoints. I have heard before that you could make the spawnpoints entities for your gamemode to make it work, I tried that with no succes. Yes, I haved tried using facepunch search, but it wont allow searchs atm? Please help me to get this problem out of the way.
[CODE]function GM:PlayerSelectSpawn( pl ) local blue = ents.FindByClass("info_player_counterterrorist") local red = ents.FindByClass("info_player_terrorist") local random_1 = math.random(#blue) local random_2 = math.random(#red) if pl:Team() == 1 then return red[random_2] elseif pl:Team() == 2 then return blue[random_1] end end [/CODE] This goes in init.lua btw, not shared.
Thank you, It works perfect.
I find i have to override this too, so the team.SetSpawnPoint() function is broken?
[QUOTE=Willox;23802213]I find i have to override this too, so the team.SetSpawnPoint() function is broken?[/QUOTE] I think so, it didn't work for me either.
Thank you, this helped a ton.
Just to clarify for people who get to this thread: To get that function to work, you must specify that your gamemode is Team Based: [url]https://github.com/garrynewman/garrysmod/blob/master/garrysmod/gamemodes/base/gamemode/shared.lua#L24[/url] So, that would be [code]GM.TeamBased = true[/code] in shared.lua of the gamemode.
Sorry, you need to Log In to post a reply to this thread.