|
|
@ -9,8 +9,7 @@ hook.Add( "PlayerDeath", "Quantum_Player_SaveDeathPos", function( pl ) |
|
|
|
pl.deathpos = pl:GetPos() |
|
|
|
pl.deathpos = pl:GetPos() |
|
|
|
end) |
|
|
|
end) |
|
|
|
|
|
|
|
|
|
|
|
hook.Add( "PlayerSpawn", "Quantum_Player_Respawn", function( pl ) |
|
|
|
local function getNearestSpawn( pl ) |
|
|
|
if( pl.isloaded && pl.deathpos ) then |
|
|
|
|
|
|
|
local spawnposdist = {} |
|
|
|
local spawnposdist = {} |
|
|
|
for id, spawnpoint in pairs( Quantum.Server.Settings.SpawnLocations[ game.GetMap() ] ) do |
|
|
|
for id, spawnpoint in pairs( Quantum.Server.Settings.SpawnLocations[ game.GetMap() ] ) do |
|
|
|
spawnposdist[id] = { dist = spawnpoint.pos:Distance( pl.deathpos ), spawnpos = spawnpoint.pos, angle = spawnpoint.ang } |
|
|
|
spawnposdist[id] = { dist = spawnpoint.pos:Distance( pl.deathpos ), spawnpos = spawnpoint.pos, angle = spawnpoint.ang } |
|
|
@ -30,6 +29,13 @@ hook.Add( "PlayerSpawn", "Quantum_Player_Respawn", function( pl ) |
|
|
|
spawnangle = spawn.angle |
|
|
|
spawnangle = spawn.angle |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
return spawnpos, spawnangle |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
hook.Add( "PlayerSpawn", "Quantum_Player_Respawn", function( pl ) |
|
|
|
|
|
|
|
if( pl.isloaded && pl.deathpos ) then |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local spawnpos, spawnangle = getNearestSpawn( pl ) |
|
|
|
|
|
|
|
|
|
|
|
Quantum.Debug( "Respawning player at nearest spawnpoint." ) |
|
|
|
Quantum.Debug( "Respawning player at nearest spawnpoint." ) |
|
|
|
pl:SetPos( spawnpos ) |
|
|
|
pl:SetPos( spawnpos ) |
|
|
|