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.
A JSON file that translates models to types, generated with GetAllVehicleModels on b2699, using the server-sided native GetVehicleType. https://pastebin.com/raw/uzUe667R
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)