CREATE_AUTOMOBILE-like natives for other vehicle types

Post above states making specific functions for each type (i.e. CREATE_PLANE, CREATE_TRAILER, etc.) was undesirable, but seems like the only reasonable option as far as I can tell.

I guess spawning incorrect types could lead to odd behaviour, but that seems better than the current case where you need to use CreateVehicle in most cases, which has been stated to be flawed and shouldn’t be used.

There was a todo item for a CREATE_VEHICLE_SERVER_SETTER call that’d take a string argument with a vehicle type, as a compromise until there’d be vehicle metadata parsing (see Vehicle metadata indexing on server · Issue #840 · citizenfx/fivem · GitHub for how that could work), and this one could then also be added to native-decls without risking misuse.

However, since each vehicle type has some different creation nodes as well, this is still a relatively complex task.

Several types do seem to be missing, though they may function okay under existing types.

  • BICYCLE (7)
  • BLIMP (3)
  • QUADBIKE (9)

Thanks for your time, this will be very useful.

I guess these don’t have their own netObject type, so they’re related to their parent type:


Bike, I believe.

Also Bike.


Again, Automobile, but maybe Submarine if that derives from Automobile.

I guess the documentation could do with a mapping table of vehicle types to network object types, then, yes, as I forgot there were derived types at all. :sweat_smile:

A JSON file that translates models to types, generated with GetAllVehicleModels on b2699, using the server-sided native GetVehicleType.

You can use this table like that:

local modelsToTypes = json.decode(--[[ Load the JSON file here, with LoadResourceFile or whatever ]])
function SpawnVehicleServerSetter(model, x, y, z, heading)
	local modelType = modelsToTypes[model]
	if not modelType then
		error("This model does not exist on the list")
	CreateVehicleServerSetter(model, modelType, x, y, z, heading)

Note that some models do not appear in the table that GetAllVehicleModels returns, and as a result, it doesn’t appear in the JSON table: such as BMX, etc… (which is a different problem)