Native SetVehicleNitroEnabled isn't working on forced game versions

Hey i just found out that the native “SetVehicleNitroEnabled” isn’t working for forced game versions (i use b2189). I tested it on production and canary version. The FXServer is on the latest recommended build (4394).

When setting the native on a vehicle it doesn’t work right. The vehicle isn’t boosting or removing nitro from the nitro-bar (its a yellow bar under the map). The native works like it should when removing the forced game version.

To reproduce this, you just have to set this native on your vehicle and forcing your server to a newer game version:

local ped = GetPlayerPed(-1)
local playerVeh = GetVehiclePedIsIn(ped, false)
SetVehicleNitroEnabled(playerVeh, 1, 0)

If you’re trying to enable nitro on a non arena war vehicles, you have to request nitro ptfx asset or a vehicle model that using it. Have you tested it with arena was vehicles or did you requested required assets?

1 Like

Tested it with arena war vehicles. The only difference are the ptfx on the exhaust (flames). But still no nitro boost. Btw. i just found out that after 2060 you have to set some new paramenters so it looks like this

SetVehicleNitroEnabled(playerVeh, 1, 0, 1, 0, 0)

When setting this parameters, all vehicles have the flames from the dlc. But still no boost for it.

You can use this

Tested with game build 2189, server build 4394

Thats a workaround but it’s not the nitro native i want to use.

Today i modified a addon vehicle with

CMOD_BOS_1, CMOD_BOS_2, CMOD_BOS_3 - mod kits
and FLAG_HAS_NITROUS_MOD

if i put Air Filter mod with vMenu, nitrous works fine.

if i put nitrous with SetVehicleNitroEnabled(veh, true, 1.0, 10.0, 100.0, false)
stop work…
if anyone find a way to get it work, please share.

Very good to know thx. I hope the native will be fixed soon

This native is not broken. You’re using it in a wrong way. As you can see from the native reference it was dramatically changed in build 2060 of GTA5. FiveM has nothing to do about it. Read decompiled scripts for b2060+ in order to understand how to use it properly. There’s nothing to fix.

Found this code

public static void SetNitroEnabled(this Vehicle vehicle, bool toggle, float level = 2.5f, float power = 1.1f, float rechargeTime = 4f, bool disableSound = false)
        {
            if (!Function.Call<bool>(GTA.Native.Hash.HAS_NAMED_PTFX_ASSET_LOADED, "veh_xs_vehicle_mods"))
                Function.Call(GTA.Native.Hash.REQUEST_NAMED_PTFX_ASSET, "veh_xs_vehicle_mods");

            if (toggle == true)
            {
                //if (!Function.Call<bool>(GTA.Native.Hash._0x36AD3E690DA5ACEB, "CrossLine")) //ANIMPOSTFX_IS_RUNNING                
                //    Function.Call(GTA.Native.Hash._0x2206BF9A37B7F724, "CrossLine", 0, true); //ANIMPOSTFX_PLAY
                Function.Call(Hash(0xC8E9B6B71B8E660D), vehicle, toggle, level, power, rechargeTime, disableSound); //_SET_VEHICLE_NITRO_ENABLED           
            } 
            if (toggle == false)
            {
                //if (Function.Call<bool>(GTA.Native.Hash._0x36AD3E690DA5ACEB, "CrossLine")) //ANIMPOSTFX_IS_RUNNING               
                //    Function.Call(GTA.Native.Hash._0x068E835A1D0DC0E3, "CrossLine"); //ANIMPOSTFX_STOP
                Function.Call(Hash(0xC8E9B6B71B8E660D), vehicle, toggle, level, power, rechargeTime, disableSound); //_SET_VEHICLE_NITRO_ENABLED
            }
        }
static public unsafe void SetNitroOn(Vehicle v)
        {
            var vehHandle = v.MemoryAddress;
            IntPtr address = (IntPtr)FindPattern("\x38\x8B\x00\x00\x00\x00\x74\x04\xB1\x01\xEB\x58", "xx????xxxxxx");
            //\x38\x8B\x00\x00\x00\x00\x74\x04\xB1\x01\xEB\x58
            //\x8A\x83\x00\x00\x00\x00\x84\xC0\x75\x09\x40\x84\xFF
            if (address != null)
            {


                var g_vehNitroEnabledOffset = *(int*)(address + 2);
                bool d = *((bool*)(vehHandle + g_vehNitroEnabledOffset));

                Function.Call(Hash.REQUEST_NAMED_PTFX_ASSET, "veh_xs_vehicle_mods");

                Function.Call((Hash)0xC8E9B6B71B8E660D, v, 1);//Enable nitro
                Function.Call((Hash)0x30B5831ECD9C35C5, v, 1f); //Set mult
                Function.Call((Hash)0x6E31900C2247D4ED, v, 1); //??
                Function.Call((Hash)0x6DEE944E1EE90CFB, v, 1); //??
                Function.Call((Hash)0x6411EB7E837170B5, v, 1f); //??

                Function.Call((Hash)0x2970EAA18FD5E42F, v, 1); //??



                // *((bool*)(vehHandle + g_vehNitroEnabledOffset)) = true;
            }
        }```


RequestNamedPtfxAsset(“veh_xs_vehicle_mods”) - Only make flames on car

SetVehicleNitroEnabled(veh, 10000.0, 5.5, 5.1, 0.1, false) without while, nitrous sounds like always empty. inside while, only seems to work 1 time…

my research its based on things i found on internet, and script testing, because i don’t have knowledge to search/view decompiled gta scripts

1 Like

Did you find anything new about it?

nothing…tried everything… i dont have knowledge to try more…

So, I think I got it! Firstly I did a little research in the decompiled scripts and found this

VEHICLE::_SET_VEHICLE_NITRO_ENABLED(iParam3, true, 2.5f, 1.1f, 4f, false);
VEHICLE::_SET_VEHICLE_NITRO_ENABLED(iParam3, false, 0f, 0f, 0f, false);

Then I checked natives_universal.lua to see if the native SetVehicleNitroEnabled had the correct arguments. I found this

— NativeDB Introduced: v1604
– NativeDB Added Parameter 2 (2060): float level
– NativeDB Added Parameter 3 (2060): float power
– NativeDB Added Parameter 4 (2060): float rechargeTime
– NativeDB Added Parameter 5 (2060): BOOL disableSound

function Global.SetVehicleNitroEnabled(vehicle, toggle)
return _in(0xC8E9B6B71B8E660D, vehicle, toggle)
end

So I knew I had to use the Citizen.InvokeNative to correctly pass the arguments.
I tried this and worked perfectly!

Citizen.InvokeNative(0xC8E9B6B71B8E660D, vehicle, true, 2.5, 1.1, 4.0, false)
Citizen.InvokeNative(0xC8E9B6B71B8E660D, vehicle, false, 0.0, 0.0, 0.0, false)

The last thing that is not working properly Is the flames in the exhaust, as soon as you enable the nitro your vehicle starts spiting out some flames… I hope I was helpful! Cheers

4 Likes

Does it still work?

Not for me… Im probably just using it wrong ^^

I use this now and it works: (Could not figure out the Nitro Native)

multiplier = 10.0
SetVehicleEngineTorqueMultiplier(vehicle, multiplier)