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. Los Santos Tuners
      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. Red Dead Redemption 2

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

    1. Grand Theft Auto Series

      1. 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. 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
    1. Announcements

      1. GTANet 20th Anniversary
    2. Support

    3. Suggestions

[REL|SRC] SCM and DirectX Hooking Source Code


Spooky
 Share

Recommended Posts

Yes, your right, you can use d3dx9.lib instead of d3dx8.lib, although it will bloat the DLL due to all the advancements in the 9.0 DirectX version. Word of advice; don't play around with things you're not suppose to, it'll only come back to haunt you in the end.

 

In one of my earlier posts I also mentioned d3d8.lib, I've been including that in the project settings for an unknown reason, but apparently you don't need it. Sorry for any misconceptions or nuisances. This shouldn't actually cause any issues, but it's not necessary to include this.

 

Also, in MSVC++, including d3dx9.lib instead of d3dx8.lib makes the DLL size approximately 1.57 MB, opposed to 848 KB when using d3dx8.lib.

 

I was just playing around with the script commands for a while. If anyone wants to update their list with some extra opcodes here's some new ones for custom.cpp:

I used the d3dx9.lib because Microsoft said to do so for MSVC 6.0. I actually compiled the project with the name d3d8.dll but was interested to note you could name it d3d9.dll and the game would still find it.

 

This extra script command stuff is great, I'll have a muck about with it later. I've not done any scm stuff before, am i right in thinking that scm files are basically a list of functions to be called, with the parameters to be passed? And more importantly, can I something like Spookies code to access anything outwith the opcode handler, things like collision detection and player xyz movement?

Link to post
Share on other sites

There are numerous ways of using the SCM hook, when I was playing around with it last night, as I believe I mentioned in my previous post, I merely threw all the script commands (opcodes) into a function in Custom.cpp, which contains much of the data that is used for the interface, i.e. CustomRender(...). All I did was threw in a call to my custom function in this function, since this function is executed quite frequently (whenever drawing routines are required) so it would execute any of the opcodes that need constant updating. Here's essentially what I mean:

 

 

void CustomRender(IDirect3DDevice8* pDevice){CustomScript();if ((pSpeedoSprite) && (pSpeedoTex) && (pNeedleSprite) && (pNeedleTex))	// If we have the goods...{ ScriptCommand(&set_weather, WEATHER_STORM); if ((*dwCanPlayRadio) && (!*bInMenu))	// If we're in the game (not in the menu)... { 	/*   Why can't we use just (!*bInMenu)?   Well, bInMenu is 1 while in the menu and 0 while in-game,   BUT as the value isn't initalized until we reach the main   menu, it's 0 when this function first gets executed.   Theres bound to be a better "InGame" variable about,   but until I go looking for it, this'll do. 	*/ 	if (ScriptCommand(&player_in_car, PLAYER_CHAR))  // Is the player in a car?... 	{   float fCurrentSpeed = 0.0;   DWORD dwPlayerCar = 0;   ScriptCommand(&get_player_car, PLAYER_CHAR, &dwPlayerCar);	// Get the player's car.   ScriptCommand(&make_car_heavy, &dwPlayerCar, 1);  	// Make the vehicle heavy.   if (!ScriptCommand(&car_stopped, &dwPlayerCar))    // Is the car moving?...   {   	ScriptCommand(&get_car_speed, &dwPlayerCar, &fCurrentSpeed);	// Get the car speed    }   fCurrentSpeed *= fSpeedoMultiplier;  // (m/s * 2.24) = mph   D3DSURFACE_DESC Desc;   pSpeedoTex->GetLevelDesc(0, &Desc);  	// Get the primary texture level description.   if (Desc.Format == D3DFMT_A8R8G8B8)  	// This should always be true, but blah.   {   	D3DLOCKED_RECT Rect;   	pSpeedoTex->LockRect(0, &Rect, NULL, 0);	// Lock the texture. Error checking here maybe? :s   	DWORD* pTexData = (DWORD*)Rect.pBits;  // Pointer to the raw texture data.   	int PixRow = Rect.Pitch / 4;    // Pitch of the texture in pixels.   	int nCurrentSpeed;   	_asm   	{     finit    	// Initialize FPU     fld  fCurrentSpeed	// Load speed from float     fistp	nCurrentSpeed	// Store speed in int   	}   	if (nCurrentSpeed > 999) nCurrentSpeed = 999;  // Maybe they're driving the bat mobile!   	if (fCurrentSpeed > 200.0f) fCurrentSpeed = 200.0f;	// We don't want the needle looping.   	int nDigit = nCurrentSpeed / 100;    	// How many hundreds of miles per hour are we going?   	DrawDigit(pTexData, PixRow, 91, 149, nDigit);  // Draw first speed digit   	nCurrentSpeed -= (nDigit * 100);    	// Subtract the hundreds   	nDigit = nCurrentSpeed / 10;      // Get tenths   	DrawDigit(pTexData, PixRow, 101, 149, nDigit);  // Draw second speed digit   	nDigit = nCurrentSpeed - (nDigit * 10);    // Subtract the tens   	DrawDigit(pTexData, PixRow, 111, 149, nDigit);  // Draw third speed digit   	BYTE* nGear = (BYTE*)GameGetVehicle(dwPlayerCar);	// Get currently driven car's structure.   	nGear += 520;          // VEHICLE_STRUCT+520 = Gear   	DrawDigit(pTexData, PixRow, 72, 149, *nGear);  // Draw gear digit   	pSpeedoTex->UnlockRect(0);      	// Unlock the texture.   }   pSpeedoSprite->Begin();	// This sets up render states and stuff. See the SDK dox.   // Draw the speedometer sprite.   pSpeedoSprite->Draw(pSpeedoTex, NULL, &vScaling, NULL, 0.0f, &vTranslation, 0xFFFFFFFF);   // Draw the needle sprite.   pNeedleSprite->Draw(pNeedleTex, NULL, &vScaling, &vRotCenter, fNeedleZero-(fNeedleUnit*fCurrentSpeed), &vNeedleTranslation, 0xFFFFFFFF);   pSpeedoSprite->End();	// Cleanup. Reset render states etc. See SDK dox.    	} }}}void CustomScript(){ScriptCommand(&set_weather, WEATHER_STORM);ScriptCommand(&set_current_time, 0, 0);if (ScriptCommand(&is_key_pressed, 0, 14)){ ScriptCommand(&set_gamespeed, 0.3);}else if (ScriptCommand(&is_key_pressed, 0, 6)){ ScriptCommand(&set_gamespeed, 0.3);}else if (ScriptCommand(&is_key_pressed, 0, 16)){ ScriptCommand(&set_gamespeed, 1.1);}}

 

Now I realize most people will tell you this is quite inefficient since opcodes such as set_weather and set_current_time (the clock remains at 00:00 during gameplay) only need to be called once, I believe the is_key_pressed opcodes must be embedded in a thread, which means that each time CustomRender(...) is called both set_weather and set_current_time are called which is improper use of CPU; but I was just messing around, so sue me.

 

The above CustomScript() function contains the simple, as can be seen, idea I mentioned previously, using the game's is_key_pressed function, which I added to the GameScripting.h (see my previous post), to check and see if a key is being pressed, and if it is modify the gamespeed to the appropriate float value, 1 being normal in a range of 0 - 2, 0 being nearly stopped and 2 being double the normal speed. Simple enough I hope.

 

Here you can see that in slow motion you can get some nice clips of carnage:

 

 

user posted image

 

user posted image

Ocram88, I believe you are referring to a .cfg file that contains opcodes that you want executed at runtime. You could possibly try adding a runtime interpreter to the code so anything within that configuration file is read by the script hook. Just a thought.

Link to post
Share on other sites

woot!

 

I stuck in

 

 

else if (ScriptCommand(&is_key_pressed, 0, 15)){    ScriptCommand(&create_player, 0, 1.0, 30.0, 1.0, PLAYER_CHAR);}

 

 

and had fun trying to control a bunch of Tommies on the golf course

Link to post
Share on other sites

Like this? biggrin.gif

http://gari.marway.org/~squiddy/clones16.jpg

 

Reminds me at Matrix Revolutions. A little bit. biggrin.gif

http://gari.marway.org/~squiddy/clones19.jpg

 

Edit: Ah, i forgot.

I was trying to get the actual position of the player. Seeing the actor_struct in gamescripting.h i tried to pass a pointer at the PLAYER_CHAR to retrieve the positions.

But i get compatibilitie errors. Can somebody post a bit code that works? smile.gif

Edited by _Squiddy_
Link to post
Share on other sites

Just add this code to GameScripting.h:

 

 

const SCRIPT_COMMAND get_player_coords  	= { 0x0054, "vfff" };	// var_player, x, y, z

 

Make sure you use PLAYER_CHAR for the first parameter. Simple enough.

 

Ever wanted to be as rich as Bill Gates?

 

 

const SCRIPT_COMMAND add_to_player_money  = { 0x0109, "vi" };  // PLAYER_CHAR, intScriptCommand(&add_to_player_money, PLAYER_CHAR, 20000); // Add $20000 each time called.

 

This essentially just adds $20000 each time the command is called, if you embed it in the CustomRender(...) function then you can just watch your money sky rocket.

 

 

user posted image

Yet another update. Just playing around with some explosions, and you can get some pretty cool results.

 

 

const SCRIPT_COMMAND create_explosion  	= { 0x020C, "fffi" };	// x, y, z, intvoid Pyro();Pyro(){float i, j;i = (float) (rand() % 30);j = (float) ((rand() + 100) % 30);ScriptCommand(&create_explosion, i, j, 30.0, 1);}

 

It's always fun playing with fire.

 

 

user posted image

 

Pyro(){float i, j;i = (float) (rand() % 100);j = (float) ((rand() + 100) % 100);ScriptCommand(&create_explosion, i, j, 30.0, 1);}

 

 

user posted image

And yet again, this time playing around with multiple types of explosions to create some nice results.

 

 

Pyro(){float i, j;i = (float) (rand() % 50);j = (float) ((rand() + 100) % 50);ScriptCommand(&create_explosion, i - 10, j, 30.0, 0);ScriptCommand(&create_explosion, i + 10, j, 30.0, 1);ScriptCommand(&create_explosion, i - 5, j, 30.0, 2);ScriptCommand(&create_explosion, i + 5, j, 30.0, 3);}

 

 

user posted image

Anyhow, just some fun stuff. You could almost create a realistic firefighting mission using this, assuming you distribute the flames across a larger area, I was just using the golf course for effect, and as long as you track the coordinates of the fires as they are created and perhaps use blips on the radar to define where they are. It would be a lot more fun trying to put out a forest fire, like in the first picture, then merely putting out vehicle fires.

 

Another humerous event occurred while I was trying to create a larger fire.

 

 

user posted image

 

user posted image

 

user posted image
Edited by Kryptos
Link to post
Share on other sites

ugh, i FINALLY got it to compile, and work ingame. i had all the same problems as cowpat.

 

Anyway, off to see what i can do with this. looks like you guys have got some nice progress going already biggrin.gif

 

is there a limit to how many players can be spawned before the game crashes?

Edited by ashdexx
Link to post
Share on other sites

 

Just add this code to GameScripting.h:

 

 

const SCRIPT_COMMAND get_player_coords  	= { 0x0054, "vfff" };	// var_player, x, y, z

 

Make sure you use PLAYER_CHAR for the first parameter. Simple enough.

Actually the params for this would be "vvvv", and you should pass PLAYER_CHAR then 3 pointers to floats...

 

e.g.

GameScripting.h

 

const SCRIPT_COMMAND get_player_coords  	= { 0x0054, "vvvv" };	// var_player, x, y, z

 

Custom.cpp

 

float fX, fY, fZ;ScriptCommand(&get_player_coords, PLAYER_CHAR, &fX, &fY, &fZ);conprintf("Player is at [%f, %f, %f]", fX, fY, fZ);

 

 

Otherwise it wouldn't be able to return the coord values, and would probably crash.

Link to post
Share on other sites

 

is there a limit to how many players can be spawned before the game crashes?

I read a whiles back it was 60 actors max

 

...but looking at Squiddy's images I wonder if that's true.

 

btw, those keypress values (L Shift=16, RTN=15, etc), are they germaine only to GTA or are they universal to keyboards in general, and where can I find a list of them?

Edited by Cowpat
Link to post
Share on other sites

is there a limit to how many players can be spawned before the game crashes?

I read a whiles back it was 60 actors max

I tested it before, and my game crashed after spawning 139 actors, so including the player actor that would be a limit of 140 actors, loads of fun stuff possible with so many actors smile.gif

Link to post
Share on other sites

is there a limit to how many players can be spawned before the game crashes?

I read a whiles back it was 60 actors max

I tested it before, and my game crashed after spawning 139 actors, so including the player actor that would be a limit of 140 actors, loads of fun stuff possible with so many actors smile.gif

My limit adjuster has a value "Peds" which is 140 by default, I assume if you increase it you can create much more... smile.gif

Link to post
Share on other sites

You could, but wouldnt that many more actors tend to slow the game down?

 

Granted, i would love to see them all trying to kill each other (hoo-wee!!) but i dont want 5fps either. Gotta find a reasonable limit. Of course the idea of a 200-person firefirefight does have its allure devil.gif

Link to post
Share on other sites

is there a limit to how many players can be spawned before the game crashes?

I read a whiles back it was 60 actors max

I tested it before, and my game crashed after spawning 139 actors, so including the player actor that would be a limit of 140 actors, loads of fun stuff possible with so many actors smile.gif

gta-vc has an internal limit for cars / peds / planes etc of 150 objects, it reserves first 10 for 10 players (broken multiplayer..) what gives you 140 objects, then subtract 3 planes, one player, some cars..

 

Link to post
Share on other sites

Sorry about that spooky. Yeah, that makes more sense. I didn't actually verify the code, I merely wrote it based on the entry for the database.

 

If I get a chance later I might try to make a more advanced jet pack mod, similar to that of LithJoe's except I want to extend the functionality to the z axis so the player moves exactly in whatever direction they are looking; opposed to merely parsing along the x and y axis as LithJoe did. This can all be achieved through relatively simplistic trigonumetric functions using math.h. I'm interested to see what can truly be accomplished with this external hook, since the entire arsenal of the C++ language is now at our disposal.

 

I forgot to add one little tidbit of code. This is essentially a speed governor, just to add that extra aspect of realism.

 

 

const SCRIPT_COMMAND stop_car    	= { 0x02D4, "v" };  // var_carif (fCurrentSpeed >= (120.0 / 2.24)) ScriptCommand(&stop_car, &dwPlayerCar); // If the car goes above 120 MPH shut off the engine.

 

It merely shuts down the engine when the vehicle travels at, or in excess of, 120 MPH.

Edited by Kryptos
Link to post
Share on other sites

 

I wonder if someone would be so kind as to suggest what's wrong. I can create newplayers and any of the actors/peds in default.ide, but I still can't get the player coordinates right. If I start a game at the beach hotel hideout and create a new player, I always spawn at the little cul de sac in Vice Point, and If I spawn a ped instead, the peds spawn at the same place and I have to go over to Vice Point if I want to see them.

 

float fX=0,fY=0,fZ=0;//can be init to 0 or not, makes no difference

 

ScriptCommand(&get_player_coords, PLAYER_CHAR, &fX, &fY, &fZ);

 

ScriptCommand(&create_player, 0, fX, fY, fZ, PLAYER_CHAR); or

ScriptCommand(&create_actor, 0, 77, fX, fY, fZ, PLAYER_ACTOR);//skater babe

 

 

I'm getting the player coords both after the keypress, and in CustomRender()

after !*bInMenu has been tested, so the player coords should have been picked up. Any Ideas?

Link to post
Share on other sites

This might have already been posted, but the speedometer (and, I assume, any other 2d graphic placed on the screen using the same code) disappears temporarily while adjusting the radio station.

 

I wish I could help find the bug, but I don't know much C++ and I know even less VC .scm scripting.

Link to post
Share on other sites

The reason the graphics flicker when the radio station is changed is because of this code:

 

 

if ((*dwCanPlayRadio) && (!*bInMenu))	// If we're in the game (not in the menu)...

 

This isn't really a bug, although it may appear to be. The if statement checks to see if the player is in a car and can play the radio and makes sure that the radio isn't playing because the player is viewing the radio menu option on the pause screen (this causes a game crash). To fix this a better pointer address, or something to that degree, is required to ensure the player is in a vehicle so the speedometer isn't displayed while the player is on foot.

 

Sorry Cowpat, I'd help you out with the get_player_coords problem except I can't get the DLL to run with the script command. Damn thing. It crashes after going through the movie, before loading the intro.txd, or whatever the file is called.

 

 

float fltPosX, fltPosY, fltPosZ;	// Player coordinates.ScriptCommand(&get_player_coords, PLAYER_CHAR, &fltPosX, &fltPosY, &fltPosZ);

 

Edited by Kryptos
Link to post
Share on other sites

You mean:

 

 

const SCRIPT_COMMAND is_player_driving  	= { 0x00E0, "v" };  // PLAYER_CHARif (ScriptCommand(&is_player_driving, PLAYER_CHAR)); // Check to see if player is in car.

 

The utility already implements this:

 

 

if (ScriptCommand(&player_in_car, PLAYER_CHAR))  // Is the player in a car?...

 

Which also checks to see if the player is in a car. Sorry, a moderator can remove this post since it's seemingly pointless. I should have looked into the code again before posting off the top of my head.

Edited by Kryptos
Link to post
Share on other sites

Problem: when using -

 

void Pyro();Pyro(){float i, j;i = (float) (rand() % 30);j = (float) ((rand() + 100) % 30);ScriptCommand(&create_explosion, i, j, 30.0, 1);}

 

 

i get:

 

\Custom.cpp(371) : error C2556: 'int __cdecl Pyro(void)' : overloaded function differs only by return type from 'void __cdecl Pyro(void)'

\Custom.cpp(368) : see declaration of 'Pyro'

\Custom.cpp(371) : error C2371: 'Pyro' : redefinition; different basic types

\Custom.cpp(368) : see declaration of 'Pyro'

 

help please

Link to post
Share on other sites

Where did you define the Pyro() function? It's easier to keep the function prototypes in Custom.h. After doing that add a call to it from the CustomRender() function so it executes frequently, or a derivation of that.

 

Oh, ashdexx, you merely forgot to put 'void' before pyro.

 

Here's my current function in Custom.cpp with the area where you encountered the problem:

 

 

void Pyro() // Your problem was here, you forgot 'void'.{float i, j;/*The modulus of 25 is used in this scenario to ensure that thegenerated coordinates are nothing more then 25, thus everythingis isolated to the golf course for simplicity's sake. If you wantfires to randomly generate around Vice merely use %1500, orwhatever the appropriate boundary is.*/i = (float) (rand() % 25);j = (float) ((rand() + 10) % 25);ScriptCommand(&create_explosion, i + 5, j, 30.0, 1);ScriptCommand(&create_explosion, i - 5, j, 30.0, 1);ScriptCommand(&create_explosion, i, j + 5, 30.0, 1);ScriptCommand(&create_explosion, i, j - 5, 30.0, 1);}

 

And the prototype in Custom.h:

 

 

void Pyro();

 

From there I make a call to the function out of my custom script function, which contains all the code I want executed at runtime, as well as any threaded functions, or unthreaded functions for that matter, that I want to use. I suggest people use this method since it's much easier to maintain a homebrewed function then adding tidbits to an already populated one.

Edited by Kryptos
Link to post
Share on other sites

Here's what i have, with the code around it kept in, so you know exactly where i have it pasted:

 

Custom.h...void CustomRender(IDirect3DDevice8* pDevice);void CustomReset();void Pyro();#endif

 

 

custom.cpp...   pSpeedoSprite->Begin();	// This sets up render states and stuff. See the SDK dox.   // Draw the speedometer sprite.   pSpeedoSprite->Draw(pSpeedoTex, NULL, &vScaling, NULL, 0.0f, &vTranslation, 0xFFFFFFFF);   // Draw the needle sprite.   pNeedleSprite->Draw(pNeedleTex, NULL, &vScaling, &vRotCenter, fNeedleZero-(fNeedleUnit*fCurrentSpeed), &vNeedleTranslation, 0xFFFFFFFF);   pSpeedoSprite->End();	// Cleanup. Reset render states etc. See SDK dox. 	} }}}void Pyro();Pyro(){float i, j;i = (float) (rand() % 30);j = (float) ((rand() + 100) % 30);ScriptCommand(&create_explosion, i, j, 30.0, 1);}

 

 

 

From there I make a call to the function out of my custom script function, which contains all the code I want executed at runtime, as well as any threaded functions, or unthreaded functions for that matter, that I want to use. I suggest people use this method since it's much easier to maintain a homebrewed function then adding tidbits to an already populated one.

yep. i am officially lost. Probably because im looking for more of a "cut this and paste it here" type of example, and know very little about this to begin with. my apologies for any annoying questions.

Link to post
Share on other sites

Okay, put the call to the Pyro() function here:

 

 

void CustomRender(IDirect3DDevice8* pDevice){CustomScript();if ((pSpeedoSprite) && (pSpeedoTex) && (pNeedleSprite) && (pNeedleTex))	// If we have the goods...{ Pyro(); // <- PUT HERE if ((*dwCanPlayRadio) && (!*bInMenu))	// If we're in the game (not in the menu)... { 	// Ignore this stuff... }}}

 

That should work. And you put the prototype of Pyro(), i.e. 'void Pyro();', twice when you should have only put it once in Custom.h. In other words, get rid of this:

 

 

Custom.cpp...// void Pyro(); <- GET RID OF THISvoid Pyro() <- ADDED VOID TO THIS{float i, j;i = (float) (rand() % 30);j = (float) ((rand() + 100) % 30);ScriptCommand(&create_explosion, i, j, 30.0, 1);}

 

That should hopefully fix your problem.

Link to post
Share on other sites

Touche! biggrin.gif

yea, it works. thanks a bunch. i did have to make one more alteration though.

i had to comment out this:

 

void CustomRender(IDirect3DDevice8* pDevice)

{

//CustomScript(); this had to go

if ((pSpeedoSprite

 

otherwise, this is wicked. thanks again!

Link to post
Share on other sites

hi,

does anyone know if the DirectX Hook will work in Delphi and how? if anyone know this plz help me thx

Edited by Serero-Kuh
Link to post
Share on other sites

hi,

does anyone know if the DirectX Hook will work in Delphi and how? if anyone know this plz help me thx

i think ST.MU is working on it..

 

Link to post
Share on other sites

hi,

does anyone know if the DirectX Hook will work in Delphi and how? if anyone know this plz help me thx

i think ST.MU is working on it..

will he translate this from C++ to Delphi? i hope so wink.gif

Link to post
Share on other sites

 

You can change the speed to kmh by editing the file Speedo.cfg, changing mul_speed 2.24 to mul_speed 3.6 - The MPH text on the speedometer will stay there, but the speed is now read as kmh.

 

Analog Speedometer now supports kmh

 

user posted image

 

Because many germans asked about kmh support i stopped working on my other mini mods and added the support.

As you will see inside the cfg you can change the speedo multiplier for both units. Switching kmh / mph is possible by changing dsp_speed.

 

I hope that will make some people more happier. biggrin.gif

 

Download

Right click -> Save as .zip

Edited by _Squiddy_
Link to post
Share on other sites

hi,

does anyone know if the DirectX Hook will work in Delphi and how? if anyone know this plz help me thx

i think ST.MU is working on it..

will he translate this from C++ to Delphi? i hope so wink.gif

I was talking about translating the scm hook, not the whole DirectX stuff, since there's no real SDK for Delphi. Haven't started on that yet, though.

 

Good work, Squiddy!

Link to post
Share on other sites

 

# Analog Speedometer Config# Speed multiplier#   Use 2.24 for mph.mul_mph_speed 2.24#   Use 3.60 for kmh.mul_kmh_speed 3.60# Speed Display#   0 = mph, 1 = kmhdsp_speed 1

 

As I can't see the code for this right now I'm just assuming everything beyond this point. If you are defining dsp_speed in the configuration file there's no real point in defining both KMH and MPH as well, as this can be done directly within the code and merely causes clutter in the configuration file. Perhaps an extra definition could be added, for example, the configuration file could appear as:

 

 

# Speed Display#   0 = mph, 1 = kmh, 2 = otherdsp_speed 1# Speed Multiplier# Use if dsp_speed is defined as 2.# Default is normal game speed.mul_speed 1.0

 

And merely define both kmh and mph in the actual code. Then you'd merely have to put:

 

 

float fSpeedoMultiplier	= 3.60f;	// Default multiplier to 3.60 (kmh).void ReadConfig(){// ...if (strcmpi(cmd, "dsp_speed") == 0) // Compare for dsp_speed...{if (tok == 0) fSpeedoMultiplier = 2.24f;	// Set fSpeedoMultiplier to mph.else if (tok == 1) fSpeedoMultiplier = 3.60f;	// Set fSpeedoMultiplier to kmh.else if (tok == 2) {while (strcmpi(cmd, "mul_speed") != 0) line++; // Sorry for crappy code, I'm extremely tired.fSpeedoMultiplier = (float) atof(tok); // Set fSpeedoMultiplier to other.}}// ...}

 

I realize this code is pretty crappy, I'm under heavy sleep deprevation so frankly it's taken me about five minutes just to write that damn code.

Link to post
Share on other sites

That looks much better. smile.gif

You're right, theres no need in defining those two multipliers for mph and kmh in the configuration file. My code will look better now, i think.

 

Thanks for this Kryptos. smile.gif

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
 Share

  • 2 Users Currently Viewing
    0 members, 0 Anonymous, 2 Guests

×
×
  • Create New...

Important Information

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