Quantcast
Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. The Cayo Perico Heist
      2. The Diamond Casino Heist
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Red Dead Online

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

    1. Red Dead Redemption 2

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

    1. Grand Theft Auto Series

    2. GTA VI

      1. St. Andrews Cathedral
    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. Guides & Strategies
      2. Help & Support
    6. GTA Vice City

      1. Guides & Strategies
      2. Help & Support
    7. GTA III

      1. Guides & Strategies
      2. 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. 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
    3. Gangs

    1. Announcements

    2. Support

    3. Suggestions

Sign in to follow this  
ClareXoBearrx3R9

Getting Vehicle Engine RPM

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 :)

Share this post


Link to post
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

Share this post


Link to post
Share on other sites
ClareXoBearrx3R9

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

Share this post


Link to post
Share on other sites
spadger

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

Share this post


Link to post
Share on other sites
NTAuthority

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

  • Like 1

Share this post


Link to post
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!

Share this post


Link to post
Share on other sites
NorthHustler

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.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • 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.