Skip to content

Commit

Permalink
Merge pull request #547 from Sanriku-Gaming/main
Browse files Browse the repository at this point in the history
fix item info in giveitem function
  • Loading branch information
GhzGarage authored Jul 25, 2024
2 parents 00a092e + 83d6f5f commit b0291d6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion client/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ RegisterNUICallback('GiveItem', function(data, cb)
local playerId = GetPlayerServerId(player)
QBCore.Functions.TriggerCallback('qb-inventory:server:giveItem', function(success)
cb(success)
end, playerId, data.item.name, data.amount)
end, playerId, data.item.name, data.amount, data.slot, data.info)
else
QBCore.Functions.Notify(Lang:t('notify.nonb'), 'error')
cb(false)
Expand Down
2 changes: 2 additions & 0 deletions html/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,8 @@ const InventoryContainer = Vue.createApp({
await axios.post("https://qb-inventory/GiveItem", {
item: selectedItem,
amount: amountToGive,
slot: selectedItem.slot,
info: selectedItem.info,
});
this.playerInventory[selectedItem.slot].amount -= amountToGive;
if (this.playerInventory[selectedItem.slot].amount === 0) {
Expand Down
10 changes: 5 additions & 5 deletions server/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ QBCore.Functions.CreateCallback('qb-inventory:server:attemptPurchase', function(
end
end)

QBCore.Functions.CreateCallback('qb-inventory:server:giveItem', function(source, cb, target, item, amount)
QBCore.Functions.CreateCallback('qb-inventory:server:giveItem', function(source, cb, target, item, amount, slot, info)
local player = QBCore.Functions.GetPlayer(source)
if not player or player.PlayerData.metadata['isdead'] or player.PlayerData.metadata['inlaststand'] or player.PlayerData.metadata['ishandcuffed'] then
cb(false)
Expand Down Expand Up @@ -355,14 +355,14 @@ QBCore.Functions.CreateCallback('qb-inventory:server:giveItem', function(source,
return
end

local giveItem = AddItem(target, item, giveAmount)
if not giveItem then
local removeItem = RemoveItem(source, item, giveAmount, slot, 'Item given to ID #'..target)
if not removeItem then
cb(false)
return
end

local removeItem = RemoveItem(source, item, giveAmount)
if not removeItem then
local giveItem = AddItem(target, item, giveAmount, false, info, 'Item given from ID #'..source)
if not giveItem then
cb(false)
return
end
Expand Down

0 comments on commit b0291d6

Please sign in to comment.