Vehicle::getVehicleModelMaxSpeed: Difference between revisions

From RAGE Multiplayer Wiki
(Add other link for maxiumum speeds)
 
(6 intermediate revisions by 4 users not shown)
Line 1: Line 1:
Returns max speed (without mods) of the specified vehicle model in m/s.<br><br>For a full list, see here: pastebin.com/AUuHHK06<br><br>GET_VEHICLE_MODEL_*
__TOC__
 
==Syntax==
==Syntax==
<syntaxhighlight lang="javascript">mp.game.vehicle.getVehicleModelMaxSpeed(modelHash);</syntaxhighlight>
<syntaxhighlight lang="javascript">mp.game.vehicle.getVehicleModelMaxSpeed(modelHash);</syntaxhighlight>
=== Required Arguments ===
 
=== '''Required Arguments:''' ===
*'''modelHash:''' Model hash or name
*'''modelHash:''' Model hash or name
===Return value===
 
=== '''Return value'''===
*'''float'''
*'''float'''
-----------
*[https://www.gtabase.com/grand-theft-auto-v/vehicles/ Database with maximum speeds and more]
==Example==
==Example==
<syntaxhighlight lang="javascript" highlight='2'>
<syntaxhighlight lang="javascript" highlight='2'>
mp.events.add('render', () => {
mp.events.add('render', () => {
let maxs = mp.game.vehicle.getVehicleModelMaxSpeed(localPlayer.vehicle.model); //max speed of vehicle  
    let maxs = mp.game.vehicle.getVehicleModelMaxSpeed(mp.players.local.vehicle.model); //max speed of vehicle  
     let currents = localPlayer.vehicle.getSpeed(); // Current Speed
     let currents = mp.players.local.vehicle.getSpeed(); // Current Speed
     mp.game.graphics.drawText(`Speed: ${(currents * 3.6).toFixed(0)}/ ${((maxs * 3.6).toFixed(0))} km/h`, [0.5, 0.005], {   
     mp.game.graphics.drawText(`Speed: ${(currents * 3.6).toFixed(0)}/ ${((maxs * 3.6).toFixed(0))} km/h`, [0.5, 0.005], {   
         font: 7,  
         font: 7,  
Line 16: Line 24:
         scale: [0.5, 0.5],  
         scale: [0.5, 0.5],  
         outline: false
         outline: false
    }); // Displays on the top of the screen Speed: CurrentSpeed/Max speed in km/h
});
}); // Displays on the top of the screen Speed: CurrentSpeed/Max speed in km/h
</syntaxhighlight>
</syntaxhighlight>



Latest revision as of 15:49, 24 September 2020

Syntax

mp.game.vehicle.getVehicleModelMaxSpeed(modelHash);

Required Arguments:

  • modelHash: Model hash or name

Return value

  • float

Example

mp.events.add('render', () => {
    let maxs = mp.game.vehicle.getVehicleModelMaxSpeed(mp.players.local.vehicle.model); //max speed of vehicle 
    let currents = mp.players.local.vehicle.getSpeed(); // Current Speed
    mp.game.graphics.drawText(`Speed: ${(currents * 3.6).toFixed(0)}/ ${((maxs * 3.6).toFixed(0))} km/h`, [0.5, 0.005], {  
        font: 7, 
        color: [255, 255, 255, 185], 
        scale: [0.5, 0.5], 
        outline: false
 });
}); // Displays on the top of the screen Speed: CurrentSpeed/Max speed in km/h

See also