• Custom Spawnpoints, Help?
    12 replies, posted
Hey everyone, Currently im trying to get players to another location when they spawn and somehow i cant get it to work. could someone check this piece of code to see if im doing anything wrong? its for a gamemode ^^ [code] function GM:PlayerSpawn( ply ) self.BaseClass:PlayerSpawn(ply) if (ply:Team() == 0) then ply:SetPos(Vector(7165, -10800, -8988)) --Area on a map of mine ply:SetAngles ( Angle( 0, 0, 0 ) ) elseif (ply:Team() == 1) then ply:SetPos(Vector(9415, 10845, 830)) ply:SetAngles ( Angle( 0, 180, 0 ) ) elseif (ply:Team() == 2) then ply:SetPos(Vector(9415, 10845, 830)) ply:SetAngles ( Angle( 0, 0, 0 ) ) elseif (ply:Team() == 3) then ply:SetPos(Vector(9415, 10845, 830)) ply:SetAngles ( Angle( 0, 0, 0 ) ) elseif (ply:Team() == 4) then ply:SetPos(Vector(9415, 10845, 830)) ply:SetAngles ( Angle( 0, 0, 0 ) ) end end [/code]if someone could fix me up with a solution, that would be totally awesome, as im stuck now and cant do a damn thing before this gets fixed.. xD Peace, [I][B]Michael[/B][/I]
[b][url=wiki.garrysmod.com/?title=Gamemode.PlayerSelectSpawn]Gamemode.PlayerSelectSpawn [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b] nuff said
Thanks, ill give it a try. :D does this also work when a player spawns for the first time? like after joining? Possible to insert vectors? like my example above? [editline]6th April 2011[/editline] i figured it out.. ^^ this is my code now: [lua] function GM:PlayerSelectSpawn( pl ) if (ply:Team() == 0) then return Vector(7165, -10800, -8988) -- ply:SetPos(Vector(7165, -10800, -8988)) --Area on a map of mine -- ply:SetAngles ( Angle( 0, 0, 0 ) ) elseif (ply:Team() == 1) then return Vector(9415, 10845, 830) -- ply:SetPos(Vector(9415, 10845, 830)) -- ply:SetAngles ( Angle( 0, 180, 0 ) ) end end [/lua] some how it places me WAY OFF the given vector, do i need to make them toLocal or toWorld?? (if these are wrong, blame E2 :P)
:)
mhmm my last post contains some mistakes, forgot to change pl into ply xP so changed it and it just spawns me at a different place then intended, any other suggestion then just a smiley face :P thx
Well, maybe try: [lua] function SpawnPosition( ply ) if ply:Team( ) == 1 then ply:SetPos( Vector( -10681, 10396, 551 ) ) elseif ply:Team( ) == 2 then ply:SetPos( Vector( -9662, 10451, 517 ) ) end end [/lua] Then under: function GM:PlayerSpawn( ply ) do [lua] SpawnPosition( ply ) [/lua] [editline]6th April 2011[/editline] Worked for me at least some weeks ago.
Yeah that code worked for me 2 days ago, n now im having no luck at all :( soo what the hell is wrong :S side idea: maybe i can create entities that auto-load with the map on a given vector n then let GM:PlayerSelectSpawn define the ents where what team should start? like this?[lua] function GM:PlayerSelectSpawn( pl ) if (ply:Team() == 0) then return ents.FindByClass( "info_player_start" ) elseif (ply:Team() == 1) then return ents.FindByClass( "info_player_custom_start" ) end end [/lua] will any thing like that even work?
Uh, there was a way using info_player_* but I can't remember how.
You could make basic point entities and place them on the map. Then use: [lua] team.SetSpawnPoint(1, "team_1_spawn" ) [/lua]
Didnt work either.. :( im out of ideas, please feel free to post a working solution. Thanks
Give us the code that you are using. [url]http://wiki.garrysmod.com/?title=Team.SetSpawnPoint[/url] Use that code. It should work. Just make a point entity, and place it on the map.
If you think its the Vectos that might be wrong, then go back to that position and type "getpos" into console and that will retun your current Vector position and Angles Also I know in the FortWars Light gamemode they made som extra spawnpoints as point entities, so then you could either use them if you are making a map (I presume not), or use a GM:Initialize hook to spawn them on map load
Thanks for the help guys, finally got it to work like it should. all post were helpfull to me ^^ Also: [b]Solved[/b], plz close or w/e
Sorry, you need to Log In to post a reply to this thread.