This commit is contained in:
Nordi98 2025-07-20 03:18:58 +02:00
parent 71e31bf060
commit 2fa4d9bdca
3 changed files with 920 additions and 33 deletions

View file

@ -59,8 +59,14 @@ lib.callback.register('container_heist:server:getPoliceCount', function()
for _, playerId in ipairs(players) do
local Player = QBCore.Functions.GetPlayer(playerId)
if Player and Player.PlayerData.job.name == Config.PoliceJobName and Player.PlayerData.job.onduty then
policeCount = policeCount + 1
if Player then
-- Check if player's job is in the list of police jobs
for _, jobName in ipairs(Config.PoliceJobs) do
if Player.PlayerData.job.name == jobName and Player.PlayerData.job.onduty then
policeCount = policeCount + 1
break -- No need to check other job names for this player
end
end
end
end
@ -74,8 +80,14 @@ RegisterNetEvent('container_heist:server:alertPolice', function(coords, streetNa
for _, playerId in ipairs(players) do
local Player = QBCore.Functions.GetPlayer(playerId)
if Player and Player.PlayerData.job.name == Config.PoliceJobName and Player.PlayerData.job.onduty then
TriggerClientEvent('container_heist:client:policeAlert', playerId, coords, streetName, containerType)
if Player then
-- Check if player's job is in the list of police jobs
for _, jobName in ipairs(Config.PoliceJobs) do
if Player.PlayerData.job.name == jobName and Player.PlayerData.job.onduty then
TriggerClientEvent('container_heist:client:policeAlert', playerId, coords, streetName, containerType)
break -- No need to send multiple alerts to the same player
end
end
end
end
end)
@ -97,11 +109,11 @@ RegisterNetEvent('container_heist:server:finishRobbery', function(containerId, c
-- Decrease durability of flex tool if configured
if Config.RequiredItems.flex.durability then
local itemData = exports['tgiann-inventory']:GetItemByName(src, Config.RequiredItems.flex.name)
if itemData and itemData.info and itemData.info.durabilityPercent then
local newDurability = math.max(0, itemData.info.durabilityPercent - Config.RequiredItems.flex.durabilityDecrease)
if itemData and itemData.info then
local newDurability = math.max(0, (itemData.info.durabilityPercent or 100) - Config.RequiredItems.flex.durabilityDecrease)
exports['tgiann-inventory']:UpdateItemMetadata(src, Config.RequiredItems.flex.name, itemData.slot, {
durabilityPercent = newDurability,
serie = itemData.info.serie,
serie = itemData.info.serie or "TOOL-" .. math.random(100000, 999999),
usedTotalAmmo = itemData.info.usedTotalAmmo or 0,
ammo = itemData.info.ammo or 0
})
@ -158,7 +170,7 @@ RegisterNetEvent('container_heist:server:finishRobbery', function(containerId, c
rewardsGiven = rewardsGiven + 1
end
end
}
if rewardsGiven == 0 then
TriggerClientEvent('QBCore:Notify', src, "The container was empty!", "error")