Skip to content

Exports & API

Core Mechanic exposes the following exports for integration with other scripts.

Client Exports

clientexports['core_mechanic']:getNitro()

Returns the current nitro health/level of the player's vehicle. Returns 0 if no nitro is installed.

Returns: number
Example
lua
local nitroHealth = exports['core_mechanic']:getNitro()
if nitroHealth > 0 then
    print('Nitro health:', nitroHealth)
else
    print('No nitro installed')
end
clientexports['core_mechanic']:getGear()

Returns the current gear the player's vehicle is in. Used for manual transmission integration with HUD scripts or other displays.

Returns: number
Example
lua
local currentGear = exports['core_mechanic']:getGear()
print('Current gear:', currentGear)
clientexports['core_mechanic']:getVehicleParts()

Returns all parts (type and health) for the vehicle currently being inspected. Returns nil if no vehicle is open.

Returns: table | nil
Example
lua
local parts = exports['core_mechanic']:getVehicleParts()
if parts then
    print('Engine:', parts.engine.type, 'Health:', parts.engine.health)
    print('Turbo:', parts.turbo and parts.turbo.type or 'None')
end
clientexports['core_mechanic']:getVehiclePlate()

Returns the plate of the vehicle currently being inspected. Returns nil if no vehicle is open.

Returns: string | nil
Example
lua
local plate = exports['core_mechanic']:getVehiclePlate()
print('Currently inspecting:', plate)
clientexports['core_mechanic']:getVehicleMileage()

Returns the current mileage of the vehicle being inspected.

Returns: number
Example
lua
local mileage = exports['core_mechanic']:getVehicleMileage()
print('Mileage:', mileage)
clientexports['core_mechanic']:isInstalling()

Returns whether the current vehicle has an active part installation in progress.

Returns: boolean
Example
lua
if exports['core_mechanic']:isInstalling() then
    print('Installation in progress!')
end
clientexports['core_mechanic']:getCurrentInstallations()

Returns all active installations across all vehicles. Each entry contains partType, part, and repairMode.

Returns: table
Example
lua
local installations = exports['core_mechanic']:getCurrentInstallations()
for plate, data in pairs(installations) do
    print(plate, 'is installing', data.partType, '-', data.part)
end
clientexports['core_mechanic']:getPartConfig(category, partType)

Returns config data (power, durability, price, etc.) for a part category or specific part. Pass only category to get all parts in that category.

ParameterTypeDescription
categorystringPart category: engine, transmission, suspension, oil, tires, turbo, nitro, brakes, sparkplugs
partTypestring (optional)Specific part key (e.g. v8engine, manual_gearbox_rwd). Omit to get all parts in the category.
Returns: table | nil
Example
lua
-- Get a specific part's config
local config = exports['core_mechanic']:getPartConfig('engine', 'v8engine')
print('Power:', config.power, 'Durability:', config.durability)

-- Get all engines
local allEngines = exports['core_mechanic']:getPartConfig('engine')
for key, engine in pairs(allEngines) do
    print(key, engine.label, engine.power)
end

Server Exports

serverexports['core_mechanic']:getVehicleParts(plate, cb)

Fetches all parts and mileage for a vehicle by plate from the database. Uses a callback with the results.

ParameterTypeDescription
platestringThe vehicle plate to look up
cbfunctionCallback receiving (parts, mileage). Parts is nil if not found.
Returns: void (results via callback)
Example
lua
exports['core_mechanic']:getVehicleParts('ABC123', function(parts, mileage)
    if parts then
        print('Engine:', parts.engine.type)
        print('Mileage:', mileage)
    end
end)
serverexports['core_mechanic']:getVehiclePartsAsync(plate)

Synchronous version of getVehicleParts. Returns parts and mileage directly. Must be called from a thread/callback context.

ParameterTypeDescription
platestringThe vehicle plate to look up
Returns: table | nil, number
Example
lua
local parts, mileage = exports['core_mechanic']:getVehiclePartsAsync('ABC123')
if parts then
    print('Engine:', parts.engine.type, 'Health:', parts.engine.health)
end
serverexports['core_mechanic']:getCurrentInstallations()

Returns all active installations server-wide. Keyed by plate, each entry contains the installation status.

Returns: table
Example
lua
local installations = exports['core_mechanic']:getCurrentInstallations()
for plate, status in pairs(installations) do
    print('Vehicle', plate, 'has an active installation')
end
serverexports['core_mechanic']:getPartConfig(category, partType)

Returns config data for a part category or specific part. Same as the client-side version.

ParameterTypeDescription
categorystringPart category: engine, transmission, suspension, oil, tires, turbo, nitro, brakes, sparkplugs
partTypestring (optional)Specific part key. Omit to get all parts in the category.
Returns: table | nil
Example
lua
-- Calculate a vehicle's total power rating
local parts, _ = exports['core_mechanic']:getVehiclePartsAsync('ABC123')
if parts then
    local totalPower = 0
    local engineCfg = exports['core_mechanic']:getPartConfig('engine', parts.engine.type)
    local turboCfg = parts.turbo and parts.turbo.type and exports['core_mechanic']:getPartConfig('turbo', parts.turbo.type)

    totalPower = totalPower + (engineCfg and engineCfg.power or 0)
    totalPower = totalPower + (turboCfg and turboCfg.power or 0)
    print('Total power:', totalPower)
end