From 5153776b1c32f73c931a04dc9a0a0607aedf4ecf Mon Sep 17 00:00:00 2001 From: FearlessNite345 <110247392+FearlessNite345@users.noreply.github.com> Date: Sat, 6 Jul 2024 14:39:08 -0400 Subject: [PATCH 1/3] Added support for ace perms --- modules/server/framework/aceperms.lua | 35 +++++++++++++++++++++++++++ modules/server/main.lua | 2 ++ 2 files changed, 37 insertions(+) create mode 100644 modules/server/framework/aceperms.lua diff --git a/modules/server/framework/aceperms.lua b/modules/server/framework/aceperms.lua new file mode 100644 index 0000000..0805009 --- /dev/null +++ b/modules/server/framework/aceperms.lua @@ -0,0 +1,35 @@ +local Voice = exports['pma-voice'] +local Config = require 'config' + +Citizen.CreateThread(function() + for frequency, allowed in pairs(Config.restrictedChannels) do + Voice:addChannelCheck(tonumber(frequency), function(playerId) + if type(allowed) == 'table' then + for _, ace in pairs(allowed) do + if IsPlayerAceAllowed(playerId, ace) then + lib.notify(playerId, { + type = 'success', + description = locale('channel_join', frequency + 0.0), + }) + return true + end + end + else + if IsPlayerAceAllowed(playerId, allowed) then + lib.notify(playerId, { + type = 'success', + description = locale('channel_join', frequency + 0.0), + }) + return true + end + end + + lib.notify(playerId, { + type = 'error', + description = locale('channel_unavailable'), + }) + + return false + end) + end +end) diff --git a/modules/server/main.lua b/modules/server/main.lua index 8cc138e..d355692 100644 --- a/modules/server/main.lua +++ b/modules/server/main.lua @@ -18,5 +18,7 @@ SetTimeout(0, function() require 'modules.server.framework.esx' elseif Utils.hasExport('qb-core.GetCoreObject') then require 'modules.server.framework.qb' + else + require 'modules.server.framework.aceperms' end end) From 89a4b226377e270dff0f03f9aba5b867b3f68055 Mon Sep 17 00:00:00 2001 From: FearlessNite345 <110247392+FearlessNite345@users.noreply.github.com> Date: Thu, 29 Aug 2024 19:59:23 -0400 Subject: [PATCH 2/3] Ensure aceperms are always checked, regardless of framework status --- modules/server/framework/esx.lua | 2 +- modules/server/framework/ox.lua | 2 +- modules/server/framework/qb.lua | 2 +- modules/server/main.lua | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/server/framework/esx.lua b/modules/server/framework/esx.lua index e5702c3..f87775e 100644 --- a/modules/server/framework/esx.lua +++ b/modules/server/framework/esx.lua @@ -12,7 +12,7 @@ AddEventHandler('esx:playerLogout', function(playerId) Player(playerId).state:set('ac:hasRadioProp', false, true) end) -CreateThread(function() +Citizen.CreateThread(function() if Config.useUsableItem and not Utils.hasExport('ox_inventory.Items') then ESX.RegisterUsableItem('radio', function(playerId) TriggerClientEvent('ac_radio:openRadio', playerId) diff --git a/modules/server/framework/ox.lua b/modules/server/framework/ox.lua index d5fff9e..f48a4f0 100644 --- a/modules/server/framework/ox.lua +++ b/modules/server/framework/ox.lua @@ -13,7 +13,7 @@ AddEventHandler('ox:playerLogout', function(playerId) Player(playerId).state:set('ac:hasRadioProp', false, true) end) -CreateThread(function() +Citizen.CreateThread(function() for frequency, allowed in pairs(Config.restrictedChannels) do Voice:addChannelCheck(tonumber(frequency), function(playerId) local player = Ox.GetPlayer(playerId) diff --git a/modules/server/framework/qb.lua b/modules/server/framework/qb.lua index 348441b..062b97f 100644 --- a/modules/server/framework/qb.lua +++ b/modules/server/framework/qb.lua @@ -12,7 +12,7 @@ AddEventHandler('QBCore:Server:OnPlayerUnload', function(playerId) Player(playerId).state:set('ac:hasRadioProp', false, true) end) -CreateThread(function() +Citizen.CreateThread(function() if Config.useUsableItem and not Utils.hasExport('ox_inventory.Items') then QB.Functions.CreateUseableItem('radio', function(playerId) TriggerClientEvent('ac_radio:openRadio', playerId) diff --git a/modules/server/main.lua b/modules/server/main.lua index d355692..037746d 100644 --- a/modules/server/main.lua +++ b/modules/server/main.lua @@ -11,14 +11,14 @@ SetConvarReplicated('voice_enableSubmix', Config.radioEffect and '1' or '0') SetConvarReplicated('voice_enableRadioAnim', Config.radioAnimation and '1' or '0') SetConvarReplicated('voice_defaultRadio', Config.radioTalkKey) -SetTimeout(0, function() +Citizen.SetTimeout(0, function() if Utils.hasExport('ox_core.GetPlayer') then require 'modules.server.framework.ox' elseif Utils.hasExport('es_extended.getSharedObject') then require 'modules.server.framework.esx' elseif Utils.hasExport('qb-core.GetCoreObject') then require 'modules.server.framework.qb' - else - require 'modules.server.framework.aceperms' end + + require 'modules.server.framework.aceperms' end) From 8dea3320f666d4c96b24a7201999f2041723993b Mon Sep 17 00:00:00 2001 From: FearlessNite345 <110247392+FearlessNite345@users.noreply.github.com> Date: Thu, 29 Aug 2024 20:07:15 -0400 Subject: [PATCH 3/3] Fix ace perms compatibility with restricted GRADE type channels --- modules/server/framework/aceperms.lua | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/modules/server/framework/aceperms.lua b/modules/server/framework/aceperms.lua index 0805009..77007bd 100644 --- a/modules/server/framework/aceperms.lua +++ b/modules/server/framework/aceperms.lua @@ -4,9 +4,17 @@ local Config = require 'config' Citizen.CreateThread(function() for frequency, allowed in pairs(Config.restrictedChannels) do Voice:addChannelCheck(tonumber(frequency), function(playerId) - if type(allowed) == 'table' then + if type(allowed) == 'string' then + if IsPlayerAceAllowed(playerId, allowed) then + lib.notify(playerId, { + type = 'success', + description = locale('channel_join', frequency + 0.0), + }) + return true + end + elseif type(allowed) == 'table' then for _, ace in pairs(allowed) do - if IsPlayerAceAllowed(playerId, ace) then + if type(ace) == 'string' and IsPlayerAceAllowed(playerId, ace) then lib.notify(playerId, { type = 'success', description = locale('channel_join', frequency + 0.0), @@ -14,14 +22,6 @@ Citizen.CreateThread(function() return true end end - else - if IsPlayerAceAllowed(playerId, allowed) then - lib.notify(playerId, { - type = 'success', - description = locale('channel_join', frequency + 0.0), - }) - return true - end end lib.notify(playerId, {