Exports & API
Core Mechanic exposes the following exports for integration with other scripts.
Client Exports
client
exports['core_mechanic']:getNitro()Returns the current nitro health/level of the player's vehicle. Returns 0 if no nitro is installed.
Returns:
numberExample
lua
local nitroHealth = exports['core_mechanic']:getNitro()
if nitroHealth > 0 then
print('Nitro health:', nitroHealth)
else
print('No nitro installed')
endclient
exports['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:
numberExample
lua
local currentGear = exports['core_mechanic']:getGear()
print('Current gear:', currentGear)client
exports['core_mechanic']:getVehicleParts()Returns all parts (type and health) for the vehicle currently being inspected. Returns nil if no vehicle is open.
Returns:
table | nilExample
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')
endclient
exports['core_mechanic']:getVehiclePlate()Returns the plate of the vehicle currently being inspected. Returns nil if no vehicle is open.
Returns:
string | nilExample
lua
local plate = exports['core_mechanic']:getVehiclePlate()
print('Currently inspecting:', plate)client
exports['core_mechanic']:getVehicleMileage()Returns the current mileage of the vehicle being inspected.
Returns:
numberExample
lua
local mileage = exports['core_mechanic']:getVehicleMileage()
print('Mileage:', mileage)client
exports['core_mechanic']:isInstalling()Returns whether the current vehicle has an active part installation in progress.
Returns:
booleanExample
lua
if exports['core_mechanic']:isInstalling() then
print('Installation in progress!')
endclient
exports['core_mechanic']:getCurrentInstallations()Returns all active installations across all vehicles. Each entry contains partType, part, and repairMode.
Returns:
tableExample
lua
local installations = exports['core_mechanic']:getCurrentInstallations()
for plate, data in pairs(installations) do
print(plate, 'is installing', data.partType, '-', data.part)
endclient
exports['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.
| Parameter | Type | Description |
|---|---|---|
category | string | Part category: engine, transmission, suspension, oil, tires, turbo, nitro, brakes, sparkplugs |
partType | string (optional) | Specific part key (e.g. v8engine, manual_gearbox_rwd). Omit to get all parts in the category. |
Returns:
table | nilExample
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)
endServer Exports
server
exports['core_mechanic']:getVehicleParts(plate, cb)Fetches all parts and mileage for a vehicle by plate from the database. Uses a callback with the results.
| Parameter | Type | Description |
|---|---|---|
plate | string | The vehicle plate to look up |
cb | function | Callback 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)server
exports['core_mechanic']:getVehiclePartsAsync(plate)Synchronous version of getVehicleParts. Returns parts and mileage directly. Must be called from a thread/callback context.
| Parameter | Type | Description |
|---|---|---|
plate | string | The vehicle plate to look up |
Returns:
table | nil, numberExample
lua
local parts, mileage = exports['core_mechanic']:getVehiclePartsAsync('ABC123')
if parts then
print('Engine:', parts.engine.type, 'Health:', parts.engine.health)
endserver
exports['core_mechanic']:getCurrentInstallations()Returns all active installations server-wide. Keyed by plate, each entry contains the installation status.
Returns:
tableExample
lua
local installations = exports['core_mechanic']:getCurrentInstallations()
for plate, status in pairs(installations) do
print('Vehicle', plate, 'has an active installation')
endserver
exports['core_mechanic']:getPartConfig(category, partType)Returns config data for a part category or specific part. Same as the client-side version.
| Parameter | Type | Description |
|---|---|---|
category | string | Part category: engine, transmission, suspension, oil, tires, turbo, nitro, brakes, sparkplugs |
partType | string (optional) | Specific part key. Omit to get all parts in the category. |
Returns:
table | nilExample
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