> 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="https://3735039044-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFH9TH8An8XLjMiOMvVGb%2Fuploads%2Fgit-blob-9e92b91cc004e049da74ade3f0dc74fb3cfd0212%2Fimmagine.png?alt=media" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3735039044-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFH9TH8An8XLjMiOMvVGb%2Fuploads%2Fgit-blob-8bc3619a9b4716d22dc33a4c9ca5bf5d3a6d4839%2Fimmagine.png?alt=media" alt=""><figcaption></figcaption></figure>

#### OX Inventory (ESX)

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

<figure><img src="https://3735039044-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFH9TH8An8XLjMiOMvVGb%2Fuploads%2Fgit-blob-35fb9b52c2d90f308fc87b8820daa17f198a5001%2Fimmagine.png?alt=media" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3735039044-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFH9TH8An8XLjMiOMvVGb%2Fuploads%2Fgit-blob-4ca32b70f370bcd9f531243cb0d0676347a45ec5%2Fimmagine.png?alt=media" alt=""><figcaption></figcaption></figure>

#### QBCore (latest version)

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

<figure><img src="https://3735039044-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFH9TH8An8XLjMiOMvVGb%2Fuploads%2Fgit-blob-204caf892148003c1c8db79c98d8761e6ec3e19e%2Fimmagine.png?alt=media" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3735039044-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFH9TH8An8XLjMiOMvVGb%2Fuploads%2Fgit-blob-554ba2ce92c8a30e5d7535362c27c56d8aa81150%2Fimmagine.png?alt=media" alt=""><figcaption></figcaption></figure>

##
