add item decay

This commit is contained in:
Linden committed 2023-06-28 00:16:28 +10:00
1 parent 901dfc5832
commit ece8ef6116
1 file changed
+70 -67
+70 -67
View File
@@ -14,61 +14,64 @@ options for the item.
**Item options:** **Item options:**
* label: `string` - label: `string`
* weight?: `number` - weight?: `number`
* stack?: `boolean` - stack?: `boolean`
* If set to false will not allow the item to be stacked. - If set to false will not allow the item to be stacked.
* degrade?: `number` - degrade?: `number`
* Amount of time in minutes the item will degrade after. - Amount of time in minutes the item will degrade after.
* close?: `boolean` - decay?: `boolean`
* If set to false does not close the inventory on item use. - If true the item will be deleted when durability reaches 0 (not instant for degraded items).
* description?: `string` - close?: `boolean`
* Item description that will be shown in the tooltip - If set to false does not close the inventory on item use.
* consume?: `number` - description?: `string`
* Item count needed and removed use. - Item description that will be shown in the tooltip
* Default: 1 - consume?: `number`
* If set to a decimal will consume durability instead (0.2 = 20%). - Item count needed and removed use.
* allowArmed?: `boolean` - Default: 1
* If set to true will allow use of item while armed with a weapon. - If set to a decimal will consume durability instead (0.2 = 20%).
* server?: `table` - allowArmed?: `boolean`
* export?: `string` - If set to true will allow use of item while armed with a weapon.
* client?: `table` - server?: `table`
* export?: `string` - export?: `string`
* Export to be triggered after item use. - client?: `table`
* event?: `string` - export?: `string`
* Event to be triggered after item use. - Export to be triggered after item use.
* status?: `table` - event?: `string`
* Adjust esx_status values after use. - Event to be triggered after item use.
* anim?: `table` - status?: `table`
* Animation that will be played during the progress bar. - Adjust esx_status values after use.
* dict: `string` - anim?: `table`
* clip: `string` - Animation that will be played during the progress bar.
* prop?: `table` - dict: `string`
* Attached prop that will be displayed during the progress bar. - clip: `string`
* model: `string` or `hash` - prop?: `table`
* pos: `table` (x, y, z) - Attached prop that will be displayed during the progress bar.
* rot: `table` (x, y, z) - model: `string` or `hash`
* disable?: `table` - pos: `table` (x, y, z)
* Actions to be disabled during the progress bar - rot: `table` (x, y, z)
* move?: `boolean` - disable?: `table`
* car?: `boolean` - Actions to be disabled during the progress bar
* combat?: `boolean` - move?: `boolean`
* mouse?: `boolean` - car?: `boolean`
* usetime?: `number` - combat?: `boolean`
* cancel?: `boolean` - mouse?: `boolean`
* If set to true the player canc cancel item use. - usetime?: `number`
* add?: `function`(total: `number`) - cancel?: `boolean`
* Function that triggers when receiving an item - If set to true the player canc cancel item use.
* Returns total item count as `total` - add?: `function`(total: `number`)
* remove?: `function`(total: `number`) - Function that triggers when receiving an item
* Function that triggers when removing an item - Returns total item count as `total`
* Returns total item count as `total` - remove?: `function`(total: `number`)
* buttons?: `table` - Function that triggers when removing an item
* label: `string` - Returns total item count as `total`
* action: `function`(slot: `number`) - buttons?: `table`
* Callback function when button is clicked in context menu, returns item slot. - label: `string`
- action: `function`(slot: `number`)
- Callback function when button is clicked in context menu, returns item slot.
**Examples:** **Examples:**
<Tabs items={["Burger", "Burger with description", "Burger with notification"]}> <Tabs items={["Burger", "Burger with description", "Burger with notification"]}>
<Tab> <Tab>
@@ -148,8 +151,8 @@ A modified burger item, which gives you notifications on add and remove argument
## Making the item usable ## Making the item usable
* If you are using ESX, you can continue using `ESX.RegisterUsableItem`. - If you are using ESX, you can continue using `ESX.RegisterUsableItem`.
* If you are using QBCore, you can continue using `QBCore.Functions.CreateUseableItem`. - If you are using QBCore, you can continue using `QBCore.Functions.CreateUseableItem`.
Using the built-in system is more secure and provides much more functionality. Using the built-in system is more secure and provides much more functionality.
@@ -238,21 +241,21 @@ Like with other items the item must first be registered.
}, },
``` ```
When registered you can define the item as a container in `/modules/items/containers.lua` When registered you can define the item as a container in `/modules/items/containers.lua`
The key for the container is the `name` you gave it when registering the item. The key for the container is the `name` you gave it when registering the item.
You can also define the number of slots, the maximum weight, blacklist and whitelist items. You can also define the number of slots, the maximum weight, blacklist and whitelist items.
* itemName: - itemName:
* slots: number - slots: number
* The number represents the amount of slots - The number represents the amount of slots
* maxWeight: number - maxWeight: number
* The number represents the maximum weight within the container - The number represents the maximum weight within the container
* blacklist: - blacklist:
* Supports single and multiple items - Supports single and multiple items
* `{ 'testburger', 'testburger2' }` - `{ 'testburger', 'testburger2' }`
* whitelist: - whitelist:
* Supports single and multiple items - Supports single and multiple items
* `{ 'testburger', 'testburger2' }` - `{ 'testburger', 'testburger2' }`
**Example:** **Example:**