Lightbar überarbeitet

Überarbeitung der Lightbars
This commit is contained in:
Max 2025-06-10 18:24:27 +02:00
parent ba79461ce9
commit 2c78a1349f
99 changed files with 0 additions and 0 deletions

View file

@ -0,0 +1,62 @@
-- ESX
if GetResourceState("es_extended") == "started" then
Citizen.CreateThread(function()
ESX = exports["es_extended"]:getSharedObject()
while ESX.GetPlayerData().job == nil do
Citizen.Wait(100)
end
TriggerServerEvent(GetCurrentResourceName()..":CheckAccess")
end)
RegisterNetEvent('esx:setJob', function(_)
TriggerServerEvent(GetCurrentResourceName()..":CheckAccess")
end)
RegisterNetEvent('esx:setJob2', function(_)
TriggerServerEvent(GetCurrentResourceName()..":CheckAccess")
end)
-- QBCore
elseif GetResourceState("qb-core") == "started" then
Citizen.CreateThread(function()
QBCore = exports['qb-core']:GetCoreObject()
while QBCore.Functions.GetPlayerData().job == nil do
Citizen.Wait(100)
end
TriggerServerEvent(GetCurrentResourceName()..":CheckAccess")
end)
RegisterNetEvent('QBCore:Client:OnPlayerUnload', function()
TriggerServerEvent(GetCurrentResourceName()..":CheckAccess")
end)
RegisterNetEvent('QBCore:Client:OnJobUpdate', function(_)
TriggerServerEvent(GetCurrentResourceName()..":CheckAccess")
end)
-- Standalone / Other
else
Citizen.CreateThread(function()
TriggerServerEvent(GetCurrentResourceName()..":CheckAccess")
end)
end
hasAccess = false
RegisterNetEvent(GetCurrentResourceName()..":CheckAccess", function(access_table)
hasAccess = false
for type, _ in pairs(Config.Models) do
for model, v in pairs(access_table[type]) do
Config.Models[type][model].HasAccess = v
if v then
hasAccess = true
end
end
end
for model, v in pairs(access_table["siren"]) do
Config.SirenTones[model].HasAccess = v
if v then
hasAccess = true
end
end
end)

View file

@ -0,0 +1,13 @@
-- exports.EVC:DisableBind(true / false)
-- ESX
Citizen.CreateThread(function()
while ESX == nil do
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
Citizen.Wait(1000)
end
while true do
Citizen.Wait(500)
exports.EVC:DisableBind(#(ESX.UI.Menu.GetOpenedMenus()) > 0)
end
end)

View file

@ -0,0 +1,114 @@
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)