RedM Natives

GET_VEHICLE_HAS_FLAG

Get vehicle.meta flag by index.

Hash0xD85C9F57
Runtime nameGetVehicleHasFlag
NamespaceCFX
SideClient
NameOfficial
Docs

Signature

bool GET_VEHICLE_HAS_FLAG(Vehicle vehicle, int flagIndex);

Parameters

NameTypeDescription
vehicleVehicle

The vehicle to obtain flags for.

flagIndexint

Flag index.

Returns bool — A boolean for whether the flag is set.### Example```lua local vehicleFlags = { FLAG_SMALL_WORKER = 0, FLAG_BIG = 1, FLAG_NO_BOOT = 2, FLAG_ONLY_DURING_OFFICE_HOURS = 3 -- This is just a example, see fivem-docs to see all flags. } local function getAllVehicleFlags(vehicle) local flags = {} for i = 0, 256 do if GetVehicleHasFlag(vehicle, i) then flags[#flags+1] = i end end return flags end local flagsVehicle = GetVehiclePedIsIn(PlayerPedId(), false) print(getAllVehicleFlags) ``````javascript const VEHICLE_FLAGS = { FLAG_SMALL_WORKER: 0, FLAG_BIG: 1, FLAG_NO_BOOT: 2, FLAG_ONLY_DURING_OFFICE_HOURS: 3 // This is just a example, see fivem-docs to see all flags. }; function getAllVehicleFlags(mVehicle = GetVehiclePedIsIn(PlayerPedId(), false)) { const flags = []; for (let i = 0; i < 204; i++) { if (GetVehicleHasFlag(mVehicle, i)) { flags.push(i); } } return flags; } let flagsVehicle = GetVehiclePedIsIn(PlayerPedId(), false); console.log(getAllVehicleFlags); ```

Description

Cfx.re native reference

Note: Flags are not the same based on your gamebuild. Please see here to see a complete list of all vehicle flags.

Get vehicle.meta flag by index. Useful examples include FLAG_LAW_ENFORCEMENT (31), FLAG_RICH_CAR (36), FLAG_IS_ELECTRIC (43), FLAG_IS_OFFROAD_VEHICLE (48).

Usage

Lua
local retval = GetVehicleHasFlag(vehicle, flagIndex)

-- always works, by hash
local retval = Citizen.InvokeNative(0xd85c9f57, vehicle, flagIndex, Citizen.ReturnResultAnyway())
JavaScript and C#
JavaScript
const retval = GetVehicleHasFlag(vehicle, flagIndex);

// by hash
const retval = Citizen.invokeNative('0xd85c9f57', vehicle, flagIndex, Citizen.returnResultAnyway());
C#
bool retval = Function.Call<bool>((Hash)0xd85c9f57, vehicle, flagIndex);

Sources

Cfx.re native reference

Something wrong or missing? Contribute a verified note — corrections ship through pull requests.