Hi guys, recently rockstar games added purchasable police cars which have their own in game mods. Do you know how to change those mods with the natives on FiveM? Thank you.
Usually those are extras, any decent admin menu (or vMenu) has the ability to play around with them
I checked with vMenu, it puts the sirens in the extras section and the other stuff in the mod menu section. I did some research with the natives and it seems that DoesExtraExists includes only the sirens, so the other natives that work with extras. I also tried with GetModSlotName to see if they’re registered as modTypes but they’re not. I’m searching the specific native that work with those mods because i’m developing a mechanic job resource and i wanna include also those mods only for police cars, do you know if there is another native that manages car exteriors? Or maybe is it possible that they have their own native?
Which exact vehicle models and what exactly are you trying to manage here?
I’m trying with the Impaler SZ Cruiser (model name polimpaler5) to change the arch covers, aerials, trim and livery (the livery cannot be set through the setLivery native because is a different livery) that are specific to the new police cars added with the ‘bottom dollar bounties’ dlc
Could be literally anything then, trims and arch covers are usually under Fenders, other stuff should be somewhere close. It’d be wise to look at the YFT file itself in specialized software (CodeWalker’s model viewer, for example) to see what’s assigned to what in the model hierarchy
With OpenIV i found the yft files (they are in update/x64/dlcpacks/mp2024_01/dlc.rpf/x64/levels/mp2024_01/vehiclemods/polimpaler5_mods.rpf/), the ones i am interested in are all the polimpaler5_ant.ytf, polimpaler5_livery.ytf, polimpaler5_pushbar.ytf and polimpaler5_slight.ytf but what do i have to do with them? Can i somehow know what native to use?
edit: i also checked polimpaler5.ytf but there is nothing i mentioned in the model hierarchy
also i checked the source code of vMenu and it seems that the following piece of code is the one that sets those mods
var mods = veh.Mods.GetAllMods();
// Loop through all the mods.
foreach (var mod in mods)
{
veh = GetVehicle();
// Get the proper localized mod type (suspension, armor, etc) name.
var typeName = mod.LocalizedModTypeName;
// Create a list to all available upgrades for this modtype.
var modlist = new List<string>();
// Get the current item index ({current}/{max upgrades})
var currentItem = $"[1/{mod.ModCount + 1}]";
// Add the stock value for this mod.
var name = $"Stock {typeName} {currentItem}";
modlist.Add(name);
// Loop through all available upgrades for this specific mod type.
for (var x = 0; x < mod.ModCount; x++)
{
// Create the item index.
currentItem = $"[{2 + x}/{mod.ModCount + 1}]";
// Create the name (again, converting to proper case), then add the name.
name = mod.GetLocalizedModName(x) != "" ? $"{ToProperString(mod.GetLocalizedModName(x))} {currentItem}" : $"{typeName} #{x} {currentItem}";
modlist.Add(name);
}
// Create the MenuListItem for this mod type.
var currIndex = GetVehicleMod(veh.Handle, (int)mod.ModType) + 1;
var modTypeListItem = new MenuListItem(
typeName,
modlist,
currIndex,
$"Choose a ~y~{typeName}~s~ upgrade, it will be automatically applied to your vehicle."
)
{
ItemData = (int)mod.ModType
};
// Add the list item to the menu.
VehicleModMenu.AddMenuItem(modTypeListItem);
}
It seems that treat those mods as modTypes but with GetModSlotName i don’t see them
Analyzing the vMenu I noticed that it uses the GetAllMods() function which is not present among the natives. After doing some research I went to analyze the C# wrapper of fivem and I came to the conclusion that the mods were actually modTypes, digging into the documentation I discovered the mod types enum which assigns the following values:
Arch covers = 42
Aerials = 43
Trim = 44
Livery = 48
To give an example I implemented the code contained in the C# GetAllMods() function which returns an array with the modTypes of a given vehicle:
local VehicleModType = {
Spoilers = 0,
FrontBumper = 1,
RearBumper = 2,
SideSkirt = 3,
Exhaust = 4,
Frame = 5,
Grille = 6,
Hood = 7,
Fender = 8,
RightFender = 9,
Roof = 10,
Engine = 11,
Brakes = 12,
Transmission = 13,
Horns = 14,
Suspension = 15,
Armor = 16,
FrontWheel = 23,
RearWheel = 24,
PlateHolder = 25,
VanityPlates = 26,
TrimDesign = 27,
Ornaments = 28,
Dashboard = 29,
DialDesign = 30,
DoorSpeakers = 31,
Seats = 32,
SteeringWheels = 33,
ColumnShifterLevers = 34,
Plaques = 35,
Speakers = 36,
Trunk = 37,
Hydraulics = 38,
EngineBlock = 39,
AirFilter = 40,
Struts = 41,
ArchCover = 42,
Aerials = 43,
Trim = 44,
Tank = 45,
Windows = 46,
Livery = 48
}
function getCount(vehicleHandler, modType)
return GetNumVehicleMods(vehicleHandler, modType);
end
function getLocalizedModName(vehicleHandler, modType)
local labelText = GetLabelText(GetModSlotName(vehicleHandler, modType))
if labelText ~= "NULL" then
return labelText
end
for k, v in pairs(VehicleModType) do
if v == modType then
return k
end
end
return "NULL"
end
function hasVehicleMod(ownerHandle, modType)
return GetNumVehicleMods(ownerHandle, modType) > 0
end
function GetAllMods(ownerHandle)
local mods = {}
for key, modType in pairs(VehicleModType) do
if type(modType) == "number" then
if hasVehicleMod(ownerHandle, modType) then
table.insert(mods, modType)
end
end
end
return mods
end
RegisterCommand('mod', function(source, args)
local vehicle = GetVehiclePedIsIn(GetPlayerPed(-1))
local mods = GetAllMods(vehicle)
for i, v in ipairs(mods) do
print("Name: " .. getLocalizedModName(vehicle, v), "Count: " .. getCount(vehicle, v))
end
end)
As you can see some values of the enum in the documentation are missing, such as VMT_NITROUS or VMT_TURBO, as the C# wrapper handles them with other enums. I hope this short explanation will be useful to those who want to know how the new police cars added in GTA Online work
If you want to dive deeper into C# wrapper vehicle enums they are here