Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for ace perms #30

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions modules/server/framework/aceperms.lua
Original file line number Diff line number Diff line change
@@ -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) == '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 type(ace) == 'string' and IsPlayerAceAllowed(playerId, ace) then
lib.notify(playerId, {
type = 'success',
description = locale('channel_join', frequency + 0.0),
})
return true
end
end
end

lib.notify(playerId, {
type = 'error',
description = locale('channel_unavailable'),
})

return false
end)
end
end)
2 changes: 1 addition & 1 deletion modules/server/framework/esx.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion modules/server/framework/ox.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion modules/server/framework/qb.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion modules/server/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +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'
end

require 'modules.server.framework.aceperms'
end)