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:trueif the menu is open,falseotherwise
-- 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()
-- 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:
entityornil: Vehicle entity handle, ornilif no vehicle is tracked
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:trueif 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)
-- 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:trueif 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 texttype(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)
