From Multi Theft Auto: Wiki
Jump to navigation Jump to search

Emblem-important.png This function is deprecated. This means that its use is discouraged and that it might not exist in future versions.

Please use setElementModel instead.

This function changes the model of the specified vehicle. If the new vehicle model has less seats than the current model, any excess passengers will be removed from the vehicle.


bool setVehicleModel ( vehicle theVehicle, int model )

Required Arguments

  • theVehicle: the vehicle you want to change the model of.
  • model: the new model you want to set.


Returns true if the new model was successfully applied, false if it failed.


This very simple example that allows a player to change the vehicle he is in with a console command. In actual gamemodes the function can be used for more interesting things, like vehicle change pickups.

Click to collapse [-]
    function(thePlayer, command, newModel)
        local theVehicle = getPlayerOccupiedVehicle(thePlayer)  -- get the vehicle the player is in
        newModel = tonumber(newModel)                           -- try to convert the string argument to a number
        if theVehicle and newModel then                         -- make sure the player is in a vehicle and specified a number
            setVehicleModel(theVehicle, newModel)

After the above code is executed, a player can get in any vehicle and execute e.g. the command "/changeveh 520" to change it into a hydra.

See Also