From 46a2aae5ce673f90ab022b94265f5e03cd607502 Mon Sep 17 00:00:00 2001 From: Kakarot Date: Wed, 30 Mar 2022 00:45:31 -0500 Subject: [PATCH] More changes --- config.lua | 2 +- server/commands.lua | 8 +++++++- server/functions.lua | 14 ++++---------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/config.lua b/config.lua index 43de9d5..9681f22 100644 --- a/config.lua +++ b/config.lua @@ -30,7 +30,7 @@ QBConfig.Server.WhitelistPermission = 'admin' -- Permission that's able to enter QBConfig.Server.PVP = true -- Enable or disable pvp on the server (Ability to shoot other players) QBConfig.Server.Discord = "" -- Discord invite link QBConfig.Server.CheckDuplicateLicense = true -- Check for duplicate rockstar license on join -QBConfig.Server.Permissions = {'god', 'admin', 'mod'} -- Add as many groups as you want here after creating them in your server.cfg +QBConfig.Server.Permissions = {'admin', 'mod'} -- Add as many groups as you want here after creating them in your server.cfg QBConfig.Notify = {} diff --git a/server/commands.lua b/server/commands.lua index 254468f..144eb2b 100644 --- a/server/commands.lua +++ b/server/commands.lua @@ -3,9 +3,15 @@ QBCore.Commands.List = {} QBCore.Commands.IgnoreList = { -- Ignore old perm levels while keeping backwards compatibility ['god'] = true, -- We don't need to create an ace because group.admin allows all commands ['admin'] = true, -- We don't need to create an ace because group.admin allows all commands - ['user'] = true, -- We don't need to create an ace because builtin.everyone + ['user'] = true -- We don't need to create an ace because builtin.everyone } +CreateThread(function() -- Add rank name to ace + for k,v in pairs(QBConfig.Server.Permissions) do + ExecuteCommand(('add_ace group.%s %s allow'):format(v, v)) + end +end) + -- Register & Refresh Commands function QBCore.Commands.Add(name, help, arguments, argsrequired, callback, permission) diff --git a/server/functions.lua b/server/functions.lua index cf21e7c..7971c37 100644 --- a/server/functions.lua +++ b/server/functions.lua @@ -266,12 +266,8 @@ end function QBCore.Functions.AddPermission(source, permission) local src = source local license = QBCore.Functions.GetIdentifier(src, 'license') - for k,v in pairs(QBCore.Config.Server.Permissions) do - if permission == v then - ExecuteCommand(('add_principal identifier.%s group.%s'):format(license, permission)) - QBCore.Commands.Refresh(src) - end - end + ExecuteCommand(('add_principal identifier.%s group.%s'):format(license, permission)) + QBCore.Commands.Refresh(src) end function QBCore.Functions.RemovePermission(source, permission) @@ -296,8 +292,7 @@ end function QBCore.Functions.HasPermission(source, permission) local src = source - local group = ('group.%s'):format(permission) - if IsPlayerAceAllowed(tostring(src), group) then return true end + if IsPlayerAceAllowed(src, permission) then return true end return false end @@ -305,8 +300,7 @@ function QBCore.Functions.GetPermissions(source) local src = source local perms = {} for k,v in pairs (QBCore.Config.Server.Permissions) do - local group = ('group.%s'):format(v) - if IsPlayerAceAllowed(src, group) then + if IsPlayerAceAllowed(src, v) then perms[v] = true end end