SetVehicleVariant: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
(Make it shared) |
||
Line 1: | Line 1: | ||
{{ | {{Shared function}} | ||
__NOTOC__ | __NOTOC__ | ||
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]] | ||
Line 41: | Line 41: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
==Requirements== | ==Requirements== | ||
{{Requirements|1.2| | {{Requirements|1.2|1.5.8-9.20693|}} | ||
==See Also== | ==See Also== | ||
{{Vehicle functions}} | {{Vehicle functions}} |
Revision as of 13:26, 25 October 2020
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
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
bool setVehicleVariant ( vehicle theVehicle [, int variant1, int variant2 ] )
OOP Syntax Help! I don't understand this!
- Method: vehicle:setVariant(...)
- Counterpart: getVehicleVariant
Required Arguments
- theVehicle: A handle to the vehicle that you want to get the variant of.
Optional Arguments
Both arguments need to be supplied, otherwise random variants will be picked.
- variant1: An integer for the first variant see Vehicle variants
- variant2: An integer for the second variant see Vehicle variants
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
This template will be deleted.
See Also
- addVehicleUpgrade
- attachTrailerToVehicle
- blowVehicle
- createVehicle
- detachTrailerFromVehicle
- fixVehicle
- getOriginalHandling
- getTrainDirection
- getTrainPosition
- getTrainSpeed
- getTrainTrack
- getVehicleColor
- getVehicleCompatibleUpgrades
- getVehicleController
- getVehicleDoorOpenRatio
- getVehicleDoorState
- getVehicleEngineState
- getVehicleHandling
- getVehicleHeadLightColor
- getVehicleLandingGearDown
- getVehicleLightState
- getVehicleMaxPassengers
- getVehicleModelFromName
- getVehicleName
- getVehicleNameFromModel
- getVehicleOccupant
- getVehicleOccupants
- getVehicleOverrideLights
- getVehiclePaintjob
- getVehiclePanelState
- getVehiclePlateText
- getVehicleSirenParams
- getVehicleSirens
- getVehicleSirensOn
- getVehicleTowedByVehicle
- getVehicleTowingVehicle
- getVehicleTurretPosition
- getVehicleType
- getVehicleUpgradeOnSlot
- getVehicleUpgradeSlotName
- getVehicleUpgrades
- getVehicleVariant
- getVehicleWheelStates
- isTrainDerailable
- isTrainDerailed
- isVehicleBlown
- isVehicleDamageProof
- isVehicleFuelTankExplodable
- isVehicleLocked
- isVehicleOnGround
- isVehicleTaxiLightOn
- removeVehicleUpgrade
- setTrainDerailable
- setTrainDerailed
- setTrainDirection
- setTrainPosition
- setTrainSpeed
- setTrainTrack
- setVehicleColor
- setVehicleDamageProof
- setVehicleDoorOpenRatio
- setVehicleDoorState
- setVehicleDoorsUndamageable
- setVehicleEngineState
- setVehicleFuelTankExplodable
- setVehicleHandling
- setVehicleHeadLightColor
- setVehicleLandingGearDown
- setVehicleLightState
- setVehicleLocked
- setVehicleOverrideLights
- setVehiclePaintjob
- setVehiclePanelState
- setVehiclePlateText
- setVehicleSirens
- setVehicleSirensOn
- setVehicleTaxiLightOn
- setVehicleTurretPosition
- setVehicleVariant
- setVehicleWheelStates