SetVehicleVariant: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
{{Shared function}} | {{Shared function}} | ||
__NOTOC__ | __NOTOC__ | ||
This function sets the variant of a specified vehicle. In GTA | 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]]. | ||
{{New feature/item|3.0159|1.5.8|20693|Function also | {{New feature/item|3.0159|1.5.8|20693|Function is also available client-side (previously available server-side only).}} | ||
{{Tip|Both variant arguments need to be supplied, otherwise random ones will be picked.}} | {{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''}} | {{Tip|If you only want one variant, set ''''variant2'''' to ''255''. If you want no variants, then set both ''''variant1'''' and ''''variant2'''' to ''255''.}} | ||
{{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. | {{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. | ||
}} | }} | ||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua">bool setVehicleVariant ( vehicle theVehicle [, int variant1, int variant2 ] )</syntaxhighlight> | <syntaxhighlight lang="lua">bool setVehicleVariant ( vehicle theVehicle [, int variant1, int variant2 ] )</syntaxhighlight> | ||
{{OOP||[[vehicle]]:setVariant||getVehicleVariant}} | {{OOP||[[vehicle]]:setVariant||getVehicleVariant}} | ||
==Optional Arguments== | ===Required Arguments=== | ||
*'''theVehicle:''' The [[vehicle]] that you want to get the variant of. | |||
===Optional Arguments=== | |||
Both arguments need to be supplied, otherwise random variants will be picked. | Both arguments need to be supplied, otherwise random variants will be picked. | ||
* '''variant1''': An integer for the first variant see [[Vehicle variants]] | * '''variant1''': An integer for the first variant see [[Vehicle variants]] | ||
Line 20: | Line 22: | ||
==Returns== | ==Returns== | ||
Returns ''true'' as the vehicle variants were successfully set, ''false'' because the specified vehicle didn't exist or specified variants were invalid. | |||
==Example== | ==Example== | ||
This example lets the vehicle driver set their vehicle variant with setvehvar | This example lets the vehicle driver set their vehicle's variant with a command named ''setvehvar'': | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function | function setMyVehicleVariants (thePlayer, commandName, arg1, arg2) | ||
local | local variant1, variant2 = tonumber (arg1), tonumber (arg2) -- If anything was passed make sure the arguments are numbers or pass nil | ||
local myVeh = getPedOccupiedVehicle( | local myVeh = getPedOccupiedVehicle (thePlayer) -- Get the vehicle that the player is in | ||
if (myVeh and getVehicleController(myVeh) == | |||
local wasSet = setVehicleVariant(myVeh, | if (myVeh and getVehicleController (myVeh) == thePlayer) then -- Make sure the player is the vehicle driver (controller) | ||
if | local wasSet = setVehicleVariant (myVeh, variant1, variant2) -- Set the vehicle variants the player passed as arguments | ||
outputChatBox("Vehicle variant successfully set!", | |||
if wasSet then | |||
outputChatBox ("Vehicle variant successfully set!", thePlayer, 0, 255, 0) | |||
else | else | ||
outputChatBox("Vehicle variant unsuccessfully set.", | outputChatBox ("Vehicle variant unsuccessfully set.", thePlayer, 255, 255, 0) | ||
end | end | ||
end | end | ||
end | end | ||
addCommandHandler("setvehvar", | |||
addCommandHandler ("setvehvar", setMyVehicleVariants) -- Create the command | |||
</syntaxhighlight> | </syntaxhighlight> | ||
==Requirements== | ==Requirements== | ||
{{Requirements|1.2|1.5.8-9.20693|}} | {{Requirements|1.2.0|1.5.8-9.20693|}} | ||
==See Also== | ==See Also== | ||
{{Vehicle functions}} | {{Vehicle functions}} |
Revision as of 11:13, 19 September 2021
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. Function is also available client-side (previously available server-side only).
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: 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
Returns true as the vehicle variants were successfully set, false because the specified vehicle didn't exist or specified variants were invalid.
Example
This example lets the vehicle driver set their vehicle's variant with a command named setvehvar:
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
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