• Team spawner not working
    5 replies, posted
Title says it all [CODE]function GM:PlayerSelectSpawn( ply ) --Make a team select a spawn and randomize where they spawn local spawns = ents.FindByClass( "info_player_terrorist" ) --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 end --End if condition local spawns = ents.FindByClass( "info_player_counterterrorist" ) --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() == 2 --If player is in team 1 then spawns[random] --Make them always spawn from a random point of this class end --End if condition end[/CODE] [CODE][ERROR] gamemodes/example/gamemode/init.lua:28: '=' expected near 'end' 1. unknown - gamemodes/example/gamemode/init.lua:0 [/CODE]
Full code as the error is referencing line 28 and I counted and there's not 28 lines.
this is in the code of init.lua theres other code then this theres more code [IMG]http://i.imgur.com/x6xdGV4.png[/IMG]
Why not use team.SetSpawnPoint inside your CreateTeams() function?
[code] function GM:PlayerSelectSpawn( ply ) local spawns = ents.FindByClass( "info_player_terrorist" ) local truespawn = table.Random(spawns) if (ply:Team() == 1) then return truespawn end local spawns = ents.FindByClass( "info_player_counterterrorist" ) local truespawn = table.Random(spawns) if (ply:Team() == 2) then return truespawn end end [/code] Terrible code and could be simplified with elseifs, but you get the point.
thank you lolcats
Sorry, you need to Log In to post a reply to this thread.