AddVehicleUpgrade: Difference between revisions
Jump to navigation
Jump to search
(→Example: changed example to use command handler rather than onConsole event) |
|||
Line 14: | Line 14: | ||
==Example== | ==Example== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
-- add a console command | |||
function | addCommandHandler ( "addupgrade", "consoleAddUpgrade" ) | ||
function consoleAddUpgrade ( player, commandName, id ) | |||
if ( player ) then | |||
if ( isPlayerInVehicle ( player ) ) then | |||
-- conver the ID to a number | |||
id = tonumber ( id ) | |||
-- get the player's vehicle | |||
local vehicle = getPlayerOccupiedVehicle ( player ) | |||
-- add the requested upgrade to the vehicle | |||
local success = addVehicleUpgrade ( vehicle, id ) | |||
if ( success ) then | |||
-- get the name of the upgrade and display it | |||
outputConsole ( getVehicleUpgradeSlotName ( id ) .. " upgrade added.", player ) | |||
else | |||
outputConsole ( "Failed to add upgrade.", player ) | |||
end | |||
else | |||
outputConsole ( "You must be in a vehicle!", player ) | |||
end | |||
end | end | ||
end | end | ||
</syntaxhighlight> | </syntaxhighlight> |
Revision as of 05:35, 18 June 2007
This function adds an upgrade to an existing vehicle, eg: nos, hyrdraulics. Defined in San Andreas\data\maps\veh_mods\veh_mods.ide.
Syntax
bool addVehicleUpgrade ( vehicle theVehicle, 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.
Returns
Returns true if the upgrade was successfully added to the vehicle, otherwise false.
Example
-- add a console command addCommandHandler ( "addupgrade", "consoleAddUpgrade" ) function consoleAddUpgrade ( player, commandName, id ) if ( player ) then if ( isPlayerInVehicle ( player ) ) then -- conver the ID to a number id = tonumber ( id ) -- get the player's vehicle local vehicle = getPlayerOccupiedVehicle ( player ) -- add the requested upgrade to the vehicle local success = addVehicleUpgrade ( vehicle, id ) if ( success ) then -- get the name of the upgrade and display it outputConsole ( getVehicleUpgradeSlotName ( id ) .. " upgrade added.", player ) else outputConsole ( "Failed to add upgrade.", player ) end else outputConsole ( "You must be in a vehicle!", player ) end end end
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