Entity::getSpeed: Difference between revisions

From RAGE Multiplayer Wiki
No edit summary
 
(7 intermediate revisions by 3 users not shown)
Line 3: Line 3:


=== Required Arguments ===
=== Required Arguments ===
* '''Entity:''' vehicle
* '''Entity:''' '''<font color='red'>vehicle</font>'''


===Return value===
===Return value===
Line 10: Line 10:
==Speed Calculations==
==Speed Calculations==
*'''KM/H (Kilometers per hour):''' <code>speed*3.6</code>
*'''KM/H (Kilometers per hour):''' <code>speed*3.6</code>
*'''MP/H (:''' <code>speed*2.236936</code>
*'''MP/H (Miles per hour):''' <code>speed*2.236936</code>


==Example==
==Example==
Line 20: Line 20:
let speed = vehicle.getSpeed();
let speed = vehicle.getSpeed();


speed = speed*3.6 // Transform the speed in to KM/H
speed = speed * 3.6; // Transform the speed into KM/H
// If you want a realistic calculation for the vehicle speed use: speed = Math.ceil(speed * (speed / 20) * 2); <- this will raise up to 300 km/h for a T20, but you can still easily cruise around with 60 km/h


return speed; // returns the speed in KM/H
return speed; // returns the speed in KM/H
}
}
</syntaxhighlight>
</syntaxhighlight>
==See also==
==See also==
{{Entity_function_c}}
{{Entity_definition_c}}
[[Category:Clientside API]]
[[Category:Clientside API]]

Latest revision as of 18:07, 1 May 2024

Syntax

entity.getSpeed();

Required Arguments

  • Entity: vehicle

Return value

  • MP/s (Meters per second)

Speed Calculations

  • KM/H (Kilometers per hour): speed*3.6
  • MP/H (Miles per hour): speed*2.236936

Example

function getspeed() {

let vehicle = mp.players.local.vehicle
let speed = vehicle.getSpeed();

speed = speed * 3.6; // Transform the speed into KM/H
// If you want a realistic calculation for the vehicle speed use: speed = Math.ceil(speed * (speed / 20) * 2); <- this will raise up to 300 km/h for a T20, but you can still easily cruise around with 60 km/h

return speed; // returns the speed in KM/H
}

See also