From 211813bc4f9632aa6134fb4546d03ad3bbb0938f Mon Sep 17 00:00:00 2001 From: thegrb93 Date: Tue, 17 Sep 2024 18:10:51 -0400 Subject: [PATCH] Optimization --- lua/starfall/sflib.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lua/starfall/sflib.lua b/lua/starfall/sflib.lua index cb140956b..351b13f0d 100644 --- a/lua/starfall/sflib.lua +++ b/lua/starfall/sflib.lua @@ -1450,7 +1450,7 @@ function SF.CheckModel(model, player, prop) return model end -SF.UniqueSounds = setmetatable({}, {__index=function(t,k) local r={} t[k]=r return r end}) +SF.UniqueSounds = setmetatable({}, {__index=function(t,k) local r={[1]=0} t[k]=r return r end}) local maxUniqueSounds = CreateConVar("sf_sounds_unique_max"..(CLIENT and "_cl" or ""), "200", FCVAR_ARCHIVE, "The maximum number of unique sounds paths allowed") function SF.CheckSound(ply, path) @@ -1466,10 +1466,11 @@ function SF.CheckSound(ply, path) local UserUniqueSounds = SF.UniqueSounds[ply:SteamID()] if not UserUniqueSounds[checkpath] then - if table.Count(UserUniqueSounds) >= maxUniqueSounds:GetInt() then + if UserUniqueSounds[1] >= maxUniqueSounds:GetInt() then SF.Throw("The unique sounds limit has been reached.", 3) end UserUniqueSounds[checkpath] = true + UserUniqueSounds[1] = UserUniqueSounds[1] + 1 end return path