mirror of
https://github.com/darksaid98/overextended.github.io.git
synced 2026-12-02 06:28:54 +00:00
add some inventory examples
This commit is contained in:
1 parent
7380341246
commit
c1d420aeaa
5 files changed
+44
-15
No files matched your search
@@ -1,9 +1,9 @@
|
||||
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
|
||||
playing one of the death anims.
|
||||
|
||||
```lua
|
||||
exports.ox_inventory:openNearbyInventory()
|
||||
```
|
||||
```
|
||||
@@ -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
|
||||
-- data: table
|
||||
-- cb: function (optional)
|
||||
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)
|
||||
```
|
||||
Reference in new issue
Block a user