mirror of
https://github.com/darksaid98/overextended.github.io.git
synced 2026-12-02 06:28:54 +00:00
Update Hooks.md
This commit is contained in:
1 parent
16da566b13
commit
41e699a52e
1 file changed
+44
-13
@@ -13,6 +13,12 @@ exports.ox_inventory:registerHook(eventName, function(payload) end, options)
|
|||||||
- The event will only trigger for items defined as keys in a set.
|
- The event will only trigger for items defined as keys in a set.
|
||||||
- inventoryFilter?: `string[]`
|
- inventoryFilter?: `string[]`
|
||||||
- The event will only trigger for inventories that match one of the [patterns](<http://www.easyuo.com/openeuo/wiki/index.php/Lua_Patterns_and_Captures_(Regular_Expressions)>) in the array.
|
- The event will only trigger for inventories that match one of the [patterns](<http://www.easyuo.com/openeuo/wiki/index.php/Lua_Patterns_and_Captures_(Regular_Expressions)>) in the array.
|
||||||
|
- typeFilter?: `{ [string]: true }`
|
||||||
|
- The event will only trigger for inventories with one of the provided types (e.g. 'player', 'stash')
|
||||||
|
|
||||||
|
Return:
|
||||||
|
|
||||||
|
- hookId: `number`
|
||||||
|
|
||||||
## swapItems
|
## swapItems
|
||||||
|
|
||||||
@@ -31,10 +37,6 @@ By returning `false`, you can cancel the action and revert the inventory state.
|
|||||||
- toSlot?: `table` or `number`
|
- toSlot?: `table` or `number`
|
||||||
- count: `number`
|
- count: `number`
|
||||||
|
|
||||||
Return:
|
|
||||||
|
|
||||||
- hookId: `number`
|
|
||||||
|
|
||||||
**Example:**
|
**Example:**
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
@@ -63,13 +65,11 @@ Blacklists "water" from being moved into or from gloveboxes and trunks.
|
|||||||
- inventoryId: `number` or `string`
|
- inventoryId: `number` or `string`
|
||||||
- inventoryType: `string`
|
- inventoryType: `string`
|
||||||
|
|
||||||
Return:
|
|
||||||
|
|
||||||
- hookId: `number`
|
|
||||||
|
|
||||||
Triggered when a player tries to open a secondary inventory.
|
Triggered when a player tries to open a secondary inventory.
|
||||||
By returning `false`, you can cancel the action and keep the player's inventory closed.
|
By returning `false`, you can cancel the action and keep the player's inventory closed.
|
||||||
|
|
||||||
|
**Example:**
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
local hookId = exports.ox_inventory:registerHook('openInventory', function(payload)
|
local hookId = exports.ox_inventory:registerHook('openInventory', function(payload)
|
||||||
print(json.encode(payload, { indent = true }))
|
print(json.encode(payload, { indent = true }))
|
||||||
@@ -94,13 +94,11 @@ Disables gloveboxes and trunks.
|
|||||||
- item: `table`
|
- item: `table`
|
||||||
- count: `number`
|
- count: `number`
|
||||||
|
|
||||||
Return:
|
|
||||||
|
|
||||||
- hookId: `number`
|
|
||||||
|
|
||||||
Triggered when an item is created, either by buying it, using AddItem, or when converting inventory data.
|
Triggered when an item is created, either by buying it, using AddItem, or when converting inventory data.
|
||||||
By returning a table you can modify or replace the metadata given to an item.
|
By returning a table you can modify or replace the metadata given to an item.
|
||||||
|
|
||||||
|
**Example:**
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
local hookId = exports.ox_inventory:registerHook('createItem', function(payload)
|
local hookId = exports.ox_inventory:registerHook('createItem', function(payload)
|
||||||
print(json.encode(payload, { indent = true }))
|
print(json.encode(payload, { indent = true }))
|
||||||
@@ -117,6 +115,39 @@ end, {
|
|||||||
|
|
||||||
Sets the label for "water" to "Mineral Water".
|
Sets the label for "water" to "Mineral Water".
|
||||||
|
|
||||||
|
## buyItem
|
||||||
|
|
||||||
|
**Payload:**
|
||||||
|
- source: `number`
|
||||||
|
- shopType: `string`
|
||||||
|
- shopId: `number`
|
||||||
|
- toInventory: `number`
|
||||||
|
- toSlot: `number`
|
||||||
|
- itemName: `string`
|
||||||
|
- metadata: `table`
|
||||||
|
- count: `number`
|
||||||
|
- price: `number`
|
||||||
|
- totalPrice: `number`
|
||||||
|
- currency?: `string`
|
||||||
|
|
||||||
|
Triggered when an item is about to be purchased and can return `false` to prevent the transaction.
|
||||||
|
|
||||||
|
**Example:**
|
||||||
|
|
||||||
|
```lua
|
||||||
|
local hookId = exports.ox_inventory:registerHook('buyItem', function(payload)
|
||||||
|
print(json.encode(payload, { indent = true, sort_keys = true }))
|
||||||
|
return false
|
||||||
|
end, {
|
||||||
|
print = true,
|
||||||
|
typeFilter = {
|
||||||
|
General = true
|
||||||
|
},
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
Prevents players from purchasing items at General stores.
|
||||||
|
|
||||||
## removeHooks
|
## removeHooks
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
@@ -126,4 +157,4 @@ exports.ox_inventory:removeHooks(id)
|
|||||||
- id?: `number`
|
- id?: `number`
|
||||||
|
|
||||||
Removes a hook created by the invoking resource with the the specified id.
|
Removes a hook created by the invoking resource with the the specified id.
|
||||||
If no id is specified then all hooks are removed.
|
If no id is specified then all hooks registered by the resource are removed.
|
||||||
Reference in new issue
Block a user