Clear Inventory

Quasar Inventory brings a system that with the versions was improving day after day, today, you can even configure the items that will not be removed from your inventory after dying, as we mentioned in the example of the local saveItems.

To clean up inventories after death, we need to make a series of changes to our esx_ambulancejob or use that reference in your ambulancejob resource.

We will apply the changes in the following event RegisterServerCallback esx_ambulancejob:removeItemsAfterRPDeath as follows:

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(), "Death")
        end

        if xPlayer.getAccount('black_money').money > 0 then
            xPlayer.setAccountMoney('black_money', 0, "Death")
        end
    end

    if Config.RemoveItemsAfterRPDeath then
        local saveItems = {
            'id_card', -- Add here the items that you do NOT want to be deleted
            'phone',
        }
        exports['qs-inventory']:ClearInventory(source, saveItems)
    end

    if Config.RemoveWeaponsAfterRPDeath then
        local weapons = exports['qs-inventory']:GetWeaponList()
        for k,v in pairs(weapons) do
            xPlayer.removeInventoryItem(v.name, 1 )
        end
    end

    cb()
end)

For this change we also bring the most recent version of esx_ambulancejob with these changes applied, to make your day easier and avoid random errors. Keep in mind that if you are going to use this esx_ambulancejob you must have the latest versions of esx-legacy.

Last updated