if GetResourceState("es_extended") == "started" then ESX = exports["es_extended"]:getSharedObject() end if GetResourceState("qb-core") == "started" then QBCore = exports['qb-core']:GetCoreObject() end function IsIdAllowed(_source, id) -- By Identifier for _, id2 in pairs(GetPlayerIdentifiers(_source)) do if id == id2 then return true end end -- By ACE permission if IsPlayerAceAllowed(_source, id) then return true end -- By job with ESX if GetResourceState("es_extended") == "started" then while ESX.GetPlayerFromId(_source) == nil or ESX.GetPlayerFromId(_source).job == nil do Citizen.Wait(100) end local Player = ESX.GetPlayerFromId(_source) if id == Player.job.name then return true end if id == Player.job.name ..":".. Player.job.grade then return true end end -- By job with QB Core if GetResourceState("qb-core") == "started" then local Player = QBCore.Functions.GetPlayer(_source) if id == Player.PlayerData.job.name then return true end if id == Player.PlayerData.job.name ..":".. Player.PlayerData.job.grade.level then return true end end -- By a custom method -- ....... -- return true / false return false end -- Check which element the player is allowed to use RegisterNetEvent(GetCurrentResourceName()..':CheckAccess', function() local _source = source local default_value = false if Config.WhiteList and Config.WhiteListEnabled then for _, id in pairs(Config.WhiteList) do default_value = IsIdAllowed(_source, id) if default_value then break end end end local Access = {} for type, _ in pairs(Config.Models) do Access[type] = {} for model, _ in pairs(Config.Models[type]) do if Config.WhiteListEnabled then if Config.Models[type][model].WhiteList == nil then Access[type][model] = default_value else Access[type][model] = false for _, id in pairs(Config.Models[type][model].WhiteList) do Access[type][model] = IsIdAllowed(_source, id) if Access[type][model] then break end end end else Access[type][model] = true end end end local type = "siren" Access[type] = {} for k,_ in pairs(Config.SirenTones) do if Config.WhiteListEnabled then -- Default whitelist is the one defined at the top if Config.SirenTones[k].WhiteList == nil then Access[type][k] = default_value else Access[type][k] = false for _, id in pairs(Config.SirenTones[k].WhiteList) do Access[type][k] = IsIdAllowed(_source, id) if Access[type][k] then break end end end else Access[type][k] = true end end -- Respond to the client TriggerClientEvent(GetCurrentResourceName()..':CheckAccess', _source, Access) end)