Vehicle::setEngineOn: Difference between revisions

From RAGE Multiplayer Wiki
No edit summary
No edit summary
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
Starts or stops the engine on the specified vehicle.<br><br>vehicle: The vehicle to start or stop the engine on.<br>value: true to turn the vehicle on; false to turn it off.<br>instantly: if true, the vehicle will be set to the state immediately; otherwise, the current driver will physically turn on or off the engine.<br>disableEngine: if true, player won't be able to start the engine
__TOC__
 
{{ClientsideJsFunction}}
 
Toggles the vehicle engine
 
{{JSContainer|
==Syntax==
==Syntax==
<syntaxhighlight lang="javascript">vehicle.setEngineOn(value, instantly, disableEngine);</syntaxhighlight>
<syntaxhighlight lang="javascript">vehicle.setEngineOn(toggle, instantly, otherwise);</syntaxhighlight>
 
=== Required Arguments ===
=== Required Arguments ===
*'''value:''' Boolean
*{{Required}}'''toggle:''' {{RageType|Boolean}}
*'''instantly:''' Boolean
*{{Required}}'''instantly:''' {{RageType|Boolean}} (Turns the engine instantly)
*'''disableEngine:''' Boolean
*{{Required}}'''otherwise:''' {{RageType|Boolean}} (Prevents player from manually toggling the engine)
 
===Return value===
===Return value===
*'''Undefined'''
*'''void'''
 
==Example==
==Example==
<syntaxhighlight lang="javascript">
{{ClientsideCode|
// todo
<pre>
</syntaxhighlight>
mp.events.add('playerStartEnterVehicle', (vehicle, seat) => {
    if (!vehicle.getIsEngineRunning()) {
        vehicle.setEngineOn(false, false, true); // Turns Engine off once enter the vehicle to prevent player from toggling the engine manually
    }
});
</pre>
}}
}}
 
==See also==
==See also==
{{Vehicle_function_c}}
{{Vehicle_function_c}}
[[Category:Clientside API]]
[[Category:Clientside API]]
[[Category:TODO: Example]]

Latest revision as of 21:22, 3 April 2020

Client-Side
Function

 JavaScript



Toggles the vehicle engine

JavaScript Syntax

Syntax

vehicle.setEngineOn(toggle, instantly, otherwise);

Required Arguments

  • *toggle: Boolean
  • *instantly: Boolean (Turns the engine instantly)
  • *otherwise: Boolean (Prevents player from manually toggling the engine)

Return value

  • void

Example

Client-Side
mp.events.add('playerStartEnterVehicle', (vehicle, seat) => { 
    if (!vehicle.getIsEngineRunning()) {
        vehicle.setEngineOn(false, false, true); // Turns Engine off once enter the vehicle to prevent player from toggling the engine manually
    }
});


See also