Skip to content

addVehicleUpgrade

Shared

Manual Review Required

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


This function adds an upgrade to a vehicle, e.g. nitrous, hydraulics.

OOP Syntax Help! I don't understand this!

Syntax

bool addVehicleUpgrade ( ​vehicle theVehicle, ​string/int upgrade )
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 ) or " all" to add all upgrades.

Returns

Returns true if the upgrade was successfully added to the vehicle, otherwise false .

  • bool: value

Code Examples

shared

This 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 )

See Also

Vehicle Functions