ServersYour serverFor creatorsForumFAQDocumentationSecurity
Download the launcher
  1. Documentation
  2. Shared functions
  3. getVehicleModelFromName

Function

getVehicleModelFromName

Server and clientVehiclesIdentical to MTA:SA

Turns a vehicle name into a model number, ignoring letter case and surrounding spaces, e.g. "infernus" → 411. It also recognises the names of new models from engineRequestModel. Ideal for commands like /v infernus.

Syntax

int getVehicleModelFromName(string name)

Arguments

namestring
Vehicle name (English, as in the game).

Returns

The model ID, or false when the name is unknown.

Example

addCommandHandler("v", function(player, _, ...)
    local model = getVehicleModelFromName(table.concat({ ... }, " "))
    if not model then return outputChatBox("Nie ma takiego pojazdu.", player) end
    local x, y, z = getElementPosition(player)
    createVehicle(model, x + 3, y, z + 0.5)
end)

See also