[Release] mvehiclequery - Get selected vehicle.meta information

Hello, here again another release. This is still not completely ready and still has some kinks, but I do not want to finish it up tomorrow instead of today. So I can do something else.

This script uses the double checked vehicle.meta information to provide data, otherwise not available through natives for your scripts.

Excerpt from Example

    Citizen.Wait(5000) -- ensures the data is loaded have no exception handling at the moment
	-- lets build an exclusion list, 
	-- we do not want to offer vehicles without plates
	-- no law enforcement vehicles
	-- no turrets
	-- no bullet resistant glass
	-- and no stuff that is not spawned by cargen
	local exjson = exports['mvehiclequery']:GetVehiclesFromFlags("VPT_NONE")
	exjson = exports['mvehiclequery']:VehiclesFilterAddFromJSON(exjson, exports['mvehiclequery']:GetVehiclesFromFlags("FLAG_LAW_ENFORCEMENT"))
	exjson = exports['mvehiclequery']:VehiclesFilterAddFromJSON(exjson, exports['mvehiclequery']:GetVehiclesFromFlags("TURRET"))
	exjson = exports['mvehiclequery']:VehiclesFilterAddFromJSON(exjson, exports['mvehiclequery']:GetVehiclesFromFlags("FLAG_HAS_BULLET_RESISTANT_GLASS"))
	exjson = exports['mvehiclequery']:VehiclesFilterAddFromJSON(exjson, exports['mvehiclequery']:GetVehiclesFromFlags("FLAG_DISABLE_THROUGH_WINDSCREEN"))
	exjson = exports['mvehiclequery']:VehiclesFilterAddFromJSON(exjson, exports['mvehiclequery']:GetVehiclesFromFlags("FLAG_DONT_SPAWN_IN_CARGEN"))
	-- Cann add some more manually, but well, idc at that point. This is a demonstration.
	
	-- just repeating the same stuff over and over again to populate the car menus
	local curjson = exports['mvehiclequery']:GetVehiclesFromClass("COMPACT")
	-- sanitize the json and remove forbidden vehicles
	curjson = exports['mvehiclequery']:VehiclesFilterOutFromJSON(curjson, exjson)
	local arr = json.decode(curjson)
	for i,v in pairs(arr) do
		if exports['mvehiclequery']:GetVehicleMakeName(v) ~= "" then
			table.insert(vehshop.menu.compacts.buttons,{
				name = GetLabelText(exports['mvehiclequery']:GetVehicleMakeName(v)).." "..GetLabelText(GetDisplayNameFromVehicleModel(v)), 
				costs = 10000, 
				description = {}, 
				model = exports['mvehiclequery']:GetVehicleModelName(v)
			})
		end
	end

The example is an excerpt from a badly modified version from the original found here: [Release] Vehicle shop by Arturs
It parses all vehicles and populates the list instead with the vehicles from the json. Which can be found individually here: https://github.com/GHMatti/FiveM-VehicleInfo/tree/master/example/vehshop

How to use the Resource

After loading the resource, you have several exports avialable to use in your resources to query the information you need, but only Client-side.

ModelHash -> Information

  • exports['mvehiclequery']:GetVehicleMakeName(hash) returns the manufacturer/brand name of a vehicle. You can send it through GetLabelText to get the localized version of it.
  • exports['mvehiclequery']:GetVehicleModelName(hash) gets you back the name of the model, which you cannot access after calling a hash usually, unless you know what it was.
  • exports['mvehiclequery']:GetVehicleFlags(hash) returns the flags of a vehicle, which are manifold. Like if it is a law enforcement vehicle, or a vehicle for rich or poor people.
  • exports['mvehiclequery']:GetVehiclePlateType(hash) returns the plate type of a vehicle, if the plate is either on the front, the back, on both sides, or on none.
  • exports['mvehiclequery']:GetVehicleType(hash) returns the vehicle type of a vehicle, if it is a helicopter, boat or a car

Information -> JSON-Array ModelHash

  • exports['mvehiclequery']:GetVehiclesFromDisplayName(displayName) returns a string containing a json-array containing all vehicle-hashes who share a displayname.
  • exports['mvehiclequery']:GetVehiclesFromMakeName(makeName) returns a string containing a json-array containing all vehicle-hashes who are from a certain manufacturer.
  • exports['mvehiclequery']:GetVehiclesFromFlags(flag) returns a string containing a json-array containing all vehicle-hashes who have a certain flag set/or partially.
  • exports['mvehiclequery']:GetVehiclesFromClass(class) returns a string containing a json-array containing all vehicle-hashes who are from a certain vehicle class.
  • exports['mvehiclequery']:GetVehiclesFromType(type) returns a string containing a json-array containing all vehicle-hashes which are of a certain type.
  • exports['mvehiclequery']:GetVehiclesFromPlateType(platetype) returns a string containing a json-array containing all vehicle-hashes which have a certain plate-type.

Utility Functions for JSON-Arrays (as strings)

  • exports['mvehiclequery']:VehiclesFilterInFromJSON(jsona, jsonb) returns a json-array which only contains items that are in jsona and jsonb.
  • exports['mvehiclequery']:VehiclesFilterOutFromJSON(jsona, jsonb) returns a json-array which only contains items that are in jsona and not in jsonb.
  • exports['mvehiclequery']:VehiclesFilterAddFromJSON(jsona, jsonb) returns a json-array which only contains items that are in jsona or jsonb.

Download from GitHub: https://github.com/GHMatti/FiveM-VehicleInfo/releases/latest

Changelog
  • 20180115: Initial Release

Additionally the raw data can be downloaded and used individually. There are 3 files, which contain the same information, a json file, and xml file and another json file the mvehicledata_simple.json only makes it simpler to find a certain vehicle by having the data contained not in an array, but in dictionary form. The files contain all the vehicles available in FiveM which are also in GTAV, not a single more or less.

Apart from the vehicle.meta data itself which can be gotten through OpenIV, and the packages required to compile it, and make your own data-files easily.

If someone has suggestions for improvements, I am all ears. Apart from the needed delay which I will fix soon™.

6 Likes

Great! (20? cmon :cry:)

1 Like

This looks to be a cool resource. Will be checking out in depth later today.

1 Like

I will drop support for the resource. Though I will continue providing the jsons. These are the jsons for the current version:

ghmatti_vehicle_data.json (232.6 KB)
ghmatti_vehicle_data_simple.json (229.1 KB)

All vehicle names and hashes in there. Enjoy. I will put up a new repository for that later. Including weapon hashes and components.