Get vehicle model from hash

Hello everyone!

I was in progress to making a garage system but quickly I found out that I cant take vehicle model´s name from a hash code.

I had this issue of some GTA Vanilla cars, Example the schwarzer vehicle model but when I try and get the vehicle model with the function
GetDisplayNameFromVehicleModel(GetEntityModel(GetVehiclePedIsIn(GetPlayerPed(-1), false)))
I dont get the right vehicle model name for the Car.

Instead of getting the orginal spawn code name “schwarzer” I get “schwarze” instead.

I had the idea to make a library for all the vehicle models and hash names in a file seperate so it scans the library if it can find the hash name there, then take the model name from the library and send over but this would take a lot of time to write all the different model and hash names down, so was wondering if anyone had a better idea to make this possible.

Hey, I assume you want to get the vehicle label.

By using the natives you used, you’ll get a display name. I this case – SCHWARZE.
If you want to find a label – Schwartzer, you have to use GetLabelText().

GetLabelText(GetDisplayNameFromVehicleModel(GetEntityModel(GetVehiclePedIsIn(PlayerPedId(), false))))

For addons, use this for every addon vehicle first or you’ll get CARNOTFOUND as a result.

Citizen.CreateThread(function()
    AddTextEntry('Spawn/Model name', 'Display name you want')
end)

Hello antond1!

Thanks for your support but this isnt working the right way…

I want to get the vehicle model (If you use the GetLabelText you get the vehicle name) and then you get the vehicle name Schwartzer, I want to get the vehicle model (Spawn Code) and in this case it is schwarzer

Okay. In this case, there is probably only one way to achieve this – correct me if I’m wrong.

You will need a huge table with the model hash as the key and the model name as the value.
@VenomXNL exported all known model names and shared them publicly, so you can use that list.
The list has 53861 rows, so it’s a little bigger. If you want to filter out just vehicles, GL.

Replace some parts to create a lua table.
This To that
<FRONT> [
= ] = '
<BACK> ',

Then you can simply index the table in your script with list[modelHash].
Make sure to use GetEntityModel() and not GetHashKey().

I have indeed gathered LOTS of resources (both from collection other partial lists and doing ALOT of own extracting/research back then)…

HOWEVER… unfortunately (because I also have been away from FiveM for almost 2 years and just returned last week) my list is (by far) not complete anymore.

MANY of the new hashes from DLC’s which where released after my initial release are not recognized by the script. What you could though (in case it’s for static/map objects and identities) is using CodeWalker and load it with DLC’s to find the object on the map :slight_smile:

(However in this instance it won’t help much when it comes to randomly spawning vehicles).