Skip to content

Commit

Permalink
Fix Drop All Item
Browse files Browse the repository at this point in the history
  • Loading branch information
ElclarkKuhu committed Sep 30, 2021
1 parent 38a3e11 commit 4920c74
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
4 changes: 3 additions & 1 deletion NUI/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ function createItem(obj, append) {
'slot' : obj.slot,
'all' : true
}));
data.filter(i => obj.name != i.name && obj.slot === i.slot)
data = data.filter(i => obj.name != i.name && obj.slot === i.slot)
} else {
$.post(`https://${GetParentResourceName()}/dropItem`, JSON.stringify({
'id' : event.currentTarget.id,
Expand Down Expand Up @@ -205,6 +205,7 @@ function updateData(container, draggable, shiftKey) {
data[i].slot = container.id
}
})

$.post(`https://${GetParentResourceName()}/moveSlot`, JSON.stringify({
'mode': 'move',
'all': true,
Expand All @@ -215,6 +216,7 @@ function updateData(container, draggable, shiftKey) {
}));
} else {
data[index].slot = container.id

$.post(`https://${GetParentResourceName()}/moveSlot`, JSON.stringify({
'mode': 'move',
'all': false,
Expand Down
2 changes: 1 addition & 1 deletion fxmanifest.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
fx_version 'cerulean'

author 'Elclark'
version '1.0.0'
version '1.0.1'
description 'Elclark Inventory Lite. Is an simple ESX Inventory with drag and drop and splittable items to organize your items and weapons'

game 'gta5'
Expand Down
21 changes: 9 additions & 12 deletions server/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -173,23 +173,20 @@ RegisterNetEvent('eInventoryLite:dropItem', function(item)
for key, value in pairs(data[identifier]) do
if item.id == value.id then
if value.type == 'item_standard' then
local InventoryItem = xPlayer.getInventoryItem(value.name)
local count = 1
if item.all then
count = 0
for k, v in pairs(data[identifier]) do
if v.name == value.name and v.slot == value.slot then
count = count + 1
end
local inventoryItem = xPlayer.getInventoryItem(value.name)
if inventoryItem.count > 0 then
local count = 1
if item.all then
count = inventoryItem.count
end
ESX.CreatePickup(value.type, inventoryItem.name, count, inventoryItem.label, source)
xPlayer.removeInventoryItem(inventoryItem.name, count)
end
ESX.CreatePickup(value.type, InventoryItem.name, count, InventoryItem.label, source)
xPlayer.removeInventoryItem(value.name, count)
else
local loadoutNum, weapon = xPlayer.getWeapon(value.name)
if weapon then
ESX.CreatePickup(value.type, value.name, weapon.ammo, weapon.label, source, weapon.components, weapon.tintIndex)
xPlayer.removeWeapon(value.name)
ESX.CreatePickup(value.type, weapon.name, weapon.ammo, weapon.label, source, weapon.components, weapon.tintIndex)
xPlayer.removeWeapon(weapon.name)
end
end

Expand Down

0 comments on commit 4920c74

Please sign in to comment.