Skip to content
This repository was archived by the owner on Mar 11, 2021. It is now read-only.

Commit f42774b

Browse files
committed
Respawn settings: Removed one NWVar
- Removed one unneeded NWVar Should work smoother
1 parent 68ce10c commit f42774b

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

lua/cl_spectator_deathmatch.lua

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ include("cl_quakesounds.lua")
66

77
hook.Add("HUDPaint", "SpecDM_RespawnMessage", function()
88
if !IsValid(LocalPlayer()) or !LocalPlayer():IsGhost() or LocalPlayer():Alive() then return end
9-
if LocalPlayer():GetNWBool("SpecDM_CanSpawnGhost") and LocalPlayer():GetNWFloat("SpecDM_RespawnedIn") then
9+
if LocalPlayer():GetNWFloat("SpecDM_RespawnedIn", -2) ~= -2 then
1010
if SpecDM.AutomaticRespawnTime > -1 then
1111
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)
1212
else
1313
draw.DrawText("Press a key to respawn!", "Trebuchet24", ScrW()/2, ScrH()/4, Color(255,255,255,255), TEXT_ALIGN_CENTER)
1414
end
15-
elseif LocalPlayer():GetNWBool("SpecDM_PreSpawnGhost") and LocalPlayer():GetNWFloat("SpecDM_AbleToRespawnIn") then
15+
elseif LocalPlayer():GetNWFloat("SpecDM_AbleToRespawnIn", -2) ~= -2 then
1616
local waittime = math.Round(LocalPlayer():GetNWFloat("SpecDM_AbleToRespawnIn") - CurTime())
17-
if waittime > 0 then
17+
if waittime > -1 then
1818
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)
1919
end
2020
end

lua/sv_specdm_overrides.lua

+5-7
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ hook.Add("PlayerSpawn", "PlayerSpawn_SpecDM", function(ply)
5656
end)
5757

5858
local function SpecDM_Respawn(ply)
59-
ply:SetNWBool("SpecDM_PreSpawnGhost", false)
60-
ply:SetNWBool("SpecDM_CanSpawnGhost", false)
59+
ply:SetNWFloat("SpecDM_RespawnedIn", -2)
60+
ply:SetNWFloat("SpecDM_AbleToRespawnIn", -2)
6161
if ply:IsGhost() then
6262
ply:UnSpectate()
6363
ply:Spawn()
@@ -68,7 +68,6 @@ end
6868

6969
hook.Add("PlayerDeath", "PlayerDeath_SpecDM", function(victim, inflictor, attacker)
7070
if victim:IsGhost() then
71-
victim:SetNWBool("SpecDM_PreSpawnGhost", true)
7271
if SpecDM.GivePointshopPoints and IsValid(attacker) and attacker:IsPlayer() and attacker:IsGhost() and attacker != victim then
7372
attacker:PS_GivePoints(SpecDM.PointshopPoints)
7473
end
@@ -80,14 +79,13 @@ hook.Add("PlayerDeath", "PlayerDeath_SpecDM", function(victim, inflictor, attack
8079
end
8180
victim:SetNWFloat("SpecDM_AbleToRespawnIn", CurTime() + SpecDM.RespawnTime)
8281
timer.Simple(SpecDM.RespawnTime, function()
83-
if IsValid(victim) and !victim:Alive() and victim:GetNWBool("SpecDM_PreSpawnGhost") and SpecDM.AutomaticRespawnTime ~= 0 then
82+
if IsValid(victim) and !victim:Alive() and SpecDM.AutomaticRespawnTime ~= 0 then
8483
victim:SetNWFloat("SpecDM_RespawnedIn", CurTime() + SpecDM.AutomaticRespawnTime)
85-
victim:SetNWBool("SpecDM_CanSpawnGhost", true)
8684
end
8785
end)
8886
if SpecDM.AutomaticRespawnTime > -1 then
8987
timer.Simple(SpecDM.AutomaticRespawnTime + SpecDM.RespawnTime, function()
90-
if IsValid(victim) and !victim:Alive() and victim:GetNWBool("SpecDM_PreSpawnGhost") then
88+
if IsValid(victim) and !victim:Alive() then
9189
SpecDM_Respawn(victim)
9290
end
9391
end)
@@ -131,7 +129,7 @@ hook.Add("Initialize", "Initialize_SpecDM", function()
131129
local old_KeyPress = GAMEMODE.KeyPress
132130
function GAMEMODE:KeyPress(ply, key)
133131
if IsValid(ply) and ply:IsGhost() then
134-
if !ply:Alive() and ply:GetNWBool("SpecDM_CanSpawnGhost") then
132+
if !ply:Alive() and ply:GetNWFloat("SpecDM_RespawnedIn", -2) ~= -2 then
135133
SpecDM_Respawn(ply)
136134
end
137135
return

0 commit comments

Comments
 (0)