mirror of
https://github.com/darksaid98/overextended.github.io.git
synced 2026-12-01 14:38:50 +00:00
Update AddItem
This commit is contained in:
1 parent
43f8625fa5
commit
07fc67545a
1 file changed
+27
-6
@@ -1,6 +1,6 @@
|
||||
Adds an item into the specified inventory.
|
||||
|
||||
Should be used alongside [CanCarryItem](./CanCarryItem.md).
|
||||
Should be used alongside [CanCarryItem](./CanCarryItem.md) otherwise, the maximum weight may be exceeded.
|
||||
|
||||
```lua
|
||||
-- inv: string or number
|
||||
@@ -15,10 +15,31 @@ exports.ox_inventory:AddItem(inv, item, count, metadata, slot, cb)
|
||||
**Example:**
|
||||
```lua
|
||||
exports.ox_inventory:AddItem(1, 'bread', 4, nil, nil, function(success, reason)
|
||||
if not success then
|
||||
if reason == 'overburdened' then
|
||||
TriggerClientEvent('ox_inventory:notify', source, {type = 'error', text = shared.locale('cannot_carry', count, data.label), duration = 2500})
|
||||
end
|
||||
if success then
|
||||
print(json.encode(reason, {indent=true}))
|
||||
--[[
|
||||
{
|
||||
"metadata": [],
|
||||
"label": "Bread",
|
||||
"slot": 1,
|
||||
"stack": true,
|
||||
"close": true,
|
||||
"name": "bread",
|
||||
"count": 1,
|
||||
"weight": 150
|
||||
}
|
||||
]]
|
||||
else
|
||||
print(success)
|
||||
-- nil
|
||||
|
||||
print(reason)
|
||||
-- for example if all slots are taken it will give us "inventory_full"
|
||||
end
|
||||
end)
|
||||
```
|
||||
```
|
||||
|
||||
**Possible value of the "reason" argument for the callback function:**
|
||||
+ "invalid_item": the item doesn't exist
|
||||
+ "invalid_inventory": the inventory doesn't exist
|
||||
+ "inventory_full": no free slots
|
||||
Reference in new issue
Block a user