RemoveVehicleUpgrade: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
 
m (normalize page to match others)
 
(4 intermediate revisions by 4 users not shown)
Line 1: Line 1:
__NOTOC__
__NOTOC__
==Description==
{{Server client function}}
This function removes an already existing upgrade from the specified vehicle, eg: nos, hyrdraulics. Defined in San Andreas\data\maps\veh_mods\veh_mods.ide.
This function removes an already existing upgrade from the specified vehicle, eg: nos, hydraulics. Defined in San Andreas\data\maps\veh_mods\veh_mods.ide.


==Syntax==
==Syntax==
<syntaxhighlight lang="lua">bool removeVehicleUpgrade ( vehicle, upgrade )</syntaxhighlight>
<syntaxhighlight lang="lua">bool removeVehicleUpgrade ( vehicle theVehicle, int upgrade )</syntaxhighlight>


===Required Arguments===
===Required Arguments===
*'''vehicle''': The [[element]] representing the [[vehicle]] you wish to remove the upgrade from
*'''theVehicle''': The [[element]] representing the [[vehicle]] you wish to remove the upgrade from
*'''upgrade''': The upgrade you wish to remove, currently limited to NOS-5X(1008), NOS-2X(1009), NOS-10X(1010), HYDRAULICS(1087)
*'''upgrade''': The ID of the upgrade you wish to remove.


==Returns==
==Returns==
Returns 'true' if the upgrade was successfully removed from the vehicle, otherwise 'false'.
Returns ''true'' if the upgrade was successfully removed from the vehicle, otherwise ''false''.


==Example==
==Example==
<section name="Server" class="server" show="true">
This script defines a 'nos' console command that adds a NOS upgrade to the vehicle that the player who executes the command is sitting in.  It also adds a 'removenos' command which allows removal of a player's nos.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
addEventHandler ( "onPlayerConsole", root, "onPlayerConsole" )
function addNOS ( sourcePlayer, command )
function onPlayerConsole ( text )
     theVehicle = getPlayerOccupiedVehicle ( sourcePlayer )
  command = split ( text, 1, 32 )
     if ( theVehicle ) then
  if ( command == "nos" ) then
        addVehicleUpgrade ( theVehicle, 1010 )     -- NOS 10x
     vehicle = getPlayerOccupiedVehicle ( source )
     if ( vehicle ) then
      addVehicleUpgrade ( vehicle, 1010 ) -- nos-10x
      removeVehicleUpgrade ( vehicle, 1010 )
     end
     end
  end
end
end
addCommandHandler ( "nos", addNOS )
function remNOS ( sourcePlayer, command )
    theVehicle = getPlayerOccupiedVehicle ( sourcePlayer )
    if ( theVehicle ) then
        removeVehicleUpgrade ( theVehicle, 1010 )
    end
end
addCommandHandler ( "removenos", remNOS )
</syntaxhighlight>
</section>
<section name="Client" class="client" show="false">
This script defines a 'nos' console command that adds a NOS upgrade to the vehicle that the player who executes the command is sitting in.  It also adds a 'removenos' command which allows removal of a player's nos.  This example is clientside and may cause desync.
<syntaxhighlight lang="lua">
function addNOS ( command )
    theVehicle = getPlayerOccupiedVehicle ( getLocalPlayer() )
    if ( theVehicle ) then
        addVehicleUpgrade ( theVehicle, 1010 )    -- NOS 10x
    end
end
addCommandHandler ( "nos", addNOS )
function remNOS ( command )
    theVehicle = getPlayerOccupiedVehicle ( getLocalPlayer() )
    if ( theVehicle ) then
        removeVehicleUpgrade ( theVehicle, 1010 )
    end
end
addCommandHandler ( "removenos", remNOS )
</syntaxhighlight>
</syntaxhighlight>
</section>


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

Latest revision as of 08:03, 5 August 2021

This function removes an already existing upgrade from the specified vehicle, eg: nos, hydraulics. Defined in San Andreas\data\maps\veh_mods\veh_mods.ide.

Syntax

bool removeVehicleUpgrade ( vehicle theVehicle, int upgrade )

Required Arguments

  • theVehicle: The element representing the vehicle you wish to remove the upgrade from
  • upgrade: The ID of the upgrade you wish to remove.

Returns

Returns true if the upgrade was successfully removed from the vehicle, otherwise false.

Example

Click to collapse [-]
Server

This script defines a 'nos' console command that adds a NOS upgrade to the vehicle that the player who executes the command is sitting in. It also adds a 'removenos' command which allows removal of a player's nos.

function addNOS ( sourcePlayer, command )
    theVehicle = getPlayerOccupiedVehicle ( sourcePlayer )
    if ( theVehicle ) then
        addVehicleUpgrade ( theVehicle, 1010 )     -- NOS 10x
    end
end
addCommandHandler ( "nos", addNOS )

function remNOS ( sourcePlayer, command )
    theVehicle = getPlayerOccupiedVehicle ( sourcePlayer )
    if ( theVehicle ) then
        removeVehicleUpgrade ( theVehicle, 1010 )
    end
end
addCommandHandler ( "removenos", remNOS )
Click to expand [+]
Client

See Also