From cb2c889e6ee2107aa8e9d1e53208c0f72a1b0371 Mon Sep 17 00:00:00 2001 From: AlmTech Date: Sat, 7 Sep 2019 19:32:01 +0200 Subject: [PATCH] Added respawning stuff --- gamemode/core/server/sv_player_spawning.lua | 35 +++++++++++++++++++++ gamemode/settings/sv_settings.lua | 11 ++++++- 2 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 gamemode/core/server/sv_player_spawning.lua diff --git a/gamemode/core/server/sv_player_spawning.lua b/gamemode/core/server/sv_player_spawning.lua new file mode 100644 index 0000000..b7d7c01 --- /dev/null +++ b/gamemode/core/server/sv_player_spawning.lua @@ -0,0 +1,35 @@ +-- __ _ _______ _ __ +-- / / /\ | | |__ __| | | \ \ +-- / / / \ | |_ __ ___ | | ___ ___| |__ \ \ +-- < < / /\ \ | | '_ ` _ \| |/ _ \/ __| '_ \ > > +-- \ \ / ____ \| | | | | | | | __/ (__| | | | / / +-- \_\ /_/ \_\_|_| |_| |_|_|\___|\___|_| |_| /_/ + +hook.Add( "PlayerSpawn", "Quantum_Player_Respawn", function( pl ) + if( pl.isloaded && pl.deathpos ) then + local spawnposdist = {} + for id, pos in pairs( Quantum.Server.Settings.SpawnLocations[ game.GetMap() ] ) do + print( id, pos ) + spawnposdist[id] = { dist = pos:Distance( pl.deathpos ), spawnpos = pos } + end + + + local maxdist + local spawnpos + for i, spawnpos in ipairs( spawnposdist ) do -- Loop through everything and pick the nearest spawnpoint + if( maxdist ~= nil ) then + if( maxdist <= spawnpos.dist ) then + maxdist = spawnpos.dist + spawnpos = spawnpos.pos + end + else + maxdist = spawnpos.dist + spawnpos = spawnpos.pos + end + end + + Quantum.Debug( "Respawning player at nearest spawnpoint... ( " .. tostring( spawnpos ) .. " )" ) + pl:SetPos( spawnpos ) + + end +end) \ No newline at end of file diff --git a/gamemode/settings/sv_settings.lua b/gamemode/settings/sv_settings.lua index 5a1d0c8..8a2b1b6 100644 --- a/gamemode/settings/sv_settings.lua +++ b/gamemode/settings/sv_settings.lua @@ -9,7 +9,16 @@ Quantum.Server.Settings.VoiceChatRange = 400 -Quantum.Server.Settings.DamageScale = { -- The scale of the damage for each hitgroup +Quantum.Server.Settings.SpawnLocations = { + + ["rp_truenorth_v1a_livin"] = { + ["Hospital"] = { pos = Vector( 13583, 13189, 128 ), ang = Angle( 1, 115, 0 ) }, + ["Lake"] = { pos = Vector( 10812, -8319, 5388 ), ang = Angle( 5, -40, 0 ) } + } + +} + +Quantum.Server.Settings.DamageScale = { -- The scale of the damage for each hitgroup [HITGROUP_HEAD] = 10, [HITGROUP_CHEST] = 4, [HITGROUP_STOMACH] = 2,