Skip to content

Exports & events

Public API of Cuxial Chipeo: server exports to install, remove, damage, read and move a car's sound system, garage integration, emergency control, routing buckets and the creator hook.

Install the equipment from a workshop script, check it from a garage, read what a car is playing or stop all music from another resource. Every export is server-side. Vehicles are identified by plate; plates are trimmed and upper-cased before comparing. With persist.unowned = 'memory', the equipment of a car without an owner is only found by its plate while that car exists.

Server exports ​

IsRadioInstalled ​

lua
exports.cuxial_chipeo:IsRadioInstalled(plate) --> boolean
lua
if exports.cuxial_chipeo:IsRadioInstalled(plate) then
    print('This car has a sound system')
end

true only if the car has an installed head unit (with the item or with InstallRadio). The stock radio does not count.

InstallRadio ​

Installs the head unit without item, progress bar or distance check.

lua
exports.cuxial_chipeo:InstallRadio(plate, installedBy) --> boolean
ParameterTypeDescription
platestringPlate of the vehicle.
installedBystring?Character identifier of the installer. They can then remove it and mount pieces.

Returns false if the plate is empty or already has a head unit. On a car without an owner with persist.unowned = 'memory', the car must exist in the world.

UninstallRadio ​

lua
exports.cuxial_chipeo:UninstallRadio(plate) --> boolean ok, string? error

Stops its music and removes the head unit. Fails with err_not_installed, or with err_mounts_present while the car still has pieces mounted.

GetSession ​

lua
exports.cuxial_chipeo:GetSession(plate) --> table?

A copy of what the car is playing, or nil. Useful fields: playing, title, url, volume, bass, distance, damaged, heat, pressure, queue, group, bucket and tier ('radio' = stock radio, 'chipeo' = sound system).

lua
local s = exports.cuxial_chipeo:GetSession(plate)
if s and s.playing then
    print(('%s is playing %s'):format(plate, s.title or s.url))
end

GetMounts ​

lua
exports.cuxial_chipeo:GetMounts(plate) --> table[]

Copy of the pieces mounted on the car (empty if none). Each entry: uid, c (piece id from data/components.lua), b (bone), o and r (offset and rotation), open.

SetDamaged ​

lua
exports.cuxial_chipeo:SetDamaged(plate, damaged) --> boolean

Fries (true) or repairs (false) the equipment. Returns false if the car has no head unit.

lua
-- Repair the sound system together with the car
exports.cuxial_chipeo:SetDamaged(plate, false)

MigratePlate ​

lua
exports.cuxial_chipeo:MigratePlate(old, new, veh) --> boolean moved
ParameterTypeDescription
oldstringPrevious plate.
newstringNew plate.
vehnumber?Entity of the car, already with the new plate. If you pass it, its pieces are shown again at once.

Moves the head unit, pieces, USB, damage and Special project from old to new, in the database and in memory, and stops the music that was playing under the old plate. Returns false if the plates are empty or equal, if old has no equipment, or if new already has its own (which is kept).

lua
-- After changing the plate from your script
SetVehicleNumberPlateText(veh, newPlate)
exports.cuxial_chipeo:MigratePlate(oldPlate, newPlate, veh)

PurgePlate ​

lua
exports.cuxial_chipeo:PurgePlate(plate) --> boolean

For a deleted vehicle: stops its music and removes head unit, pieces, USB, damage and Special project from the database. Also returns true if there was nothing to delete, and false if the database fails.

VehicleSpawned ​

lua
exports.cuxial_chipeo:VehicleSpawned(veh, plate)

Tells Cuxial Chipeo that a garage has just spawned a player's car with its final plate: it is treated as an owned car and its pieces are published without waiting to detect it.

SetEmergency / IsEmergency ​

lua
exports.cuxial_chipeo:SetEmergency(on) --> integer stopped
exports.cuxial_chipeo:IsEmergency() --> boolean

Same as /chipeoemergencia: stops and blocks all music (true) or lifts it (false). Returns the number of sessions stopped.

SetPlayerBucket / GetPlayerBucket ​

lua
exports.cuxial_chipeo:SetPlayerBucket(source, bucket) --> boolean
exports.cuxial_chipeo:GetPlayerBucket(source) --> integer

Moves a player to a routing bucket and updates what they hear at once. The resource also detects bucket changes on its own every buckets.pollMs; call this export from your own bucket scripts to skip that wait.

Garage integration ​

Cuxial Chipeo listens to these server events from Cuxial Garages. With that resource nothing has to be done; with another garage script, call the exports above at the same moments.

EventParametersWhat it does
cuxial_garages:server:VehicleSpawnedveh, vehicleId, plateSame as VehicleSpawned.
cuxial_garages:server:PlateChangedveh, old, newSame as MigratePlate.
cuxial_garages:server:VehicleDeletedvehicleId, plateSame as PurgePlate.
cuxial_garages:server:VehicleTransferredvehicleId, plate, citizenidThe equipment stays on the car; whoever installed the head unit loses their rights over it and the new owner is in charge.
my_garage/server.lua
lua
-- When a car is taken out of the garage
exports.cuxial_chipeo:VehicleSpawned(veh, plate)

-- When a car is deleted for good
exports.cuxial_chipeo:PurgePlate(plate)

Creator hook ​

fixed.creators.export lets another resource decide who can create fixed installations:

shared/config.lua
lua
creators = {
    permission = false,
    jobs = {},
    export = { resource = 'my_clubs', name = 'CanBuildSound' },
},
my_clubs/server.lua
lua
exports('CanBuildSound', function(source)
    return IsClubOwner(source) -- your own check, returns boolean
end)

State bags (read only) ​

BagOnContent
chipeoVehicleCurrent session (same shape as GetSession).
chipeoHeatVehicle{ heat, max, pressure }.
chipeoPowerVehicleBattery and voltage state of the electrical system.
chipeoEmergencyGlobalStatetrue while the emergency is active.

Read them, do not write them: the server owns these values and overwrites them.

Item exports ​

The items call client exports with the same name (cuxial_chipeo.chipeo_radio, cuxial_chipeo.usb_8, cuxial_chipeo.chipeo_medusa_l, cuxial_chipeo.chipeo_sub12…). Every piece and electrical part has one: it puts the part in the player's hands. They exist for ox_inventory and are not meant to be called from other resources.

© Cuxial