To write in your [esx_inventoryhud\client\main.lua]
RegisterNUICallback( "DropItem", function(data, cb) if IsPedSittingInAnyVehicle(playerPed) then return end
if type(data.number) == "number" and math.floor(data.number) == data.number then TriggerServerEvent("esx_inventoryhud:deleteItem", data.item.type, data.item.name, data.number) end
Wait(250) loadPlayerInventory()
cb("ok") end
)
and to write in your [esx_inventoryhud\server\main.lua]
RegisterNetEvent("esx_inventoryhud:deleteItem")
AddEventHandler("esx_inventoryhud:deleteItem", function(itemType, itemName, nb)
local playerId = source
local xPlayer = ESX.GetPlayerFromId(source)
itemCount = nb
if itemType == 'item_standard' then
if itemCount == nil or itemCount < 1 then
xPlayer.showNotification('invalid quantity')
else
local xItem = xPlayer.getInventoryItem(itemName)
if (itemCount > xItem.count or xItem.count < 1) then
xPlayer.showNotification('invalid quantity')
else
xPlayer.removeInventoryItem(itemName, itemCount)
end
end
elseif itemType == 'item_account' then
if itemCount == nil or itemCount < 1 then
xPlayer.showNotification('invalid amount')
else
local account = xPlayer.getAccount(itemName)
if (itemCount > account.money or account.money < 1) then
--xPlayer.showNotification(_U('imp_invalid_amount'))
xPlayer.showNotification('invalid amount')
else
xPlayer.removeAccountMoney(itemName, itemCount)
end
end
elseif itemType == 'item_weapon' then
itemName = string.upper(itemName)
if xPlayer.hasWeapon(itemName) then
local _, weapon = xPlayer.getWeapon(itemName)
local _, weaponObject = ESX.GetWeapon(itemName)
local components, pickupLabel = ESX.Table.Clone(weapon.components)
xPlayer.removeWeapon(itemName)
xPlayer.showNotification('Threw weapon : '..weapon.label)
if weaponObject.ammo and weapon.ammo > 0 then
local ammoLabel = weaponObject.ammo.label
else
xPlayer.showNotification('threw weapon :'..weapon.label)
end
end
end
end)
Am besten Backup von beiden Ressourcen machen wenn du dies änderst
Bei mir hat dass geholfen!