fivem icon indicating copy to clipboard operation
fivem copied to clipboard

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

Open KevinCCucumber opened this issue 1 year ago • 9 comments

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))
{

KevinCCucumber avatar Jul 23 '22 13:07 KevinCCucumber

???

nikez avatar Jul 23 '22 13:07 nikez

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.

titanium-cfx avatar Jul 23 '22 13:07 titanium-cfx

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

Lucas7yoshi avatar Jul 23 '22 15:07 Lucas7yoshi

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))
{

KevinCCucumber avatar Jul 23 '22 17:07 KevinCCucumber

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

titanium-cfx avatar Jul 23 '22 18:07 titanium-cfx

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

Lucas7yoshi avatar Jul 23 '22 19:07 Lucas7yoshi

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

KevinCCucumber avatar Jul 23 '22 22:07 KevinCCucumber

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.

thorium-cfx avatar Jul 24 '22 12:07 thorium-cfx

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.

Local9 avatar Jul 28 '22 19:07 Local9