> ## Documentation Index
> Fetch the complete documentation index at: https://docs.jaksam-scripts.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Optimización

> Engánchate a los events de items de tu inventario para mejorar el rendimiento de Trackers Creator.

Esta página te muestra cómo optimizar el script. Seguir todas las instrucciones de abajo mejorará el rendimiento del script.

## Comprobación de items

Usa estos events del **lado del servidor** justo después de cualquier adición/eliminación de items. Se pueden usar en cualquier lugar, siempre que reemplaces los parámetros por los adecuados.

```lua theme={null}
TriggerEvent("framework:onItemAdded", playerId, itemName, itemCount)
```

```lua theme={null}
TriggerEvent("framework:onItemRemoved", playerId, itemName, itemCount)
```

### Ejemplos

<Note>
  Si usas algo que no está en los ejemplos, adaptarlo depende de ti — los events indicados arriba funcionan en cualquier lugar si se usan correctamente.
</Note>

#### ESX

<Info>
  El ESX predeterminado ya tiene `esx:onAddInventoryItem` y `esx:onRemoveInventoryItem`, por lo que no necesitarás añadir nada. Sigue el ejemplo de abajo solo si no tienes esos events por algún motivo.
</Info>

Ve a `es_extended/server/classes/player.lua` y añade el siguiente código:

<Frame>
  <img src="https://mintcdn.com/jaksam/cS_rA3IcGZ7NTj0G/images/immagine-2-1.png?fit=max&auto=format&n=cS_rA3IcGZ7NTj0G&q=85&s=d88303125c9d955b51c94f033f3d6f5b" alt="ESX item added/removed hook example 1" width="652" height="299" data-path="images/immagine-2-1.png" />
</Frame>

<Frame>
  <img src="https://mintcdn.com/jaksam/cS_rA3IcGZ7NTj0G/images/immagine-3.png?fit=max&auto=format&n=cS_rA3IcGZ7NTj0G&q=85&s=fb86973babfb7820b9cd00faf766d37d" alt="ESX item added/removed hook example 2" width="777" height="379" data-path="images/immagine-3.png" />
</Frame>

#### OX Inventory (ESX)

Ve a `es_extended/server/classes/overrides/oxinventory.lua` y añade el siguiente código:

<Frame>
  <img src="https://mintcdn.com/jaksam/cS_rA3IcGZ7NTj0G/images/immagine-4-1.png?fit=max&auto=format&n=cS_rA3IcGZ7NTj0G&q=85&s=a36548992235d59e7918f046332d6745" alt="OX Inventory hook example 1" width="626" height="166" data-path="images/immagine-4-1.png" />
</Frame>

<Frame>
  <img src="https://mintcdn.com/jaksam/cS_rA3IcGZ7NTj0G/images/immagine.png?fit=max&auto=format&n=cS_rA3IcGZ7NTj0G&q=85&s=68b0a99ae22a608fb20c10e6a3931907" alt="OX Inventory hook example 2" width="645" height="171" data-path="images/immagine.png" />
</Frame>

#### QBCore (última versión)

Ve a `qb-inventory/server/main.lua` y añade el siguiente código:

<Frame>
  <img src="https://mintcdn.com/jaksam/cS_rA3IcGZ7NTj0G/images/immagine-5-1.png?fit=max&auto=format&n=cS_rA3IcGZ7NTj0G&q=85&s=4af8bc5666aa514902387070cfb17def" alt="QBCore hook example 1" width="913" height="666" data-path="images/immagine-5-1.png" />
</Frame>

<Frame>
  <img src="https://mintcdn.com/jaksam/cS_rA3IcGZ7NTj0G/images/immagine-6.png?fit=max&auto=format&n=cS_rA3IcGZ7NTj0G&q=85&s=041507c082406954f7b070ad611878d6" alt="QBCore hook example 2" width="822" height="525" data-path="images/immagine-6.png" />
</Frame>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.