AddVehicleUpgrade: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Added template, sections, minor changes)
Line 1: Line 1:
__NOTOC__
__NOTOC__
This function adds an upgrade to an existing vehicle, eg: nos, hyrdraulics. Defined in San Andreas\data\maps\veh_mods\veh_mods.ide.
{{Server client function}}
This function adds an upgrade to an existing vehicle, eg: nos, hyrdraulics. These upgrades are listed in San Andreas\data\maps\veh_mods\veh_mods.ide.


==Syntax==
==Syntax==
<section name="Server and Client" class="both" show="true">
<syntaxhighlight lang="lua">bool addVehicleUpgrade ( vehicle theVehicle, int upgrade )</syntaxhighlight>
<syntaxhighlight lang="lua">bool addVehicleUpgrade ( vehicle theVehicle, int upgrade )</syntaxhighlight>


Line 11: Line 13:
==Returns==
==Returns==
Returns ''true'' if the upgrade was successfully added to the vehicle, otherwise ''false''.
Returns ''true'' if the upgrade was successfully added to the vehicle, otherwise ''false''.
</section>


==Example==
==Example==
'''Example 1:''' This example allows the user to get an upgrade by typing a command:
<section name="Example 1" class="server">
This serverside function allows the user to get an upgrade by typing a command:
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
-- add a console command
-- define the handler function for our command
function consoleAddUpgrade ( thePlayer, commandName, id )
function consoleAddUpgrade ( thePlayer, commandName, id )
         -- make sure the player is in a vehicle
         -- make sure the player is in a vehicle
Line 35: Line 39:
         end
         end
end
end
-- add the function as a handler for the "addupgrade" command
addCommandHandler ( "addupgrade", consoleAddUpgrade )
addCommandHandler ( "addupgrade", consoleAddUpgrade )
</syntaxhighlight>
</syntaxhighlight>
'''Example 2:''' This client-side script gives vehicles a nitro upgrade whenever they pass through a certain collision shape:
</section>
 
<section name="Example 2" class="client">
This client-side script gives vehicles a nitro upgrade whenever they pass through a certain collision shape:
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
-- create a collision shape
-- create a collision shape
Line 51: Line 59:
addEventHandler ( "onClientColShapeHit", nitroColShape, onNitroColShapeHit )
addEventHandler ( "onClientColShapeHit", nitroColShape, onNitroColShapeHit )
</syntaxhighlight>
</syntaxhighlight>
</section>


==See Also==
==See Also==
{{Vehicle functions}}
{{Vehicle functions}}

Revision as of 22:00, 12 August 2007

This function adds an upgrade to an existing vehicle, eg: nos, hyrdraulics. These upgrades are listed in San Andreas\data\maps\veh_mods\veh_mods.ide.

Syntax

Click to collapse [-]
Server and Client
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. (1000 to 1193)

Returns

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

Example

Click to expand [+]
Example 1
Click to expand [+]
Example 2

See Also