Exports & Events

HZ-CarControl exposes client exports and events to allow integration with your custom scripts.


Client Exports

isMenuOpen

Check if the CarControl menu is currently open.

local isOpen = exports['hz_carcontrol']:isMenuOpen()

Return:
  • boolean: true if the menu is open, false otherwise
Example:

-- Prevent another NUI from opening if CarControl is active
if exports['hz_carcontrol']:isMenuOpen() then
    return
end


openMenu

Open the CarControl menu programmatically.

exports['hz_carcontrol']:openMenu()

The player must be in a vehicle for the menu to open. If not, a notification will be shown.
Example:

-- Open CarControl from another script
RegisterCommand('veh', function()
    exports['hz_carcontrol']:openMenu()
end)


closeMenu

Close the CarControl menu programmatically.

exports['hz_carcontrol']:closeMenu()

Example:

-- Close menu when entering a specific zone
AddEventHandler('myzone:entered', function()
    exports['hz_carcontrol']:closeMenu()
end)


getCurrentVehicle

Get the current vehicle entity handle.

local vehicle = exports['hz_carcontrol']:getCurrentVehicle()

Return:
  • entity or nil: Vehicle entity handle, or nil if no vehicle is tracked
Example:

local veh = exports['hz_carcontrol']:getCurrentVehicle()
if veh and DoesEntityExist(veh) then
    print('Current vehicle: ' .. GetDisplayNameFromVehicleModel(GetEntityModel(veh)))
end


isCruiseActive

Check if cruise control is currently active.

local active = exports['hz_carcontrol']:isCruiseActive()

Return:
  • boolean: true if cruise control is engaged

getCruiseSpeed

Get the current cruise control speed.

local speed = exports['hz_carcontrol']:getCruiseSpeed()

Return:
  • number: Current cruise speed in km/h (0 if inactive)
Example:

-- Display cruise info in a HUD
if exports['hz_carcontrol']:isCruiseActive() then
    local speed = exports['hz_carcontrol']:getCruiseSpeed()
    DrawText('CRUISE: ' .. speed .. ' km/h')
end


isLimiterActive

Check if the speed limiter is currently active.

local active = exports['hz_carcontrol']:isLimiterActive()

Return:
  • boolean: true if the speed limiter is engaged

getLimiterSpeed

Get the current speed limiter value.

local speed = exports['hz_carcontrol']:getLimiterSpeed()

Return:
  • number: Current limiter speed in km/h (0 if inactive)

Events

Server → Client

HZ-CarControl:openMenu

Force open the menu on a specific player.

-- Server
TriggerClientEvent('hz_carcontrol:openMenu', targetPlayerId)


HZ-CarControl:closeMenu

Force close the menu on a specific player.

-- Server
TriggerClientEvent('hz_carcontrol:closeMenu', targetPlayerId)


HZ-CarControl:notify

Send a notification to a player through the CarControl bridge.

-- Server
TriggerClientEvent('hz_carcontrol:notify', targetPlayerId, 'Message text', 'info')

Parameters:
  • message (string): Notification text
  • type (string): 'info', 'success', 'error'

Client → Server

HZ-CarControl:saveNeonColor

Triggered when a player changes a neon color (if SaveColor is enabled).

-- Server
RegisterNetEvent('hz_carcontrol:saveNeonColor', function(plate, r, g, b)
    local src = source
    print('Player ' .. src .. ' set neon color on plate ' .. plate)
end)


HZ-CarControl:logAction

Triggered on various player actions (only when Config.Debug = true).

-- Server
RegisterNetEvent('hz_carcontrol:logAction', function(action, data)
    local src = source
    print('Player ' .. src .. ' — ' .. action)
end)


Integration Examples

Disable Cruise Control in a Zone

-- Client: disable cruise when entering a no-speed zone
Citizen.CreateThread(function()
    while true do
        Citizen.Wait(1000)
        local coords = GetEntityCoords(PlayerPedId())

        if #(coords - noSpeedZone) < 50.0 then
            if exports['hz_carcontrol']:isCruiseActive() then
                exports['hz_carcontrol']:closeMenu()
                -- Cruise will auto-disengage when menu closes
            end
        end
    end
end)

Display CarControl State on External HUD

-- Client: poll cruise/limiter state for a custom HUD
Citizen.CreateThread(function()
    while true do
        Citizen.Wait(500)

        local cruiseActive = exports['hz_carcontrol']:isCruiseActive()
        local cruiseSpeed  = exports['hz_carcontrol']:getCruiseSpeed()
        local limiterActive = exports['hz_carcontrol']:isLimiterActive()
        local limiterSpeed  = exports['hz_carcontrol']:getLimiterSpeed()

        SendNUIMessage({
            action = 'updateDrivingHUD',
            cruise = cruiseActive and cruiseSpeed or nil,
            limiter = limiterActive and limiterSpeed or nil,
        })
    end
end)


Need help integrating these exports? Join our Discord and open a ticket in #support!