Closed SKITTLE6969 closed 10 months ago
@SKITTLE6969 Video is not available. But i have the same problem. If you split an item in several stacks and you remove all items in on RemoveItem call without a slot number, then the items will not removed. After a short view in code. I found the reason for. There is no code implemented if a slot has a lower amount of items. So no items will return. See: https://github.com/qbcore-framework/qb-inventory/blob/main/server/main.lua#L255
The code has to change like:
local function RemoveItem(source, item, amount, slot)
local Player = QBCore.Functions.GetPlayer(source)
if not Player then return false end
amount = tonumber(amount) or 1
slot = tonumber(slot)
if slot then
if Player.PlayerData.items[slot].amount > amount then
Player.PlayerData.items[slot].amount = Player.PlayerData.items[slot].amount - amount
Player.Functions.SetPlayerData("items", Player.PlayerData.items)
if not Player.Offline then
TriggerEvent('qb-log:server:CreateLog', 'playerinventory', 'RemoveItem', 'red', '**' .. GetPlayerName(source) .. ' (citizenid: ' .. Player.PlayerData.citizenid .. ' | id: ' .. source .. ')** lost item: [slot:' .. slot .. '], itemname: ' .. Player.PlayerData.items[slot].name .. ', removed amount: ' .. amount .. ', new total amount: ' .. Player.PlayerData.items[slot].amount)
end
return true
elseif Player.PlayerData.items[slot].amount == amount then
Player.PlayerData.items[slot] = nil
Player.Functions.SetPlayerData("items", Player.PlayerData.items)
if Player.Offline then return true end
TriggerEvent('qb-log:server:CreateLog', 'playerinventory', 'RemoveItem', 'red', '**' .. GetPlayerName(source) .. ' (citizenid: ' .. Player.PlayerData.citizenid .. ' | id: ' .. source .. ')** lost item: [slot:' .. slot .. '], itemname: ' .. item .. ', removed amount: ' .. amount .. ', item removed')
return true
end
else
local slots = GetSlotsByItem(Player.PlayerData.items, item)
local amountToRemove = amount
if not slots then return false end
local itemAmountOfPlayer = 0
for _, _slot in pairs(slots) do
itemAmountOfPlayer += Player.PlayerData.items[_slot].amount
end
if amount > itemAmountOfPlayer then
return false
end
for _, _slot in pairs(slots) do
if Player.PlayerData.items[_slot].amount > amountToRemove then
Player.PlayerData.items[_slot].amount = Player.PlayerData.items[_slot].amount - amountToRemove
Player.Functions.SetPlayerData("items", Player.PlayerData.items)
if not Player.Offline then
TriggerEvent('qb-log:server:CreateLog', 'playerinventory', 'RemoveItem', 'red', '**' .. GetPlayerName(source) .. ' (citizenid: ' .. Player.PlayerData.citizenid .. ' | id: ' .. source .. ')** lost item: [slot:' .. _slot .. '], itemname: ' .. Player.PlayerData.items[_slot].name .. ', removed amount: ' .. amount .. ', new total amount: ' .. Player.PlayerData.items[_slot].amount)
end
return true
elseif Player.PlayerData.items[_slot].amount == amountToRemove then
Player.PlayerData.items[_slot] = nil
Player.Functions.SetPlayerData("items", Player.PlayerData.items)
if Player.Offline then return true end
TriggerEvent('qb-log:server:CreateLog', 'playerinventory', 'RemoveItem', 'red', '**' .. GetPlayerName(source) .. ' (citizenid: ' .. Player.PlayerData.citizenid .. ' | id: ' .. source .. ')** lost item: [slot:' .. _slot .. '], itemname: ' .. item .. ', removed amount: ' .. amount .. ', item removed')
return true
elseif Player.PlayerData.items[_slot].amount < amountToRemove then
amount -= Player.PlayerData.items[_slot].amount
local removedAmount -= Player.PlayerData.items[_slot].amount
Player.PlayerData.items[_slot] = nil
Player.Functions.SetPlayerData("items", Player.PlayerData.items)
if not Player.Offline then
TriggerEvent('qb-log:server:CreateLog', 'playerinventory', 'RemoveItem', 'red', '**' .. GetPlayerName(source) .. ' (citizenid: ' .. Player.PlayerData.citizenid .. ' | id: ' .. source .. ')** lost item: [slot:' .. _slot .. '], itemname: ' .. item .. ', removed amount: ' .. removedAmount .. ', item removed')
end
end
end
end
return false
end
(Code is not tested)
But this is only a dirty fix, maybe someone of QB-inventory owner can fix the code.
i have created a pull request https://github.com/qbcore-framework/qb-inventory/pull/406
since the video is not available all you have to do is open a stash anywhere drop all the items you need to dupe close stash open the stash again and take all the items back while keeping the inventory open f8 quit
once you rejoin all the items will be duplicated even unique items
Okay, this is another issue then i have.
since the video is not available all you have to do is open a stash anywhere drop all the items you need to dupe close stash open the stash again and take all the items back while keeping the inventory open f8 quit
once you rejoin all the items will be duplicated even unique items
I have tested this out and not happening on my side.. did you made changes to your inventory ?
dont try it on a local host, try on a vps server or a different hosting
I've tried this on my live server with 120 pop right now, steps:
Does not seem like this exists?
I've tried this on my live server with 120 pop right now, steps:
- Spawned 3 pistols on me
- Opened apartment stash
- Moved 3 pistols in and exited the stash
- Re-opened stash and moved 3 pistol to inventory
- Press F8 and quit
- Rejoined server
- 3 pistols in my inventory, none in stash
Does not seem like this exists?
Follow this method, this was done on a vanilla install https://streamable.com/bwj7ah
Follow this method,
Holy shit! It actually works ><
Follow this method,
Holy shit! It actually works ><
told ya heheeee xD
any update on this?
This issue has had 60 days of inactivity & will close within 7 days
Summary
im using all qb latest stuff and qb inventory with a reskin not lj inventory xD
Reproduction
https://streamable.com/b827jw - follow the video new link https://streamable.com/bwj7ah
Expected behavior
WATCH THE VIDEO FOR BETTER UNDERSTANDING
Actual behavior
WATCH THE VIDEO FOR BETTER UNDERSTANDING
Additional context
WATCH THE VIDEO FOR BETTER UNDERSTANDING
Last Updated
couple of days back
Custom Resources
nope
Resource Rename
nope