Skip to main content

Opening Method

How players open Carplay — chat command, keybind, or inventory item.

This section

Opening Method

Carplay V2 supports three mutually exclusive opening methods: command, keybind, or inventory item. When UseItem = true, command and keybind are automatically disabled.

Options

OptionDefaultDescription
Config.Command"carplay"Chat command (set false to disable)
Config.EnableKeyfalseEnable keybind alongside command
Config.DefaultKey"F10"Default key (player can rebind in FiveM settings)
Config.BindingDescription"Open Carplay"Description shown in keybind settings
Config.UseItemfalseUse inventory item instead (disables command + key)
Config.ItemName"carplay"Item name in inventory
Config.InventorySystem"auto"Override auto-detection. Options: "auto", "ox", "qs", "codem", "esx", "qb", "qbox"

Method 1 — Chat Command

The default. Players type /carplay in chat while in the driver seat.

lua
Config.Command = "carplay"
Config.UseItem = false

Method 2 — Keybind

Add a keybind so players can rebind to whatever key they prefer:

lua
Config.Command = "carplay" -- still works as a fallback
Config.EnableKey = true
Config.DefaultKey = "F10"
Config.BindingDescription = "Open Carplay" -- shows up under FiveM keybind settings
Config.UseItem = false

Once started, FiveM registers the keybind. Players can rebind it under FiveM Settings → Keybinds → FiveM in the pause menu.

Method 3 — Inventory Item

For roleplay servers that want Carplay to be a physical item (often paired with Config.Screen.requiredToUse = true):

lua
Config.UseItem = true
Config.ItemName = "carplay"

When UseItem = true:

  • Command and keybind are automatically disabled
  • Players need the item in their inventory to open the tablet
  • The script auto-registers the usable item on resource start (one of ox_inventory export, ESX.RegisterUsableItem, QBCore.Functions.CreateUseableItem, etc.)

Inventory Provider Auto-Detection

The script detects which inventory you're using in this priority:

  1. Config.InventorySystem override (if not "auto")
  2. ox_inventory if started
  3. qs-inventory if started
  4. codem-inventory if started
  5. Framework fallback (ESX/QBCore/QBox getInventoryItem etc.)

Override only if auto-detection picks the wrong one or if you have multiple inventories installed for testing.

ox_inventory Item Registration

Add to ox_inventory/data/items.lua:

lua
['carplay'] = {
label = 'Carplay',
weight = 100,
server = {
export = 'code9_carplayv2.carplayItem'
},
},

The export code9_carplayv2.carplayItem is defined in server/open.lua and triggers c9:carplay2:useItem on the player's client.

qs-inventory / codem-inventory

These auto-register via CreateUsableItem exports — just make sure your item exists in their items list.

ESX / QBCore / QBox

These auto-register via the framework's usable item API on resource start. Make sure the item exists in your items table or qb-core/shared/items.lua.

The same auto/override pattern is used for mileage:

lua
Config.MileageSystem = "auto" -- "auto", "internal", "jg-vehiclemileage", "cd_garage"
  • "auto" priority: jg-vehiclemileage > cd_garage > internal
  • "internal" uses code9_carplay2_mileage table (no external dependency)
  • "jg-vehiclemileage" reads via exports['jg-vehiclemileage']
  • "cd_garage" reads via exports['cd_garage']:GetVehicleMileage

See Database for the internal mileage tracking detail.