Exports
This page documents the available exports for interacting with the kartik-mechanic system from other scripts.
For detailed information on how impacts affect part wear, see the Damage System documentation.
Client-Side Exports
GetMileage
Returns the current accumulated mileage of the player's vehicle in the current unit (Miles or KM).
local mileage = exports['kartik-mechanic']:GetMileage()
print("Current Mileage: " .. mileage)ToggleHUD
Toggles the visibility of the mechanic HUD elements (Mileage, Gears, Nitro).
-- Hide HUD
exports['kartik-mechanic']:ToggleHUD(false)
-- Show HUD
exports['kartik-mechanic']:ToggleHUD(true)OpenTuningTablet
Opens the Tuning Chip interface for the current vehicle (requires a Tuning Chip to be installed).
exports['kartik-mechanic']:OpenTuningTablet()getNitrousLevel
Returns the current nitrous level (count) for a vehicle.
local level = exports['kartik-mechanic']:getNitrousLevel(vehicle)refillNitrous
Refills the nitrous for a vehicle. If amount is provided, it adds that amount to the current count (capped at max). If amount is omitted, it refills to 100%.
-- Refill to 100%
exports['kartik-mechanic']:refillNitrous(vehicle)
-- Add 50 units
exports['kartik-mechanic']:refillNitrous(vehicle, 50)OpenAdminCustoms
Opens the admin customs customization interface for the player's current vehicle. This menu bypasses job restrictions and upgrades are completely free.
exports['kartik-mechanic']:OpenAdminCustoms()OpenCustoms
General wrapper to open the customs menu with custom configurations.
exports['kartik-mechanic']:OpenCustoms(shopId, extrasOnly, isAdmin)- shopId (string/nil): Shop configuration ID to use.
- extrasOnly (boolean): If true, only opens liveries/extras.
- isAdmin (boolean): If true, all upgrades are free and job checks are bypassed.
ToggleSeatbelt
Buckles or unbuckles the player's seatbelt (or harness, if one is fitted). Use this instead of the built-in keybind when another resource already owns the seatbelt key, set Config.EnableRegisterKeyMapping = false and call this from your own binding.
exports['kartik-mechanic']:ToggleSeatbelt()IsSeatbeltOn
Returns true if the player currently has their seatbelt buckled.
if exports['kartik-mechanic']:IsSeatbeltOn() then
print("Buckled up")
endHasHarness
Returns true if the vehicle the player is in has a racing harness installed.
local harness = exports['kartik-mechanic']:HasHarness()IsVehicleIgnored
Returns true if the vehicle has been exempted from wear, damage and mileage (see the server-side SetVehicleIgnored).
if exports['kartik-mechanic']:IsVehicleIgnored(vehicle) then
print("Vehicle is ignored by the mechanic system")
endServer-Side Exports
GetVehicleMileage
Retrieves the mileage for a specific vehicle plate. Use a callback to receive the value.
exports['kartik-mechanic']:GetVehicleMileage('ABC 123', function(mileage)
print("Vehicle Mileage: " .. mileage)
end)SetVehicleMileage
Updates the mileage for a specific vehicle plate.
exports['kartik-mechanic']:SetVehicleMileage('ABC 123', 5000.0)GetVehiclePartsWear
Retrieves current wear levels (0.0 to 1.0) for vehicle parts.
exports['kartik-mechanic']:GetVehiclePartsWear('ABC 123', function(wearData)
if wearData then
print("Brake Wear: " .. wearData.brakeWear)
print("Clutch Wear: " .. wearData.clutchWear)
end
end)SetVehiclePartsWear
Updates wear levels for vehicle parts.
exports['kartik-mechanic']:SetVehiclePartsWear('ABC 123', {
brakeWear = 0.1,
clutchWear = 0.5
})GetVehicleLastPartsChange
Retrieves the mileage at which parts were last replaced.
exports['kartik-mechanic']:GetVehicleLastPartsChange('ABC 123', function(history)
if history then
print("Last Oil Change: " .. history.oilChange)
end
end)LogTransaction
Logs a shop transaction to the database for the management history.
exports['kartik-mechanic']:LogTransaction(shopId, customerId, employeeId, cost, {
label = "Engine Repair",
type = "repair"
})GetShopData
Retrieves configuration and balance data for a specific mechanic shop.
local shopData = exports['kartik-mechanic']:GetShopData('bennys')RefillNitrous
Server-side export to refill nitrous for a vehicle by its network ID.
-- Refill to 100%
exports['kartik-mechanic']:RefillNitrous(netId)
-- Add 50 units
exports['kartik-mechanic']:RefillNitrous(netId, 50)SetVehicleIgnored
Exempts a single vehicle from wear, crash damage and mileage. Useful for derbies, races, events and rentals where you don't want to whitelist the whole model. The flag only affects that vehicle, syncs to all players and clears automatically when the vehicle is deleted.
-- Ignore the vehicle
exports['kartik-mechanic']:SetVehicleIgnored(netIdOrEntity, true)
-- Stop ignoring the vehicle
exports['kartik-mechanic']:SetVehicleIgnored(netIdOrEntity, false)- netIdOrEntity (number): Network ID or server entity handle of the vehicle.
- Returns (boolean):
trueif the vehicle was found and updated.
IsVehicleIgnored
Returns true if the vehicle is currently ignored.
local ignored = exports['kartik-mechanic']:IsVehicleIgnored(netIdOrEntity)