From f42774b56bcd48bab088a4bd0efdd7cc602e918e Mon Sep 17 00:00:00 2001 From: Min Date: Mon, 23 Jan 2017 20:43:46 +0100 Subject: [PATCH] Respawn settings: Removed one NWVar - Removed one unneeded NWVar Should work smoother --- lua/cl_spectator_deathmatch.lua | 6 +++--- lua/sv_specdm_overrides.lua | 12 +++++------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/lua/cl_spectator_deathmatch.lua b/lua/cl_spectator_deathmatch.lua index 093f8a5..4a7b6e7 100644 --- a/lua/cl_spectator_deathmatch.lua +++ b/lua/cl_spectator_deathmatch.lua @@ -6,15 +6,15 @@ include("cl_quakesounds.lua") hook.Add("HUDPaint", "SpecDM_RespawnMessage", function() if !IsValid(LocalPlayer()) or !LocalPlayer():IsGhost() or LocalPlayer():Alive() then return end - if LocalPlayer():GetNWBool("SpecDM_CanSpawnGhost") and LocalPlayer():GetNWFloat("SpecDM_RespawnedIn") then + if LocalPlayer():GetNWFloat("SpecDM_RespawnedIn", -2) ~= -2 then if SpecDM.AutomaticRespawnTime > -1 then draw.DrawText("Press a key to respawn!\nYou will be automaticly respawned in "..math.Round(LocalPlayer():GetNWFloat("SpecDM_RespawnedIn") - CurTime()).." second(s)", "Trebuchet24", ScrW()/2, ScrH()/4, Color(255,255,255,255), TEXT_ALIGN_CENTER) else draw.DrawText("Press a key to respawn!", "Trebuchet24", ScrW()/2, ScrH()/4, Color(255,255,255,255), TEXT_ALIGN_CENTER) end - elseif LocalPlayer():GetNWBool("SpecDM_PreSpawnGhost") and LocalPlayer():GetNWFloat("SpecDM_AbleToRespawnIn") then + elseif LocalPlayer():GetNWFloat("SpecDM_AbleToRespawnIn", -2) ~= -2 then local waittime = math.Round(LocalPlayer():GetNWFloat("SpecDM_AbleToRespawnIn") - CurTime()) - if waittime > 0 then + if waittime > -1 then draw.DrawText("You need to wait "..waittime.." second(s) before you can respawn", "Trebuchet24", ScrW()/2, ScrH()/4, Color(255,255,255,255), TEXT_ALIGN_CENTER) end end diff --git a/lua/sv_specdm_overrides.lua b/lua/sv_specdm_overrides.lua index bbeb0a4..92fc24e 100644 --- a/lua/sv_specdm_overrides.lua +++ b/lua/sv_specdm_overrides.lua @@ -56,8 +56,8 @@ hook.Add("PlayerSpawn", "PlayerSpawn_SpecDM", function(ply) end) local function SpecDM_Respawn(ply) - ply:SetNWBool("SpecDM_PreSpawnGhost", false) - ply:SetNWBool("SpecDM_CanSpawnGhost", false) + ply:SetNWFloat("SpecDM_RespawnedIn", -2) + ply:SetNWFloat("SpecDM_AbleToRespawnIn", -2) if ply:IsGhost() then ply:UnSpectate() ply:Spawn() @@ -68,7 +68,6 @@ end hook.Add("PlayerDeath", "PlayerDeath_SpecDM", function(victim, inflictor, attacker) if victim:IsGhost() then - victim:SetNWBool("SpecDM_PreSpawnGhost", true) if SpecDM.GivePointshopPoints and IsValid(attacker) and attacker:IsPlayer() and attacker:IsGhost() and attacker != victim then attacker:PS_GivePoints(SpecDM.PointshopPoints) end @@ -80,14 +79,13 @@ hook.Add("PlayerDeath", "PlayerDeath_SpecDM", function(victim, inflictor, attack end victim:SetNWFloat("SpecDM_AbleToRespawnIn", CurTime() + SpecDM.RespawnTime) timer.Simple(SpecDM.RespawnTime, function() - if IsValid(victim) and !victim:Alive() and victim:GetNWBool("SpecDM_PreSpawnGhost") and SpecDM.AutomaticRespawnTime ~= 0 then + if IsValid(victim) and !victim:Alive() and SpecDM.AutomaticRespawnTime ~= 0 then victim:SetNWFloat("SpecDM_RespawnedIn", CurTime() + SpecDM.AutomaticRespawnTime) - victim:SetNWBool("SpecDM_CanSpawnGhost", true) end end) if SpecDM.AutomaticRespawnTime > -1 then timer.Simple(SpecDM.AutomaticRespawnTime + SpecDM.RespawnTime, function() - if IsValid(victim) and !victim:Alive() and victim:GetNWBool("SpecDM_PreSpawnGhost") then + if IsValid(victim) and !victim:Alive() then SpecDM_Respawn(victim) end end) @@ -131,7 +129,7 @@ hook.Add("Initialize", "Initialize_SpecDM", function() local old_KeyPress = GAMEMODE.KeyPress function GAMEMODE:KeyPress(ply, key) if IsValid(ply) and ply:IsGhost() then - if !ply:Alive() and ply:GetNWBool("SpecDM_CanSpawnGhost") then + if !ply:Alive() and ply:GetNWFloat("SpecDM_RespawnedIn", -2) ~= -2 then SpecDM_Respawn(ply) end return