Add visual indicator (#38)

* Add visual indicator

* Improve logic
This commit is contained in:
Redox 2023-08-21 00:15:45 +01:00 committed by GitHub
parent 216f95a4f2
commit 1db5ab5c23
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 3 deletions

View File

@ -0,0 +1,21 @@
local textColor = Color( 0, 100, 255 )
local outlineColor = color_black
local TEXT_ALIGN_CENTER = TEXT_ALIGN_CENTER
local scrw = ScrW()
local scrh = ScrH()
surface.CreateFont( "SpawnProtection", {
font = "Roboto",
size = ScreenScale( 15 ),
weight = 600,
} )
local function drawNotice()
local active = LocalPlayer():GetNWBool( "HasSpawnProtection", false )
if not active then return end
draw.SimpleTextOutlined( "Spawn protection enabled", "SpawnProtection", scrw * 0.5, scrh * 0.9, textColor, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER, 1, outlineColor )
end
hook.Add( "HUDPaint", "DrawSpawnProtection", drawNotice )

View File

@ -74,7 +74,7 @@ end
-- Set Spawn Protection
local function setSpawnProtection( ply )
ply.hasSpawnProtection = true
ply:SetNWBool( "HasSpawnProtection", true )
end
-- Remove Decay Timer
@ -100,7 +100,7 @@ local function removeSpawnProtection( ply, printMessage )
if not isValidPlayer( ply ) then return end
ply:ChatPrint( printMessage )
ply.hasSpawnProtection = false
ply:SetNWBool( "HasSpawnProtection", false )
end
-- Creates a decay timer which will expire after spawnProtectionDecayTime
@ -149,7 +149,7 @@ local function playerIsInPvp( ply )
end
local function playerHasSpawnProtection( ply )
return ply.hasSpawnProtection
return ply:GetNWBool( "HasSpawnProtection", false )
end
local function playerIsDisablingSpawnProtection( ply )