VORPCORE/vorp_inventory-lua

[BUG] Create new item with item_crafted_id instead of item id on SetMetadata

ZambrOvosky opened this issue · 16 comments

When you have more than 1 item stacked, let's say 2 pickaxes, and wants to set the metadata for 1 of them, the item_id on items_crafted table is inserted as the id on items_crafted of the original pickaxe instead of the id of the item in items table.

if you have an item with a stack that means the item is same , so adding metadata to a specific item wouldnt make sense as they are the same only unique items wont stack.

if you have an item with a stack that means the item is same , so adding metadata to a specific item wouldnt make sense as they are the same only unique items wont stack.

That's not true, in my usecase I have "pickaxe" that you can stack up to 5. When I use it, I'm not using the 5 of them, just 1. The metadata holds what's the durability for this specific used item is at.
Like, if it's not supposed to set metadata for N amount of a stack, why does VORP have a export for it them?

if you have 5 items stacked they arent unique , meaning they dont have metadata or they all have the same metadata. hence you dont need to get a specifc item to apply, they are the same it doesnt matter which item you apply

they matter when items are unique in which you have exports to get specific items with their unique ids

image
it accepts ammount to set metadata for stacks, you cant indididually set different metadata for a stack using one single call.

image it accepts ammount to set metadata for stacks, you cant indididually set different metadata for a stack using one single call.

Yes you can
https://github.com/VORPCORE/vorp_inventory-lua/blob/c9174d1631922bef9c54d4d472fd972c1f6c68ef/server/services/inventoryApiService.lua#L678C2-L705C5

The call:
VorpInv.setItemMetadata(source, itemId, metadata, amount)
or
exports.vorp_inventory:setItemMetadata(source, itemId, metadata, amount)

The problem it self is here

DBService.CreateItem(charId, item:getId(), amount or 1, metadata, function(craftedItem)

Where item:getId() returns the item crafted id instead of the item id it self.

If it's not supposed to set a metadata to N amount of a stack, the amount param shouldn't exist and this if below shouldn't too

if amountRemove >= count then -- if greater or equals we set meta data

i still dont understand whats the issue you facing ? the metdata isnt being applied if the item is in a stack?

image
stacked
image
applied metadata on a stack of items

When you have more than 1 item stacked, let's say 2 pickaxes, and wants to set the metadata for 1 of them, the item_id on items_crafted table is inserted as the id on items_crafted of the original pickaxe instead of the id of the item in items table.

I explained it on the main thread.

image stacked image applied metadata on a stack of items

log out and log in, the item is gone

let me try

this is why i asked for steps of reproduction, i dont need an explanation, i need steps on how to achieve the issue knowhere you mentioned you loose the item on relog.

step 1 apply meta to a stack of items
step to 2 relog item is gone.

thats what i wanted.
and I just tried and indeed happens

this is why i asked for steps of reproduction, i dont need an explanation, i need steps on how to achieve the issue knowhere you mentioned you loose the item on relog.

step 1 apply meta to a stack of items step to 2 relog item is gone.

thats what i wanted. and I just tried and indeed happens

You got a point, I promise to get better on that.

thanks.