AddVehicleUpgrade
From Multi Theft Auto: Wiki
This function adds an upgrade to a vehicle, e.g. nitrous, hydraulics.
Syntax
bool addVehicleUpgrade ( vehicle theVehicle, int upgrade )
OOP Syntax Help! I don't understand this!
- Method: vehicle:addUpgrade(...)
Required Arguments
- theVehicle: The element representing the vehicle you wish to add the upgrade to.
- upgrade: The id of the upgrade you wish to add. (1000 to 1193), see Vehicle Upgrades
Note: setCameraTarget will behave strangely if you use hydraulics (upgrade id: 1087) server sided and when your camera target is the player inside the vehicle with hydraulics and if the player is not you.
Returns
Returns true if the upgrade was successfully added to the vehicle, otherwise false.
Example
Click to collapse [-]
Example 1This serverside function allows the user to get an upgrade by typing a command:
-- define the handler function for our command function consoleAddUpgrade ( thePlayer, commandName, id ) -- make sure the player is in a vehicle if ( isPedInVehicle ( thePlayer ) ) then -- convert the given ID from a string to a number local id = tonumber ( id ) -- get the player's vehicle local theVehicle = getPedOccupiedVehicle ( thePlayer ) -- add the requested upgrade to the vehicle local success = addVehicleUpgrade ( theVehicle, id ) -- inform the player of whether the upgrade was added successfully if ( success ) then outputConsole ( getVehicleUpgradeSlotName ( id ) .. " upgrade added.", thePlayer ) else outputConsole ( "Failed to add upgrade.", thePlayer ) end else outputConsole ( "You must be in a vehicle!", thePlayer ) end end -- add the function as a handler for the "addupgrade" command addCommandHandler ( "addupgrade", consoleAddUpgrade )
Click to collapse [-]
Example 2This client-side script gives vehicles a nitro upgrade whenever they pass through a certain collision shape:
-- create a collision shape local nitroColShape = createColSphere ( 1337, 100, 12, 2 ) -- attach the collision shape to an 'onClientColShapeHit' event function onNitroColShapeHit ( hitElement, matchingDimension ) if ( getElementType ( hitElement ) == "vehicle" ) then -- add a nitro upgrade if the element that hit the colshape is a vehicle addVehicleUpgrade ( hitElement, 1010 ) end end addEventHandler ( "onClientColShapeHit", nitroColShape, onNitroColShapeHit )
See Also
FROM VERSION 1.5.7 r19626 ONWARDS
- attachTrailerToVehicle
- blowVehicle
- createVehicle
- detachTrailerFromVehicle
- fixVehicle
- getModelHandling
- getOriginalHandling
- getTrainDirection
- getTrainPosition
- getTrainSpeed
FROM VERSION 1.6 r7485 ONWARDS
- getVehicleColor
- getVehicleCompatibleUpgrades
- getVehicleController
- getVehicleDoorOpenRatio
- getVehicleDoorState
- getVehicleEngineState
- getVehicleHandling
- getVehicleHeadLightColor
- getVehicleLandingGearDown
- getVehicleLightState
- getVehicleMaxPassengers
- getVehicleModelFromName
- getVehicleName
- getVehicleNameFromModel
- getVehicleOccupant
- getVehicleOccupants
- getVehicleOverrideLights
- getVehiclePaintjob
- getVehiclePanelState
- getVehiclePlateText
- getVehicleRespawnPosition
- getVehicleRespawnRotation
- getVehicleSirenParams
- getVehicleSirens
- getVehicleSirensOn
- getVehicleTowedByVehicle
- getVehicleTowingVehicle
- getVehicleTurretPosition
- getVehicleType
- getVehicleUpgradeOnSlot
- getVehicleUpgradeSlotName
- getVehicleUpgrades
- getVehicleVariant
- getVehicleWheelStates
- getVehiclesOfType
- isTrainDerailable
- isTrainDerailed
- isVehicleBlown
- isVehicleDamageProof
- isVehicleFuelTankExplodable
- isVehicleLocked
- isVehicleOnGround
- isVehicleTaxiLightOn
- removeVehicleSirens
- removeVehicleUpgrade
- resetVehicleExplosionTime
- resetVehicleIdleTime
- respawnVehicle
- setModelHandling
- setTrainDerailable
- setTrainDerailed
- setTrainDirection
- setTrainPosition
- setTrainSpeed
FROM VERSION 1.6 r7485 ONWARDS
- setVehicleColor
- setVehicleDamageProof
- setVehicleDoorOpenRatio
- setVehicleDoorState
- setVehicleDoorsUndamageable
- setVehicleEngineState
- setVehicleFuelTankExplodable
- setVehicleHandling
- setVehicleHeadLightColor
- setVehicleIdleRespawnDelay
- setVehicleLandingGearDown
- setVehicleLightState
- setVehicleLocked
- setVehicleOverrideLights
- setVehiclePaintjob
- setVehiclePanelState
- setVehiclePlateText
- setVehicleRespawnDelay
- setVehicleRespawnPosition
- setVehicleRespawnRotation
- setVehicleSirens
- setVehicleSirensOn
- setVehicleTaxiLightOn
- setVehicleTurretPosition