Skip to content

Instantly share code, notes, and snippets.

@FrazzIe
Created January 5, 2022 14:27
Show Gist options
  • Select an option

  • Save FrazzIe/6236dcfe61d32ede31f8c54697c81231 to your computer and use it in GitHub Desktop.

Select an option

Save FrazzIe/6236dcfe61d32ede31f8c54697c81231 to your computer and use it in GitHub Desktop.
FiveM: Generates a list of all wheels available for a car
const eVehicleWheelType =
{
VWT_SPORT: 0,
VWT_MUSCLE: 1,
VWT_LOWRIDER: 2,
VWT_SUV: 3,
VWT_OFFROAD: 4,
VWT_TUNER: 5,
VWT_BIKE: 6,
VWT_HIEND: 7,
VWT_SUPERMOD1: 8, // Benny's Original
VWT_SUPERMOD2: 9, // Benny's Bespoke
VWT_SUPERMOD3: 10, // Open Wheel
VWT_SUPERMOD4: 11, // Street
VWT_SUPERMOD5: 12, // Track
};
const eVehicleModType =
{
VMT_WHEELS: 23,
VMT_WHEELS_REAR_OR_HYDRAULICS: 24,
};
function onGenerateWheels()
{
const ped = PlayerPedId();
const veh = GetVehiclePedIsIn(ped, false);
let wheels = "";
if (veh == 0)
{
return;
}
if (!HasThisAdditionalTextLoaded("mod_mnu", 10))
{
ClearAdditionalText(10, true);
RequestAdditionalText("mod_mnu", 10);
}
SetVehicleModKit(veh, 0);
const _wheelType = GetVehicleWheelType(veh);
for (const wheelTypeKey in eVehicleWheelType)
{
wheels += `${wheelTypeKey} =\r\n`;
wheels += "{\r\n";
const wheelType = eVehicleWheelType[wheelTypeKey];
SetVehicleWheelType(veh, wheelType);
const modType = eVehicleModType["VMT_WHEELS"];
const numMods = GetNumVehicleMods(veh, modType);
wheels += `\t{ name = "${GetLabelText("CMOD_WHE_0")}", wtype = ${wheelType}, mod = -1, price = 0 },\r\n`;
for (let mod = 0; mod < numMods; mod++)
{
const modLabel = GetModTextLabel(veh, modType, mod);
const modName = GetLabelText(modLabel);
wheels += `\t{ name = "${modName}", wtype = ${wheelType}, mod = ${mod}, price = ${100 * mod} },\r\n`;
}
wheels += "},\r\n";
}
SetVehicleWheelType(veh, _wheelType);
console.log(wheels);
}
RegisterCommand("genWheels", onGenerateWheels);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment