1
0
mirror of https://github.com/CFC-Servers/cfc_chip_lister.git synced 2025-03-04 03:03:14 -05:00

Add a small ratelimit to screen toggle

This commit is contained in:
legokidlogan 2022-08-29 08:34:10 -06:00
parent ae072574c8
commit bfc9524a59

View File

@ -4,6 +4,7 @@ local TOGGLE_DIST = 1500
local MAX_ELEMENTS = 30
local SCREEN_SIZE = 1024
local SCREEN_SIZE_HALF = SCREEN_SIZE / 2
local USE_COOLDOWN = 0.5
local FONT_NAME = "CFC_ChipLister_Font"
local FONT_SIZE = 30
@ -31,6 +32,7 @@ local ID_WORLD = "[WORLD]"
local CPUS_FORMAT = "%05d"
local useIsOnCooldown = false
local rtChipLister = GetRenderTarget( "cfc_chiplister_rt", SCREEN_SIZE, SCREEN_SIZE )
local INFO_OFFSET_OWNER = 0
local INFO_OFFSET_CHIP = 0
@ -315,6 +317,7 @@ end )
hook.Add( "KeyPress", "CFC_ChipLister_ToggleScreen", function( ply, key ) -- ply is always LocalPlayer() on client
if key ~= IN_USE then return end
if useIsOnCooldown then return end
local tr = ply:GetEyeTrace()
local ent = tr.Entity
@ -323,6 +326,12 @@ hook.Add( "KeyPress", "CFC_ChipLister_ToggleScreen", function( ply, key ) -- ply
if tr.StartPos:DistToSqr( tr.HitPos ) > TOGGLE_DIST_SQR then return end
ply:ConCommand( "cfc_chiplister_enabled " .. ( listerEnabled and "0" or "1" ) )
useIsOnCooldown = true
timer.simple( USE_COOLDOWN, function()
useIsOnCooldown = false
end )
end )