Skip to content

Developer API

Caner Karaca edited this page Nov 17, 2026 · 6 revisions

💻 Developer API (C-ABI)

ModelExtras v3.1 provides a standard C-ABI export interface compatible with other plugins, scripts, and modding frameworks (C/C++, MoonLoader Lua, CLEO, etc.). The shipped src/ModelExtrasAPI.h contains the authoritative declarations for all 175 exported functions; this page provides an overview of the core API functions and types.


📦 Integration Examples

C / C++

Include ModelExtrasAPI.h in your project or load exported functions dynamically via GetProcAddress() on ModelExtras.asi:

#include "ModelExtrasAPI.h"

// Check if ModelExtras is loaded and verify API version
if (ME_GetAPIVersion() >= 30001) {
    bool lightsOn = ME_GetVehicleLightState(pVeh, ME_HeadLightLeft);
}

MoonLoader (Lua / FFI)

You can directly call exported C-ABI functions in MoonLoader Lua scripts using MoonLoader's built-in module functions and ffi.cast:

local ffi = require("ffi")

-- Check if ModelExtras is loaded in the game process
if getModuleHandle("ModelExtras.asi") ~= 0 then
    -- Resolve exported functions directly from the running module
    local ME_GetAPIVersion = ffi.cast("int (__cdecl *)()", getModuleProcAddress("ModelExtras.asi", "ME_GetAPIVersion"))
    local ME_SetIndicatorState = ffi.cast("void (__cdecl *)(void*, int)", getModuleProcAddress("ModelExtras.asi", "ME_SetIndicatorState"))
    local ME_TriggerBackfire = ffi.cast("void (__cdecl *)(void*, bool)", getModuleProcAddress("ModelExtras.asi", "ME_TriggerBackfire"))

    -- Verify API version compatibility (30001 = v3.1)
    if ME_GetAPIVersion and ME_GetAPIVersion() >= 30001 then
        -- Example: Control lights on the player's current vehicle
        if isCharInAnyCar(PLAYER_PED) then
            local carHandle = storeCarCharIsInPed(PLAYER_PED)
            local pVeh = ffi.cast("void*", getCarPointer(carHandle))

            -- Turn on hazard lights (3 = ME_IndicatorBoth)
            ME_SetIndicatorState(pVeh, 3)

            -- Trigger exhaust backfire flame
            ME_TriggerBackfire(pVeh, true)
        end
    end
end

🛠️ API Reference

1. Core & Lifecycle Management

Function Description
int ME_GetAPIVersion() Returns API interface version code (e.g. 30001).
int ME_GetVersion() Returns ModelExtras version number (e.g. 30100 for v3.1).
bool ME_IsFeatureAvail(ME_FeatureID featureId) Returns whether the feature's configuration toggle is active.
bool ME_IsFeatureEnabled(ME_FeatureID featureId) Returns whether the feature is actively enabled.
void ME_Reload() Triggers hot-reload of all configurations, audio, and vehicle data.
void ME_ReloadVehicle(CVehicle *pVeh) Reloads configuration data specifically for pVeh.

2. Vehicle Lights & Indicators

Function Description
bool ME_GetVehicleLightState(CVehicle *pVeh, ME_LightID lightId) Returns whether a specific light is currently turned on.
void ME_SetVehicleLightState(CVehicle *pVeh, ME_LightID lightId, bool state) Sets the state of a light dummy/material.
bool ME_IsLightAvailable(CVehicle *pVeh, ME_LightID lightId) Returns true if the vehicle has matching nodes/materials for this light type.
int ME_GetIndicatorState(CVehicle *pVeh) Returns current indicator state (0: Off, 1: Left, 2: Right, 3: Hazard).
void ME_SetIndicatorState(CVehicle *pVeh, int state) Sets turn indicator state (ME_IndicatorOff, ME_IndicatorLeft, ME_IndicatorRight, ME_IndicatorBoth).
int ME_GetLightOverride(CVehicle *pVeh) Returns light override mode (0: None, 1: Force Off, 2: Force On).
void ME_SetLightOverride(CVehicle *pVeh, int overrideMode) Forces vehicle headlights/taillights state.
bool ME_GetFogLights(CVehicle *pVeh) Returns whether fog lights are currently active.
void ME_SetFogLights(CVehicle *pVeh, bool on) Toggles vehicle fog lights on or off.
bool ME_GetHighBeam(CVehicle *pVeh) Returns whether high beams (long lights) are currently active.
void ME_SetHighBeam(CVehicle *pVeh, bool on) Toggles high-beam headlights on or off.
bool ME_ArePopUpHeadlightsOpen(CVehicle *pVeh) Returns true if retractable headlights have fully opened.
bool ME_HasPopUpHeadlights(CVehicle *pVeh) Returns true if the vehicle model is equipped with pop-up headlights.

3. Sirens & Emergency Lighting

Function Description
int ME_GetSirenStateCount(CVehicle *pVeh) Returns the number of defined siren pattern states for this vehicle.
int ME_GetSirenStateCountByModel(int modelIndex) Returns siren state count by vehicle model ID.
int ME_GetSirenState(CVehicle *pVeh) Returns the current active siren pattern stage index.
bool ME_SetSirenState(CVehicle *pVeh, int state) Sets active siren stage pattern.
int ME_GetSirenSoundMode(CVehicle *pVeh) Returns current active audio tone index (0 to 8, or -1 if unavailable).
bool ME_SetSirenSoundMode(CVehicle *pVeh, int soundMode) Changes the siren sound tone index (0 to 8).
bool ME_GetSirenMute(CVehicle *pVeh) Returns whether siren sound playback is muted.
void ME_SetSirenMute(CVehicle *pVeh, bool mute) Mutes or unmutes siren audio playback.
bool ME_IsSirenActive(CVehicle *pVeh) Returns true if emergency lighting or sirens are active.
bool ME_IsSirenVehicle(CVehicle *pVeh) Returns true if vehicle model has siren configuration.
bool ME_IsCustomSirenPlaying(CVehicle *pVeh) Returns true if 3D custom siren audio stream is currently playing.

4. HD License Plates

Function Description
bool ME_GetPlateText(CVehicle *pVeh, char *outBuffer, int maxLen) Reads custom license plate string into the buffer.
bool ME_SetPlateText(CVehicle *pVeh, const char *text) Sets a custom plate text string and regenerates the plate texture.
bool ME_HasCustomPlate(CVehicle *pVeh) Returns true if vehicle is using custom HD license plate rendering.
int ME_GetPlateCity(CVehicle *pVeh) Returns the current plate regional background city index.
void ME_SetPlateCity(CVehicle *pVeh, int cityId) Changes the plate regional background city texture.

5. Carcols & Vehicle Colors

Function Description
bool ME_GetVehicleColors(CVehicle *pVeh, ME_Color *col1, ME_Color *col2, ME_Color *col3, ME_Color *col4) Retrieves all 4 custom RGBA colors.
bool ME_SetVehicleColors(CVehicle *pVeh, ME_Color col1, ME_Color col2, ME_Color col3, ME_Color col4) Sets all 4 custom RGBA colors.
int ME_GetCarcolVariationCount(int modelIndex) Returns number of custom carcol color variation presets for the model.
int ME_GetCarcolVariation(CVehicle *pVeh) Returns current carcol variation index.
bool ME_SetCarcolVariation(CVehicle *pVeh, int variationIndex) Applies a specific color variation index.

6. Exhausts, Nitro & Backfire

Function Description
unsigned int ME_GetExhaustCount(CVehicle *pVeh) Returns the number of active exhaust points on the vehicle.
ME_ExhaustInfo ME_GetExhaustData(CVehicle *pVeh, int index) Retrieves exhaust particle size, speed, lifetime, and color data.
void ME_SetExhaustData(CVehicle *pVeh, int index, ME_ExhaustInfo &data) Updates exhaust particle properties at runtime.
void ME_TriggerNitro(CVehicle *pVeh, bool enable) Activates / deactivates NOS exhaust flames and dynamic point lights.
bool ME_IsNitroFiring(CVehicle *pVeh) Returns true if NOS boost exhaust flame is currently active.
void ME_TriggerBackfire(CVehicle *pVeh, bool bPlaySound) Manually triggers a single exhaust flame pop-and-bang effect.
void ME_TriggerBackfireBurst(CVehicle *pVeh, bool bPlaySound) Triggers a multi-burst backfire pop sequence.
bool ME_IsBackfireActive(CVehicle *pVeh) Returns true if backfire flames are actively discharging.

7. Dashboard Gauges, LEDs & Clock

Function Description
float ME_GetVehicleMileage(CVehicle *pVeh) Returns vehicle total accumulated mileage in kilometers.
void ME_SetVehicleMileage(CVehicle *pVeh, float mileageKm) Sets total vehicle odometer mileage.
float ME_GetSpeedometerValue(CVehicle *pVeh) Returns current animated speedometer gauge reading.
float ME_GetRPMValue(CVehicle *pVeh) Returns current animated RPM gauge reading.
float ME_GetTurboValue(CVehicle *pVeh) Returns current turbo boost gauge reading.
int ME_GetGearIndicatorValue(CVehicle *pVeh) Returns current transmission gear display value.
bool ME_GetDashboardLEDState(CVehicle *pVeh, ME_LightID ledId) Checks state of dashboard warning / status LED indicators.
void ME_SetDashboardLEDState(CVehicle *pVeh, ME_LightID ledId, bool state) Manually sets dashboard indicator LED state.
bool ME_IsClockAvailable(CVehicle *pVeh) Returns whether vehicle dashboard features an active digital clock.

8. Dirt FX & Texture Remapping

Function Description
float ME_GetDirtLevel(CVehicle *pVeh) Returns current vehicle dirtiness level (0.0 = clean, 15.0 = max dirt).
void ME_SetDirtLevel(CVehicle *pVeh, float dirtLevel) Sets vehicle dirtiness level and updates texture blending.
int ME_GetRemapIndex(CVehicle *pVeh) Returns active texture remapping index.
void ME_SetRemapIndex(CVehicle *pVeh, int remapIndex) Changes active texture remapping livery / variation.

9. Dynamic Animations & Features

Function Description
bool ME_IsRoofOpen(CVehicle *pVeh) Returns convertible roof open/closed state.
void ME_SetRoofOpen(CVehicle *pVeh, bool open) Controls convertible roof animation.
float ME_GetSpoilerAngle(CVehicle *pVeh, int spoilerIndex) Returns current angle of active aerodynamic spoiler.
void ME_SetSpoilerAngle(CVehicle *pVeh, int spoilerIndex, float angle) Manually sets angle of active spoiler.
bool ME_IsRollbackBedExpanded(CVehicle *pVeh) Returns whether tow truck rollback bed is extended.
void ME_SetRollbackBedExpanded(CVehicle *pVeh, bool expanded) Extends or retracts rollback recovery bed.
bool ME_IsSpotlightActive(CVehicle *pVeh) Returns whether police/utility spotlight beam is active.
void ME_SetSpotlightActive(CVehicle *pVeh, bool active) Toggles spotlight illumination.
bool ME_HasSlideDoors(CVehicle *pVeh) Returns true if vehicle model has animated sliding doors.
bool ME_HasRotateDoors(CVehicle *pVeh) Returns true if vehicle model has scissor/gullwing doors.
bool ME_HasWheelHubs(CVehicle *pVeh) Returns true if vehicle model has custom rotating wheel hubs.
bool ME_HasAnimatedChain(CVehicle *pVeh) Returns true if bike model has an animated drive chain.
int ME_GetPedVariationCount(int modelIndex) Returns number of PedCols color variations for a ped model.

10. Neon / Underglow

Function Description
bool ME_HasNeonData(int modelIndex) Returns true if the vehicle model defines a "neon" configuration.
bool ME_IsVehicleNeonActive(CVehicle *pVeh) Returns whether neon underglow is currently active and illuminating for the vehicle.

11. JSONC Configuration Query API

External tools and scripts can query loaded vehicle JSONC configurations without parsing files manually:

Function Description
bool ME_HasModelData(int modelIndex) Checks if ModelExtras configuration data is loaded for the model.
bool ME_GetModelMetadata(...) Reads author, desc, creation date, and minimum version from metadata.
bool ME_IsModLoaderDataEnabled() Returns whether ModLoader subfolder scanning is enabled (ModLoaderData = 1).
bool ME_GetGlobalLightInertia(int modelIndex, float *outInertia) Reads global lighting halogen inertia value.
bool ME_GetLightDummyConfig(...) Reads corona, shadow, pointlight, and inertia settings for a dummy.
bool ME_GetLightShadowOffset(...) Reads 2D ground shadow displacement offset (outOffsetX, outOffsetY).

📑 Type Enums & Structs

ME_FeatureID

enum ME_FeatureID {
    ME_TextureRemapper,
    ME_REMOVED_NULL,
    ME_AnimatedBrakes,
    ME_AnimatedClutch,
    ME_AnimatedGearLever,
    ME_RotatingHandleBar,
    ME_AnimatedChain,
    ME_AnimatedDoors,
    ME_AnimatedGasMeter,
    ME_AnimatedGearMeter,
    ME_AnimatedOdoMeter,
    ME_AnimatedRpmMeter,
    ME_AnimatedSpeedMeter,
    ME_AnimatedSpoiler,
    ME_AnimatedTurboMeter,
    ME_BackfireEffect,
    ME_DirtFX,
    ME_HDLicensePlate,
    ME_IVFCarcols,
    ME_RotatingSteeringWheel,
    ME_RotatingWheelHubs,
    ME_StandardLights,
    ME_SirenLights,
    ME_SoundEffects,
    ME_SpotLights,
    ME_BodyStateVariation,
    ME_CustomSounds,
    ME_GangHands,
    ME_PedCols,
    ME_ExhaustFx,
    ME_ConvertibleRoof,
    ME_DashboardLED,
    ME_RollbackBed,
    ME_Clock,
    ME_ExtraWheels,
    ME_Neon,
    ME_FeatureCount
};

ME_LightID

enum ME_LightID {
    ME_HeadLightLeft, ME_HeadLightRight,
    ME_TailLightLeft, ME_TailLightRight,
    ME_ReverseLightLeft, ME_ReverseLightRight,
    ME_BrakeLightLeft, ME_BrakeLightRight,
    ME_HighBeamLeft, ME_HighBeamRight,
    ME_AllDayLight, ME_DayLight, ME_NightLight,
    ME_FogLightLeft, ME_FogLightRight,
    ME_SideLightLeft, ME_SideLightRight,
    ME_STTLightLeft, ME_STTLightRight,
    ME_NABrakeLightLeft, ME_NABrakeLightRight,
    ME_SpotLight, ME_StrobeLight, ME_SirenLight,
    ME_IndicatorLightLeftFront, ME_IndicatorLightLeftMiddle, ME_IndicatorLightLeftRear,
    ME_IndicatorLightRightFront, ME_IndicatorLightRightMiddle, ME_IndicatorLightRightRear,
    ME_EngineOnLed, ME_EngineBrokenLed, ME_FogLightLed, ME_HighBeamLed, ME_LowBeamLed,
    ME_IndicatorLeftLed, ME_IndicatorRightLed, ME_SirenLed,
    ME_BootOpenLed, ME_BonnetOpenLed, ME_DoorOpenLed, ME_RoofOpenLed,
    ME_LightCount
};

ME_IndicatorState

enum ME_IndicatorState {
    ME_IndicatorOff   = 0,
    ME_IndicatorLeft  = 1,
    ME_IndicatorRight = 2,
    ME_IndicatorBoth  = 3
};

ME_LightOverride

enum ME_LightOverride {
    ME_LightOverrideNone     = 0,
    ME_LightOverrideForceOff = 1,
    ME_LightOverrideForceOn  = 2
};

Clone this wiki locally