feat!: ace permission system

This commit is contained in:
BerkieBb
2022-02-24 21:58:49 +01:00
parent 1412d02db1
commit 31888996ab
13 changed files with 195 additions and 72 deletions
+3 -7
View File
@@ -19,11 +19,9 @@ AddEventHandler('chatMessage', function(source, _, message)
if not QBCore.Commands.List[command] then return end
local Player = QBCore.Functions.GetPlayer(src)
if not Player then return end
local isGod = QBCore.Functions.HasPermission(src, 'god')
local hasPerm = QBCore.Functions.HasPermission(src, QBCore.Commands.List[command].permission)
local isPrincipal = IsPlayerAceAllowed(src, 'command')
table.remove(args, 1)
if isGod or hasPerm or isPrincipal then
if hasPerm then
if QBCore.Commands.List[command].argsrequired and #QBCore.Commands.List[command].arguments ~= 0 and not args[#QBCore.Commands.List[command].arguments] then
TriggerClientEvent('QBCore:Notify', src, Lang:t('error.missing_args2'), 'error')
else
@@ -190,10 +188,8 @@ RegisterNetEvent('QBCore:CallCommand', function(command, args)
if not QBCore.Commands.List[command] then return end
local Player = QBCore.Functions.GetPlayer(src)
if not Player then return end
local isGod = QBCore.Functions.HasPermission(src, 'god')
local hasPerm = QBCore.Functions.HasPermission(src, QBCore.Commands.List[command].permission)
local isPrincipal = IsPlayerAceAllowed(src, 'command')
if (QBCore.Commands.List[command].permission == Player.PlayerData.job.name) or isGod or hasPerm or isPrincipal then
if (QBCore.Commands.List[command].permission == Player.PlayerData.job.name) or hasPerm then
if QBCore.Commands.List[command].argsrequired and #QBCore.Commands.List[command].arguments ~= 0 and not args[#QBCore.Commands.List[command].arguments] then
TriggerClientEvent('QBCore:Notify', src, Lang:t('error.missing_args2'), 'error')
else
@@ -258,4 +254,4 @@ QBCore.Functions.CreateCallback('QBCore:HasItem', function(source, cb, items, am
end
end
cb(retval)
end)
end)