setVehicleVariant | Multi Theft Auto: Wiki Skip to content

setVehicleVariant

Client-side
Server-side
Shared

Pair: getVehicleVariant

This page is incomplete! Help wanted!

Please finish this page using the corresponding Old Wiki article.
Go to Contribution guidelines for more information.


This function sets the variant of a specified vehicle. In GTA: San Andreas some vehicles are different; for example the labelling on trucks or the contents of a pick-up truck and the varying types of a motor bike. For the default variant list see: Vehicle variants.

Note

The fairings on the NRG-500 and BF-400 are both variants, so unless you explicitly ask for 3 or 4, your bike will have no fairings which some people may find offensive.

Tip

Both variant arguments need to be supplied, otherwise random ones will be picked.

Tip

If you only want one variant, set ' variant2' to 255 . If you want no variants, then set both ' variant1' and ' variant2' to 255 .

Syntax

setVehicleVariant ( )

Code Examples

server

This example lets the vehicle driver set their vehicle's variant with a command:

function setMyVehicleVariants (thePlayer, commandName, arg1, arg2)
local variant1, variant2 = tonumber (arg1), tonumber (arg2) -- If anything was passed make sure the arguments are numbers or pass nil
local myVeh = getPedOccupiedVehicle (thePlayer) -- Get the vehicle that the player is in
if (myVeh and getVehicleController (myVeh) == thePlayer) then -- Make sure the player is the vehicle driver (controller)
local wasSet = setVehicleVariant (myVeh, variant1, variant2) -- Set the vehicle variants the player passed as arguments
if wasSet then
outputChatBox ("Vehicle variant successfully set!", thePlayer, 0, 255, 0)
else
outputChatBox ("Vehicle variant unsuccessfully set.", thePlayer, 255, 255, 0)
end
end
end
addCommandHandler ("setvehvar", setMyVehicleVariants) -- Create the command

See Also

Vehicle Functions