Jump to content
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. The Criminal Enterprises
      2. Updates
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Red Dead Online

      1. Blood Money
      2. Frontier Pursuits
      3. Find Lobbies & Outlaws
      4. Help & Support
    3. Crews

    1. Grand Theft Auto Series

      1. Bugs*
      2. St. Andrews Cathedral
    2. GTA VI

    3. GTA V

      1. Guides & Strategies
      2. Help & Support
    4. GTA IV

      1. The Lost and Damned
      2. The Ballad of Gay Tony
      3. Guides & Strategies
      4. Help & Support
    5. GTA San Andreas

      1. Classic GTA SA
      2. Guides & Strategies
      3. Help & Support
    6. GTA Vice City

      1. Classic GTA VC
      2. Guides & Strategies
      3. Help & Support
    7. GTA III

      1. Classic GTA III
      2. Guides & Strategies
      3. Help & Support
    8. Portable Games

      1. GTA Chinatown Wars
      2. GTA Vice City Stories
      3. GTA Liberty City Stories
    9. Top-Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    1. Red Dead Redemption 2

      1. PC
      2. Help & Support
    2. Red Dead Redemption

    1. GTA Mods

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Red Dead Mods

      1. Documentation
    3. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    4. Featured Mods

      1. Design Your Own Mission
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Rockstar Games

    2. Rockstar Collectors

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Movies & TV
      5. Music
      6. Sports
      7. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    1. Announcements

    2. Support

    3. Suggestions

*DO NOT* SHARE MEDIA OR LINKS TO LEAKED COPYRIGHTED MATERIAL. Discussion is allowed.

Getting Vehicle Engine RPM


ClareXoBearrx3R9
 Share

Recommended Posts

ClareXoBearrx3R9

Hello everyone,

 

Does anyone know of a method to get the engine RPM of a vehicle? I'd like to work on a tachometer but it seems that no natives exist for such a function. I'm a C and C++ programmer, so hopefully some combination of methods within the ScriptHook SDK that would work exist.

 

I looked around and found some GetVehicleRPM() in the .NET SDK that appears to access data from the memory but I'm not familiar with .NET.

 

Thanks in advance :)

Link to comment
Share on other sites

InfamousSabre

Looks like you'll need to access the data from memory then. Since the .Net ScriptHook does it, and its source is available, I'd check the .Net ScriptHook's source code.

Edited by InfamousSabre
Link to comment
Share on other sites

ClareXoBearrx3R9

Was trying to avoid having to do that but it seems that what's necessary. Thanks!

Link to comment
Share on other sites

Hello everyone,

 

Does anyone know of a method to get the engine RPM of a vehicle? I'd like to work on a tachometer but it seems that no natives exist for such a function. I'm a C and C++ programmer, so hopefully some combination of methods within the ScriptHook SDK that would work exist.

 

I looked around and found some GetVehicleRPM() in the .NET SDK that appears to access data from the memory but I'm not familiar with .NET.

 

Thanks in advance :)

extern float GET_VEHICLE_ENGINE_REVS(int vehicle);

Works on new natives only, so PC version ;)

Here's what i use for a simple displayer using scocl to compile.

if ( DOES_VEHICLE_EXIST(G_MYVEH) ){	static float speed = 0.0f;	static uint delay = 0;	GET_GAME_TIMER(&gtimer);	if ( delay < gtimer )	{		delay = gtimer + 333;		GET_CAR_SPEED(G_MYVEH, &speed);		speed *= 2.94f;	}	int revs = 0;	float frevs = GET_VEHICLE_ENGINE_REVS(G_MYVEH);	frevs *= 10.0f;	revs = (int) frevs;	register float x = 0.08f;	register int i;	for ( i = 0; i < revs; ++i )	{		if ( i > 8 ) SetFont( 255, 0, 0 );		else if ( i > 6 ) SetFont( 255, 213, 0 );		else SetFont( 0, 255, 0 );		DISPLAY_TEXT_WITH_LITERAL_STRING(x, 0.68f, "STRING", ">");		x += 0.008f;	}	SetFont( 33, 148, 219 );	DISPLAY_TEXT_WITH_LITERAL_STRING(0.08f, 0.70f, "STRING", "Gear:");	SetFont( 219, 104, 33 );	DISPLAY_TEXT_WITH_NUMBER(0.135f, 0.70f, "NUMBER", GET_VEHICLE_GEAR(G_MYVEH));	SetFont( 33, 148, 219 );	DISPLAY_TEXT_WITH_LITERAL_STRING(0.08f, 0.72f, "STRING", "Mph:");	SetFont( 219, 104, 33 );	DISPLAY_TEXT_WITH_NUMBER(0.135f, 0.72f, "NUMBER", (int) speed);	DRAW_CURVED_WINDOW(0.0752f, 0.679f, 0.089f, 0.0645f, 255);}
Edited by spadger
Link to comment
Share on other sites

Works on new natives only, so PC version ;)

?!

 

it's a DLC2 function, should work fine on consoles if you just use the non-altered hash (i.e. the reproducible one) for it, though they might only be enabled when setup2 indicates episode 2

SsZgxdL.png

Inactive in GTA/R* title modification indefinitely pursuant to a court order obtained by TTWO. Good job acting against modding!

Link to comment
Share on other sites

ClareXoBearrx3R9

 

Hello everyone,

 

Does anyone know of a method to get the engine RPM of a vehicle? I'd like to work on a tachometer but it seems that no natives exist for such a function. I'm a C and C++ programmer, so hopefully some combination of methods within the ScriptHook SDK that would work exist.

 

I looked around and found some GetVehicleRPM() in the .NET SDK that appears to access data from the memory but I'm not familiar with .NET.

 

Thanks in advance :)

extern float GET_VEHICLE_ENGINE_REVS(int vehicle);

Works on new natives only, so PC version ;)

Here's what i use for a simple displayer using scocl to compile.

 

if ( DOES_VEHICLE_EXIST(G_MYVEH) ){	static float speed = 0.0f;	static uint delay = 0;	GET_GAME_TIMER(&gtimer);	if ( delay < gtimer )	{		delay = gtimer + 333;		GET_CAR_SPEED(G_MYVEH, &speed);		speed *= 2.94f;	}	int revs = 0;	float frevs = GET_VEHICLE_ENGINE_REVS(G_MYVEH);	frevs *= 10.0f;	revs = (int) frevs;	register float x = 0.08f;	register int i;	for ( i = 0; i < revs; ++i )	{		if ( i > 8 ) SetFont( 255, 0, 0 );		else if ( i > 6 ) SetFont( 255, 213, 0 );		else SetFont( 0, 255, 0 );		DISPLAY_TEXT_WITH_LITERAL_STRING(x, 0.68f, "STRING", ">");		x += 0.008f;	}	SetFont( 33, 148, 219 );	DISPLAY_TEXT_WITH_LITERAL_STRING(0.08f, 0.70f, "STRING", "Gear:");	SetFont( 219, 104, 33 );	DISPLAY_TEXT_WITH_NUMBER(0.135f, 0.70f, "NUMBER", GET_VEHICLE_GEAR(G_MYVEH));	SetFont( 33, 148, 219 );	DISPLAY_TEXT_WITH_LITERAL_STRING(0.08f, 0.72f, "STRING", "Mph:");	SetFont( 219, 104, 33 );	DISPLAY_TEXT_WITH_NUMBER(0.135f, 0.72f, "NUMBER", (int) speed);	DRAW_CURVED_WINDOW(0.0752f, 0.679f, 0.089f, 0.0645f, 255);}

 

Wow - thanks!!! I'll definitely give that a try! :D

 

On a sidenote, I did find that native previously but was disappointed to find that it was only in TBoGT. Regardless, I'll give it a shot; again!

Link to comment
Share on other sites

  • 2 years later...

Er, what value would GET_VEHICLE_ENGINE_REVS output, if the car revs are, say, 2000? Is there a Rockstar version of the revs? I'm creating a script, and I was going to use if (VehicleRevs < 2000) etc. but... Would the revs be that high? Would it output just 2?

 

Any help would be greatly appreciated.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.