Vehicle::getVehicleModelMaxSpeed: Difference between revisions

From RAGE Multiplayer Wiki
(yay)
 
(Add other link for maxiumum speeds)
 
(8 intermediate revisions by 5 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">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">
<syntaxhighlight lang="javascript" highlight='2'>
todo
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
</syntaxhighlight>
</syntaxhighlight>
==See also==
==See also==
{{Vehicle_function_c}}
{{Vehicle_s_function_c}}
[[Category:Clientside API]]
[[Category:Clientside API]]
[[Category:TODO: Example]]
[[Category:TODO: Example]]

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