SetVehicleNitroActivated: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
(Remove obsolete Requirements section)
 
(11 intermediate revisions by 5 users not shown)
Line 1: Line 1:
__NOTOC__  
__NOTOC__  
{{Client function}}
{{Client function}}
{{New feature/item|4.0132|1.3.1|4993|
{{New feature/item|3.0131|1.3.1|4993|
This function activate the nitro on the [[vehicle]].
This function activates or deactivates the nitro on the specified [[vehicle]], like if a player pressed the button for activating nitro.
}}
}}
 
{{Warning|Only works if the vehicle is streamed in.}}
==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">bool setVehicleNitroActivated ( vehicle theVehicle, bool state )</syntaxhighlight>  
<syntaxhighlight lang="lua">bool setVehicleNitroActivated ( vehicle theVehicle, bool state )</syntaxhighlight>  


===Required Arguments===  
===Required Arguments===  
*'''theVehicle''' The [[vehicle]] which you want to check an activation.
*'''theVehicle''' The [[vehicle]] to activate or deactivate the nitro on.
*'''state''' true if you want to activate the nitro, false if you want to disable it.
*'''state''' ''true'' if you want to activate the nitro, ''false'' if you want to disable it.


===Returns===
===Returns===
Returns ''true'' if the nitro is activated successfully on the vehicle, ''false'' otherwise.
Returns ''true'' if the nitro activation state was modified successfully, ''false'' otherwise.


==Example==
==Example==
<syntaxhighlight lang="lua">addEventHandler( 'onClientVehicleEnter', root,
<section name="Client" class="client" show="true">
function( pPlayer )
This example adds and activates nitro in the vehicle the player enters.
if pPlayer == localPlayer then
<syntaxhighlight lang="lua">
addVehicleUpgrade( source, 1010 ) -- Install a nitro.
function activateNitro(pPlayer)
setVehicleNitroActivated( source, true ) -- Activate the nitro.
if pPlayer == localPlayer then
if not getVehicleUpgradeOnSlot(source, 8) then -- Check if the vehicle has nitro installed or not
addVehicleUpgrade(source, 1010) -- Install the nitrous
end
end
setVehicleNitroActivated(source, true) -- Activate the nitro
end
end
)</syntaxhighlight>
end
 
addEventHandler("onClientVehicleEnter", root, activateNitro) -- When the player enters a vehicle, it executes the function
==Requirements==
</syntaxhighlight>
{{Requirements|n/a|1.3.1-9.04993|}}
</section>


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

Latest revision as of 17:10, 7 November 2024

This function activates or deactivates the nitro on the specified vehicle, like if a player pressed the button for activating nitro.

[[|link=|]] Warning: Only works if the vehicle is streamed in.

Syntax

bool setVehicleNitroActivated ( vehicle theVehicle, bool state )

Required Arguments

  • theVehicle The vehicle to activate or deactivate the nitro on.
  • state true if you want to activate the nitro, false if you want to disable it.

Returns

Returns true if the nitro activation state was modified successfully, false otherwise.

Example

Click to collapse [-]
Client

This example adds and activates nitro in the vehicle the player enters.

function activateNitro(pPlayer)
	if pPlayer == localPlayer then
		if not getVehicleUpgradeOnSlot(source, 8) then -- Check if the vehicle has nitro installed or not
			addVehicleUpgrade(source, 1010) -- Install the nitrous
		end
		setVehicleNitroActivated(source, true) -- Activate the nitro
	end
end
addEventHandler("onClientVehicleEnter", root, activateNitro) -- When the player enters a vehicle, it executes the function

See Also