SetVehicleVariant: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
mNo edit summary
Line 1: Line 1:
{{Server function}}
{{Server function}}
__NOTOC__
__NOTOC__
{{New feature/item|3.0120|1.2||
Only available in MTA:SA v1.2 and onwards.
}}
This function sets the variant of a specified vehicle. In GTA SA 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 GTA SA variant list see: [[Vehicle variants]]
This function sets the variant of a specified vehicle. In GTA SA 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 GTA SA variant list see: [[Vehicle variants]]



Revision as of 09:50, 6 August 2012

This function sets the variant of a specified vehicle. In GTA SA 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 GTA SA variant list see: Vehicle variants

Syntax

bool setVehicleVariant ( vehicle theVehicle, [ int variant1, int variant2 ] )

Required Arguments

  • theVehicle: A handle to the vehicle that you want to get the variant of. Specifying no variant will result in random one being picked.

Optional Arguments

Returns

On success:

  • bool: Returns true as the vehicle variants were successfully set.

On failure:

  • bool: False because the specified vehicle didn't exist or specified variants were invalid.

Example

This example lets the vehicle driver set their vehicle variant with setvehvar

function setMyVehiclesVariant(theUser, command, var1, var2)
    local var1, var2 = tonumber(var1), tonumber(var2) -- If anything was passed make sure its number or nil
    local myVeh = getPedOccupiedVehicle(theUser) -- Get the vehicle that they're in
    if (myVeh and getVehicleController(myVeh) == theUser) then -- Make sure they're in control
        local wasSet = setVehicleVariant(myVeh, var1, var2) -- Set what they wanted
        if (wasSet) then
            outputChatBox("Vehicle variant successfully set!", theUser, 0, 255, 0)
        else
            outputChatBox("Vehicle variant unsuccessfully set.", theUser, 255, 255, 0)
        end
    end
end
addCommandHandler("setvehvar", setMyVehiclesVariant) -- Add the command

Requirements

Minimum server version 1.2
Minimum client version n/a

Note: Using this feature requires the resource to have the above minimum version declared in the meta.xml <min_mta_version> section. e.g. <min_mta_version server="1.2" />

See Also