> ## 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.

# Key emulator used

> Triggered server side after every try of the key emulator, when it opens a car and when it misses.

Triggered after every try of the [key emulator](https://docs.jaksam-scripts.com/vehicles-keys/guides/key-emulator.md): once with `success = true` when it opens the car, and once with `success = false` for every miss.

```lua Event theme={null}
AddEventHandler("vehicles_keys:playerUsedKeyEmulator", function(playerId, vehicleNetId, success)

end)
```

### Parameters

| Name | Data Type | Description |
| - | - | - |
| `playerId` | integer | Server ID of the thief |
| `vehicleNetId` | integer | Network ID of the car |
| `success` | boolean | `true`: the doors opened. `false`: a missed try |

## Example

```lua theme={null}
AddEventHandler("vehicles_keys:playerUsedKeyEmulator", function(playerId, vehicleNetId, success)
    if(not success) then return end

    local vehicle = NetworkGetEntityFromNetworkId(vehicleNetId)
    local plate = GetVehicleNumberPlateText(vehicle)

    print(GetPlayerName(playerId) .. " opened the car " .. plate .. " with a key emulator")
end)
```

> [!NOTE]
>
> The emulator only opens the doors: the thief still has to hotwire the car. To know when that happens, see [Player hotwired a vehicle](https://docs.jaksam-scripts.com/vehicles-keys/server/player-hotwired-a-vehicle.md).


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