RegisterNetEvent('esx:onPickup')
AddEventHandler('esx:onPickup', function(id)
local pickup, xPlayer,success = ESX.Pickups[id], ESX.GetPlayerFromId(source)
if pickup then
if pickup.type == 'item_standard' then
local maxWeight, currentWeight = xPlayer.maxWeight , xPlayer.weight
local item = xPlayer.getInventoryItem(pickup.name)
local newWeight = currentWeight + (item.weight * pickup.count)
local remaining = 0
TriggerClientEvent('esx:removePickup', -1, id)
while (maxWeight < newWeight) and (0 < pickup.count) do
pickup.count = pickup.count - 1
remaining = remaining + 1
newWeight = currentWeight + (item.weight * pickup.count)
end
if pickup.count > 0 then
xPlayer.addInventoryItem(pickup.name, pickup.count)
success = true
end
if remaining > 0 then
xPlayer.showNotification(_U('threw_cannot_pickup'))
local pickupLabel = ('~y~%s~s~ [~b~%s~s~]'):format(item.label, remaining)
ESX.CreatePickup ('item_standard', pickup.name, remaining, pickupLabel, source)
end
- if pickup then
- if pickup.type == 'item_standard' then
- if xPlayer.canCarryItem (pickup.name, pickup.count) then
- xPlayer.addInventoryItem (pickup.name, pickup.count)
- success = true
- else
- xPlayer.showNotification (_U ('threw_cannot_pickup'))
- end
elseif pickup.type == 'item_account' then
success = true
xPlayer.addAccountMoney (pickup.name, pickup.count)
elseif pickup.type == 'item_weapon' then
if xPlayer.hasWeapon (pickup.name) then
xplayer.shownotificatio the (_ (the 'threw_weapon_already'))
else
success = true
xPlayer.addWeapon (pickup.name, pickup.count)
xPlayer.setWeaponTint (pickup.name, pickup.tintIndex)
for k, v in ipairs (pickup.components) do
xPlayer.addWeaponComponent (pickup.name, v)
end
end
end
if success then
ESX.Pickups [id] = nil
TriggerClientEvent ('esx: removePickup', -1, id)
end
end
end) Starting from [/ CODE] 422, I have added as much of my item on the ground as we can and leave the rest.
[/ QUOTE]
can you explain a little more ?