> For the complete documentation index, see [llms.txt](https://documentation.jaksam-scripts.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://documentation.jaksam-scripts.com/trackers-creator/optimization.md).

# Optimization

This page will show you how to optimize the script, following all the instructions will improve the script performance

## Item check

Use these **server-side** events right after any item addition/removal, they can be used anywhere (if you replace the parameters with the proper ones)

```lua
TriggerEvent("framework:onItemAdded", playerId, itemName, itemCount)
```

```lua
TriggerEvent("framework:onItemRemoved", playerId, itemName, itemCount)
```

### Examples

Note: if you use something that is not listed in the examples, editing it is down to you, the events listed above works anywhere if used properly

#### ESX

**Note: default ESX already has `esx:onAddInventoryItem` and `esx:onRemoveInventoryItem` which will allow you to not add anything, so follow the example only if you don't have those events for any reason**

Go in `es_extended/server/classes/player.lua` and add the following codes

<figure><img src="/files/nRGvpFqKdCPRxNgVQjg5" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/5T9fjBvCJRAb3WNqMRc5" alt=""><figcaption></figcaption></figure>

#### OX Inventory (ESX)

Go in `es_extended/server/classes/overrides/oxinventory.lua` and add the following codes

<figure><img src="/files/qgOqdHmgZmrKO4Rh62CG" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/L0CWPeNNO2YP6lyOcp5e" alt=""><figcaption></figcaption></figure>

#### QBCore (latest version)

Go in `qb-inventory/server/main.lua` and add the following codes

<figure><img src="/files/pJaVr7VPZUQKSmBFrhBB" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/Z7ycr53lfaF97kHhPV2Z" alt=""><figcaption></figcaption></figure>

##
