• Team spawn points
    6 replies, posted
Hey! Me and a friend of mine (CalzEdz) is making a gamemode. Now, I'm normally the guy who is making the maps, but I can aslo do some code. Now we have a problem with the team spawns (Yes, it's a team based gamemode). we can't get the teams to spawn at any spawnpoint at all on the map that I have created. So, basicly how do we create team spawnpoints on a map and how de we do so a teammember spawn there? This is the error I get: [code] ERROR: GAMEMODE:'PlayerSelectSpawn' Failed: CTC/gamemode/init.lua:24: attempt to get length of local 'spawns' (a nil value) [/code] Btw, here is the PlayerSelectSpawn code that I have made: (One of MANY that have failed) [code] function GM:PlayerSelectSpawn(ply) if ply:Team() == 1 then local spawns = team.GetSpawnPoint( 3 ) local randomspawn = math.random(#spawns) return spawns[randomspawn] elseif ply:Team() == 0 then local spawns = team.GetSpawnPoint( 2 ) local randomspawn = math.random(#spawns) return spawns[randomspawn] end end [/code] On my map I have 2 teamspawns. One is set to be the Red team and the another one is set to be the Blue team. (2 and 3). Thanks in advance, TheRaz.
You don't have to pick a random spawnpoint, as far as I know the game does that for you.
Well, does it pick a team spawn point?
[url]http://www.facepunch.com/showthread.php?t=756730[/url]
You could use: [lua]team.SetSpawnPoint( Team, "spawnpoint" )[/lua] Use the wiki next time: [url]http://wiki.garrysmod.com/?title=Team.SetSpawnPoint[/url]
It didn't work before. Byt I solved it by myself now, thanks anyway
How?
Sorry, you need to Log In to post a reply to this thread.