Vehicle::getEngineHealth: Difference between revisions

From RAGE Multiplayer Wiki
 
(6 intermediate revisions by 4 users not shown)
Line 24: Line 24:
Note*: Returns 1000.0 if the function is unable to get the address of the specified vehicle or if it's not a vehicle.<br>
Note*: Returns 1000.0 if the function is unable to get the address of the specified vehicle or if it's not a vehicle.<br>
==Syntax==
==Syntax==
<syntaxhighlight lang="javascript">vehicle.getEngineHealth();</syntaxhighlight>
<pre>vehicle.getEngineHealth();</pre>
=== Required Arguments ===
=== Required Arguments ===
===Return value===
===Return value===
*'''float'''
*'''float'''
==Example==
==Example==
<syntaxhighlight lang="javascript">
let engineHealth = vehicle.getEngineHealth();


mp.gui.chat.push(`engine health: ${engineHealth}`);
{{ClientsideCode|
</syntaxhighlight>
<pre>
function getEngineHealth() {
    let vehicle = mp.players.local.vehicle;
    let engineHealth = vehicle.getEngineHealth();
    mp.gui.chat.push(`engine health: ${engineHealth}`);
 
    return engineHealth; // returns the value of the engine health as a float
}
</pre>
}}


==See also==
==See also==
{{Vehicle_function_c}}
{{Vehicle_definition_c}}
[[Category:Clientside API]]
[[Category:Clientside API]]
[[Category:TODO: Example]]
[[Category:TODO: Example]]

Latest revision as of 11:37, 9 May 2024

Engine Health Status
1000 Perfect - Undamaged
< 1000 Damaged
< 400 Engine is smoking and losing functionality
0 Engine stops working and car is not drivable
< 0 Engine catches fire, health rapidly declines and blows up seconds later

Maximum: 1000
Minimum: -4000
Note*: Returns 1000.0 if the function is unable to get the address of the specified vehicle or if it's not a vehicle.

Syntax

vehicle.getEngineHealth();

Required Arguments

Return value

  • float

Example

Client-Side
function getEngineHealth() {
    let vehicle = mp.players.local.vehicle;
    let engineHealth = vehicle.getEngineHealth();
    mp.gui.chat.push(`engine health: ${engineHealth}`);

    return engineHealth; // returns the value of the engine health as a float
}

See also