Skip to content

Commit

Permalink
refactor: ace permissions (#389)
Browse files Browse the repository at this point in the history
* refactor: ace permissions

* refactor(permissions): simplify aces to check

* Update permissions.lua
  • Loading branch information
Manason authored Feb 4, 2024
1 parent eb56f9e commit e3bd119
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 42 deletions.
41 changes: 4 additions & 37 deletions server/permissions.lua
Original file line number Diff line number Diff line change
@@ -1,44 +1,11 @@
local resetTimer = GetGameTimer()
local allAces = {}

lib.callback.register("illenium-appearance:server:GetPlayerAces", function()
local src = source
local allowedAces = {}
for k in pairs(allAces) do
if IsPlayerAceAllowed(src, k) then
allowedAces[#allowedAces + 1] = k
for i = 1, #Config.Aces do
local ace = Config.Aces[i]
if IsPlayerAceAllowed(src, ace) then
allowedAces[#allowedAces+1] = ace
end
end
return allowedAces
end)

local function findAceFromSecurityMessage(message)
local words = {}
for word in message:gmatch("%S+") do words[#words + 1] = word end
return words[3]
end

RegisterConsoleListener(function(channel, message)
if channel ~= "security" then
return
end

local ace = findAceFromSecurityMessage(message)
if ace and ((GetGameTimer() - resetTimer) > Config.ACEResetCooldown) then
allAces = {}
end

if ace then
allAces[ace] = true
resetTimer = GetGameTimer()
end
end)

if Config.EnableACEPermissions then
CreateThread(function()
while true do
ExecuteCommand("list_aces")
Wait(Config.ACEListCooldown)
end
end)
end
8 changes: 3 additions & 5 deletions shared/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,6 @@ Config.ReloadSkinCooldown = 5000

Config.AutomaticFade = false -- Enables automatic fading and hides the Fade section from Hair

-- ACE Permissions Config
Config.EnableACEPermissions = false
Config.ACEResetCooldown = 5000
Config.ACEListCooldown = 60 * 60 * 1000 -- 1 Hour

Config.DisableComponents = {
Masks = false,
UpperBody = false,
Expand All @@ -99,6 +94,9 @@ Config.DisableProps = {
Bracelets = false
}

---@type string[]
Config.Aces = {} -- list of ace permissions used for blacklisting

Config.Blips = {
["clothing"] = {
Show = true,
Expand Down

0 comments on commit e3bd119

Please sign in to comment.