Перейти к содержанию

Entity::getSpeed

Материал из RAGE MP Wiki Archive
Версия от 18:07, 1 мая 2024; imported>Shr0x (See also)
(разн.) ← Предыдущая версия | Текущая версия (разн.) | Следующая версия → (разн.)

Syntax

<syntaxhighlight lang="javascript">entity.getSpeed();</syntaxhighlight>

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

<syntaxhighlight lang="javascript">

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 } </syntaxhighlight>

See also