Vehicle::getVehicleModelMaxSpeed: Difference between revisions

From RAGE Multiplayer Wiki
No edit summary
(Add other link for maxiumum speeds)
 
(5 intermediate revisions by 4 users not shown)
Line 12: Line 12:
-----------
-----------


 
*[https://www.gtabase.com/grand-theft-auto-v/vehicles/ Database with maximum speeds and more]
*List of maximum vehicle [https://pastebin.com/AUuHHK06 speeds]


==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 25: 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