citizenfx / fivem

The source code for the Cfx.re modification frameworks, such as FiveM, RedM and LibertyM, as well as FXServer.
https://cfx.re/
3.57k stars 2.11k forks source link

C# VehicleHash enum is not up-to-date, entries after the Diamond Casino Heist DLC are missing #1538

Open KevinCCucumber opened 2 years ago

KevinCCucumber commented 2 years ago

Spawning a vehicle via a hashlist does not work if the vehicle was released after the Diamond Casio Heist DLC It would be very convenient if it was updated since i have to check if a vehicle is spawnable by name everytime.

I have a script for spawning vehicles and to check if a vehicle actually exists I am looking up the hash values if they exist. Problem is that this List seems to not be up to date for everything later than the Diamond Casino Heist. My Codesample is:

var argsList = args.Select(o => o.ToString()).ToList();
if (argsList.Any() && Enum.TryParse(argsList[0], true, out VehicleHash model)){
}

The Tryparse returns false if the model does not exist in the hashmap.

Another example where this problem is applicable would be this code from the scripting code examples:

var hash = (uint) GetHashKey(model);
if (!IsModelInCdimage(hash) || !IsModelAVehicle(hash))
{
nikez commented 2 years ago

???

titanium-cfx commented 2 years ago

Hello,

Could you please elaborate on what you mean by 'Spawning a vehicle via a hashlist'? As without any code explanation, this sentence doesn't make much sense. :/ Please provide reproduction steps or so if you believe something is not behaving the way it should.

Lucas7yoshi commented 2 years ago

this sounds like it's asking for support for some specific resource.

relevant though is this https://github.com/citizenfx/fivem/pull/1476 PR which returns all the vehicle names. but I still feel this is more about some specific script

KevinCCucumber commented 2 years ago

I have a script for spawning vehicles and to check if a vehicle actually exists I am looking up the hash values if they exist. Problem is that this List seems to not be up to date for everything later than the Diamond Casino Heist. My Codesample is:

var argsList = args.Select(o => o.ToString()).ToList();
if (argsList.Any() && Enum.TryParse(argsList[0], true, out VehicleHash model)){
}

The Tryparse returns false if the model does not exist in the hashmap.

Another example where this problem is applicable would be this code from the scripting code examples:

var hash = (uint) GetHashKey(model);
if (!IsModelInCdimage(hash) || !IsModelAVehicle(hash))
{
titanium-cfx commented 2 years ago

I'm still not too sure about which hashlist you're checking this against. If you're referring to this third-party library https://github.com/d0p3t/fivem-js/blob/master/src/hashes/VehicleHash.ts unfortunately its maintainer (who was one of our community moderators) passed away a few months ago and will likely never be updated unless someone starts maintaining a new fork.

You'd be better off using this native for your usecase: https://docs.fivem.net/natives/?_0xC0296A2EDF545E92

Lucas7yoshi commented 2 years ago

Pretty sure this is requesting the updating of https://github.com/citizenfx/fivem/blob/master/code/client/clrcore/External/VehicleHash.cs

KevinCCucumber commented 2 years ago

I was not aware that I am looking up something that was initially not a part of FiveM, but since it gets used in the tutorial it can lead to some confusion

thorium-cfx commented 2 years ago

It is part of the C# library that FiveM offers and apparently no one uses this or didn't mind it not being updated, until now, I guess.

Next time it would be great if you could use the exact names of things (like WeaponHash) and refer to the C# library, that'll speed up the process.

Local9 commented 2 years ago

Most of the C# enums are out of date and missing things, most users of the library I know have just made their own solutions (personally I use Durty's dumps) and cracked on without having to add to the FiveM backlog.