# Creative items

## Item Exports 🍀

> ⚠️ **All code shown in this section must be added to:**\
> \&#xNAN;**`data/items.lua`**\
> (unless the documentation states otherwise)

This system allows you to create your **own custom item exports**, which can trigger stress-related functions directly from the script.\
Below is an example export and instructions on how to create your own items.

***

### Example Export 📦

```lua
exports("YoursNameOfExport", function(data)
    print("Stress Test")
    ShowNotify('Test Stress Item', 'success') -- use for notify
    
    RemoveStress(10)
    print('Removed 10 stress')
    
    SetTemporaryProof(10, 10000)
    print('Set temporary proof to 10% for 10000ms')
    
    SetStressProof("Shooting", 1)
    print('Set stress proof to Shooting for 1')

    -- add your event to remove item. If you use ox_inventory (data.name = item name)
end)
```

***

### Adding an Item (ox\_inventory) 🗂️

To create your own stress-related item, add it to:

**`data/items.lua`**

```lua
["stress_test"] = {
    label = "Stress Test",
    weight = 1,
    stack = true,
    client = {
       export = "nrg_stress:YoursNameOfExport",
   },
},
```

> 💡 **This is only an example using ox\_inventory.**\
> You can use *any inventory system* as long as it allows assigning an export to an item and calling it when the item is used.\
> The export name you created will work universally.

***

## Available Functions ⚙️

These functions can be used inside your export or anywhere in the script.

***

### ➤ SetStress

Sets the player's stress level.

```lua
SetStress(value)
```

**Example:**

```lua
SetStress(50)
```

***

### ➤ GetStress

Gets the player's current stress level.

```lua
GetStress()
```

**Returns:** number

**Example:**

```lua
print("Stress:", GetStress())
```

***

### ➤ RemoveStress

Removes stress from the player.

```lua
RemoveStress(value)
```

**Example:**

```lua
RemoveStress(10)
```

***

### ➤ AddStress

Adds stress to the player.

```lua
AddStress(value)
```

**Example:**

```lua
AddStress(15)
```

***

### ➤ SetStressProof

Adds or removes immunity to a specific stress type.

```lua
SetStressProof(type, value)
```

**type** (string):\
`Shooting`, `CarCrash`, `Fight`, `FastDriving`, `SeenPedKilled`

**value** (number):\
`1` – enable immunity\
`0` – disable immunity

**Example:**

```lua
SetStressProof("Shooting", 1)
```

***

### ➤ SetTemporaryProof

Temporarily reduces stress gained from all sources.

```lua
SetTemporaryProof(percent, time)
```

**percent** (number) – Reduction percentage\
**time** (number) – Duration in milliseconds

**Example:**

```lua
SetTemporaryProof(30, 5000)
```

***

### ➤ GetStressProof

Returns the immunity configuration of the player.

```lua
GetStressProof()
```

**Returns:** table

**Example:**

```lua
local proof = GetStressProof()
print(json.encode(proof))
```

***

### ➤ ShowNotify

Displays a notification.

```lua
ShowNotify('Your text', 'success')
```

***

## Summary 📘

You can freely create your own items and assign custom behavior to them using exports.\
This allows you to fully integrate stress mechanics into gameplay features, consumables, abilities, tools, and more.
