Quantcast
Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
    1. Welcome to GTAForums!   (85,908 visits to this link)

    2. News

    1. GTA Online

      1. Find Lobbies & Players
      2. Guides & Strategies
      3. Vehicles
      4. Content Creator
      5. Help & Support
    2. Crews

      1. Events
      2. Recruitment
    1. Grand Theft Auto Series

    2. GTA Next

    3. GTA V

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

      1. Episodes from Liberty City
      2. Multiplayer
      3. Guides & Strategies
      4. Help & Support
      5. GTA Mods
    5. GTA Chinatown Wars

    6. GTA Vice City Stories

    7. GTA Liberty City Stories

    8. GTA San Andreas

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    9. GTA Vice City

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    10. GTA III

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    11. Top Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    12. Wiki

      1. Merchandising
    1. GTA Modding

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Mod Showroom

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

      1. DYOM
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Red Dead Redemption 2

    2. Red Dead Redemption

    3. Rockstar Games

    1. Off-Topic

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

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

    2. Site 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

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

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
Sign in to follow this  

×

Important Information

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