PlayerSpawn Angles

Hello everyone,

I currently have custom team spawn point for the gamemode I am currently working on. However, I’m having a issue with setting the angle which the player is spawned in. I know this is possible, but not currently sure how.

This is what the code currently looks like:



teams[0] = {
	name = "Civilian",
	model = "models/Characters/Hostage_02.mdl",
	color = Vector( .2, .2, 1.0 ),
	pos = {
		Vector( -10899, -11862, 72 ),
		Vector( -10748, -11723, 72 ),
		Vector( -10673, -11804, 72 ),
		Vector( -10867, -11616, 72 ),
		Vector( -10869, -11391, 72 )
	},
	ang = Angle( 0.000, 43.860, 0.000 ),
	weapons = {
		"weapon_crowbar"
	}
}

function ply:SetTeamSpawnPoint()
	local n = self:Team()
	self:SetPos( table.Random( teams[n].pos ) )
	self:SetAngles( teams[n].ang )
end
hook.Add( "PlayerSpawn", "TeamSpawnPoint", SetTeamSpawnPoint )



Any ideas?

Bump,

Still looking for a little help on this topic.

http://puu.sh/2i05g

Wha?

You are creating your hook function on ply - and then passing a variable with a nil value to the hook.Add function

If I understand what Garry is explaining:

local PLAYER = FindMetaTable( “Player” )


function **PLAYER:**SetTeamSpawnPoint()
    local n = self:Team()
    self:SetPos( table.Random( teams[n].pos ) )
    self:SetAngles( teams[n].ang )
end
hook.Add( "PlayerSpawn", "TeamSpawnPoint", SetTeamSpawnPoint )

[lua]
function SetTeamSpawnPoint(ply)
local n = ply:Team()
ply:SetPos( table.Random( teams[n].pos ) )
ply:SetAngles( teams[n].ang )
end
hook.Add( “PlayerSpawn”, “TeamSpawnPoint”, SetTeamSpawnPoint )[/lua]

This is how it should look like to work properly.

I have the line “local ply = FindMetaTable( “Player” )” in the file, I just forgot to include it in my OP.

[editline]15th March 2013[/editline]

I’ll give it a shot. I’ll post my results.

Edit:
These did not work.

Drop the hook and use
[lua]
function GM:PlayerSpawn(ply)
ply:SetPos(Vector(100,100,100))
end
[/lua]

The Pos works, I’m trying to get the Angle to work.

I misread.
You should still go with that.

The Spawn points work without issue. I just can’t get them to spawn pointing the way I want them to.



function GM:PlayerSpawn(ply)
    ply:SetPos(Vector(100,100,100))
    ply:SetEyeAngles(Angle(0,0,0))
end


hopespawn1 = ents.Create( “info_player_start” )
hopespawn1:SetPos( Vector(3457,462,12109) )
hopespawn1:SetName(“hopespawn1”)
hopespawn1:SetKeyValue( “angles”, “0 0 0”)
hopespawn1:Spawn()

:v

You are the best. Worked like a charm!