Entity::getSpeed: Difference between revisions

From RAGE Multiplayer Wiki
(yay)
 
No edit summary
Line 1: Line 1:
result is in meters per second<br><br>------------------------------------------------------------<br>So would the conversion to mph and km/h, be along the lines of this.<br><br>float speed = GET_ENTITY_SPEED(veh);<br>float kmh = (speed * 3.6);<br>float mph = (speed * 2.236936);<br>------------------------------------------------------------
==Syntax==
==Syntax==
<syntaxhighlight lang="javascript">entity.getSpeed();</syntaxhighlight>
<syntaxhighlight lang="javascript">entity.getSpeed();</syntaxhighlight>
=== Required Arguments ===
=== Required Arguments ===
* '''Entity:''' vehicle
===Return value===
===Return value===
*'''float'''
*'''MP/s (Meters per second)'''
 
==Speed Calculations==
*'''KM/H (Kilometers per hour):''' <code>speed*3.6</code>
*'''MP/H (:''' <code>speed*2.236936</code>
 
==Example==
==Example==
<syntaxhighlight lang="javascript">
<syntaxhighlight lang="javascript">
// todo
 
function getspeed() {
 
let vehicle = mp.players.local.vehicle
let speed = vehicle.getSpeed();
 
speed = speed*3.6 // Transform the speed in to KM/H
 
return speed; // returns the speed in KM/H
}
</syntaxhighlight>
</syntaxhighlight>
==See also==
==See also==
{{Entity_function_c}}
{{Entity_function_c}}
[[Category:Clientside API]]
[[Category:Clientside API]]
[[Category:TODO: Example]]

Revision as of 11:30, 30 November 2017

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 (: speed*2.236936

Example

function getspeed() {

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

speed = speed*3.6 // Transform the speed in to KM/H

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

See also