ClareXoBearrx3R9 Posted January 16, 2015 Share Posted January 16, 2015 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 More sharing options...
InfamousSabre Posted January 17, 2015 Share Posted January 17, 2015 (edited) 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 January 17, 2015 by InfamousSabre Link to comment Share on other sites More sharing options...
ClareXoBearrx3R9 Posted January 17, 2015 Author Share Posted January 17, 2015 Was trying to avoid having to do that but it seems that what's necessary. Thanks! Link to comment Share on other sites More sharing options...
spadger Posted January 19, 2015 Share Posted January 19, 2015 (edited) 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(>imer); 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 January 19, 2015 by spadger Link to comment Share on other sites More sharing options...
NTAuthority Posted January 19, 2015 Share Posted January 19, 2015 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 leftas 1 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 More sharing options...
ClareXoBearrx3R9 Posted January 19, 2015 Author Share Posted January 19, 2015 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(>imer); 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! 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 More sharing options...
NorthHustler Posted December 9, 2017 Share Posted December 9, 2017 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now