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

Commit

Permalink
Respawn settings: Removed one NWVar
Browse files Browse the repository at this point in the history
- Removed one unneeded NWVar
Should work smoother
  • Loading branch information
MinIsMin committed Jan 23, 2017
1 parent 68ce10c commit f42774b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
6 changes: 3 additions & 3 deletions lua/cl_spectator_deathmatch.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 5 additions & 7 deletions lua/sv_specdm_overrides.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit f42774b

Please sign in to comment.