qbcore-framework / qb-inventory

Slot Based Inventory System Used With QB-Core :school_satchel:
GNU General Public License v3.0
49 stars 376 forks source link

giveitem and cancarryitem #411

Closed i-kulgu closed 1 year ago

i-kulgu commented 1 year ago

Description

With this PR you can give an item more controlled. You'll get a list of nearby players and when you choose a player it will give the item to that selected player.

Preview: https://www.youtube.com/watch?v=WtpmP7GfGF0

Also added an export to check if the user can carry an amount of item. Usage :

local cancarry = exports['qb-inventory']:CanCarryItem(src,item,amount)
if not cancarry then TriggerClientEvent("QBCore:Notify", src, "Not enough room in inventory", "error") return end

Checklist

QBLes commented 1 year ago

i can Confirm this works.

xxUnknown13xx commented 1 year ago

Where can I add this? :) local cancarry = exports['qb-inventory']:CanCarryItem(src,item,amount) if not cancarry then TriggerClientEvent("QBCore:Notify", src, "Not enough room in inventory", "error") return end

i-kulgu commented 1 year ago

Where can I add this? :) local cancarry = exports['qb-inventory']:CanCarryItem(src,item,amount) if not cancarry then TriggerClientEvent("QBCore:Notify", src, "Not enough room in inventory", "error") return end

Inside any script where you want to check if the user can carry an item before giving it. Export will return a boolean so you can use that also in an if statement like :

local cancarry = exports['qb-inventory']:CanCarryItem(src, 'diamond' , 10)
if cancarry then
    print('You can carry 10 diamonds')
    -- User can carry the given item with given amount
else
    print('You can\'t carry 10 diamonds')
    -- User can't carry the given item with given amount
end
03ntity commented 1 year ago

FiveM_b2699_GTAProcess 2023-01-18 23-13-53

player name appears duplicate

i-kulgu commented 1 year ago

player name appears duplicate

See the latest commit, it's fixed in there