mirror of
https://github.com/darksaid98/overextended.github.io.git
synced 2026-12-03 06:28:53 +00:00
add some inventory examples
This commit is contained in:
1 parent
7380341246
commit
c1d420aeaa
5 files changed
+40
-11
No files matched your search
@@ -1,6 +1,6 @@
|
|||||||
If possible opens the nearby player's inventory.
|
If possible opens the nearby player's inventory.
|
||||||
|
|
||||||
The player trying to open the invenotry must be able to open their own and
|
The player trying to open the inventory must be able to open their own and
|
||||||
if the player does not have a police job, the target player must be fatally injured or
|
if the player does not have a police job, the target player must be fatally injured or
|
||||||
playing one of the death anims.
|
playing one of the death anims.
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,31 @@
|
|||||||
Uses the passed item, then triggers the callback function.
|
Uses the passed item, then triggers the callback function.
|
||||||
|
Should be calling during item callbacks to utilise the builtin methods (server checks, progress bar, etc.).
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
-- data: table
|
-- data: table
|
||||||
-- cb: function (optional)
|
-- cb: function (optional)
|
||||||
exports.ox_inventory:useItem(data, cb)
|
exports.ox_inventory:useItem(data, cb)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
```lua
|
||||||
|
exports('bandage', function(data, slot)
|
||||||
|
local playerPed = PlayerPedId()
|
||||||
|
local maxHealth = GetEntityMaxHealth(playerPed)
|
||||||
|
local health = GetEntityHealth(playerPed)
|
||||||
|
|
||||||
|
-- Does the ped need to heal?
|
||||||
|
if health < maxHealth then
|
||||||
|
-- Use the bandage
|
||||||
|
exports.ox_inventory:useItem(data, function(data)
|
||||||
|
-- The item has been used, so trigger the effects
|
||||||
|
if data then
|
||||||
|
SetEntityHealth(playerPed, math.min(maxHealth, math.floor(health + maxHealth / 16)))
|
||||||
|
exports.ox_inventory:notify({text = 'You feel better already'})
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
else
|
||||||
|
-- Don't use the item
|
||||||
|
exports.ox_inventory:notify({type = 'error', text = 'You don\'t need a bandage right now'})
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
```
|
||||||
@@ -1,14 +1,21 @@
|
|||||||
Creates an inventory drop at the specified coords.
|
Drops can be created from other resources, containing a variety of items and utilising a custom label (instead of 'Drop 32648').
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
-- prefix: string
|
-- prefix: string
|
||||||
-- items: table
|
-- items: table
|
||||||
|
-- name: string
|
||||||
|
-- count: number
|
||||||
|
-- metadata: table (optional)
|
||||||
-- coords: vector3
|
-- coords: vector3
|
||||||
-- slots: number
|
-- slots: number (optional)
|
||||||
-- maxWeight: number
|
-- maxWeight: number (optional)
|
||||||
-- instance: ? (optional)
|
-- instance: string | number (optional)
|
||||||
exports.ox_inventory:CustomDrop(prefix, item, coords, slots, maxWeight, instance)
|
exports.ox_inventory:CustomDrop(prefix, items, coords, slots, maxWeight, instance)
|
||||||
```
|
```
|
||||||
|
|
||||||
**Example:**
|
```lua
|
||||||
You can find and example showcasing this function into furher detail [here](../../../Guides/customDrop.md).
|
exports.ox_inventory:CustomDrop('Carcass', {
|
||||||
|
{'meat', 5, { grade = 2, type = 'deer' }},
|
||||||
|
{'hide', 5, { grade = 2, type = 'deer' }}
|
||||||
|
}, coords)
|
||||||
|
```
|
||||||
@@ -16,6 +16,7 @@ for k, v in pairs(water) do
|
|||||||
print('\n______________'..'\n- index '..k)
|
print('\n______________'..'\n- index '..k)
|
||||||
print(v.name, 'slot: '..v.slot, 'metadata: '..json.encode(v.metadata))
|
print(v.name, 'slot: '..v.slot, 'metadata: '..json.encode(v.metadata))
|
||||||
water = v
|
water = v
|
||||||
|
break
|
||||||
end
|
end
|
||||||
water.metadata.type = 'clean'
|
water.metadata.type = 'clean'
|
||||||
ox_inventory:SetMetadata(source, water.slot, water.metadata)
|
ox_inventory:SetMetadata(source, water.slot, water.metadata)
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
---
|
|
||||||
title: Creating custom drops
|
|
||||||
---
|
|
||||||
Reference in new issue
Block a user