ESX.RegisterServerCallback('esx_ambulancejob:removeItemsAfterRPDeath', function(source, cb)
local xPlayer = ESX.GetPlayerFromId(source)
if Config.RemoveCashAfterRPDeath then
if xPlayer.getMoney() > 0 then
xPlayer.removeMoney(xPlayer.getMoney())
end
if xPlayer.getAccount('black_money').money > 0 then
xPlayer.setAccountMoney('black_money', 0)
end
end
if Config.RemoveItemsAfterRPDeath then
for i=1, #xPlayer.inventory, 1 do
if xPlayer.inventory[i].count > 0 then
xPlayer.setInventoryItem(xPlayer.inventory[i].name, 0)
end
end
end
local playerLoadout = {}
if Config.RemoveWeaponsAfterRPDeath then
for i=1, #xPlayer.loadout, 1 do
--xPlayer.removeWeapon(xPlayer.loadout[i].name)
xPlayer.removeInventoryItem(xPlayer.loadout[i].name, 1)
end
else -- save weapons & restore em' since spawnmanager removes them
for i=1, #xPlayer.loadout, 1 do
table.insert(playerLoadout, xPlayer.loadout[i])
end
-- give back wepaons after a couple of seconds
Citizen.CreateThread(function()
Citizen.Wait(5000)
for i=1, #playerLoadout, 1 do
if playerLoadout[i].label ~= nil then
--xPlayer.addWeapon(playerLoadout[i].name, playerLoadout[i].ammo)
xPlayer.addInventoryItem(playerLoadout[i].name,1)
end
end
end)
end
cb()
end)