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


Recommended Posts


The edges of the speedo aren't smoothed out for me like that, I'vr tried changing my res already. I have no idea, I might need to change some settings on my vid card?

Are you running in 32bit color?... Can't think of anything else it could be, unless theres some graphics card settings for alphablending.




I've noticed a little bug, when you change the radio station, the speedo disappears and comes back when the game has tuned in on the next station

It's due to the flag I used to see whether you're ingame. If it's really bothering you and you know how to recompile the source I'll find you a better flag...




I haven't had much time for any recreational coding lately, but I'll make a start on it when I do though, if nobody else does first. It's relatively simple if you make use of the msscript control. Implementing all the scms as methods will be the hardest part.

I've started turning some of them into C++ classes...


	pGame = new ScriptGame();pGame->NameThread("MAIN");pGame->Fade(0, FADE_OUT);pGame->SetMaxWantedLevel(6);pGame->SetWastedBustedCheck(0);pGame->SetCurrentTime(12, 0);pGame->RefreshScreen(200.0f, -500.0f);pGame->SetCamera(200.0f, -503.0f, 11.54f);pPlayer = new ScriptPlayer(200.0f, -500.0f, 11.54f);pPlayer->SetSkin(MODEL_PLAYER);pGame->SetWeather(WEATHER_SUNNY);pGame->Fade(1000, FADE_IN);pGame->SelectInterior(INTERIOR_OUTSIDE);pPlayer->Freeze(1);


But it will take a looong time... unless it becomes a community project smile.gif




wouldn't it be better/easier to see which functions the scm opcodes actually call, and instead document those, combine them with known memory addresses, and try to reconstruct the real vehicle/actor/scriptthread objects from that (in which case the ps2 gta3 exe with embedded function names would help a lot)?

It would be better, but I wouldn't say it'd be easier wink.gif


Does the vice city ps2 executable have labels? If so, if somebody would send me either of those (I've gave my PS2 vice city and gta3 to my brother now sad.gif), that'd be great smile.gif

I spent about 3 hours strait yesterday finding, and then figuring out how to use the AnimateActor function - If this is labeled I'll go mad wink.gif.




First attemp: Using a scm opcode



const SCRIPT_COMMAND get_car_health    = { 0x0227, "vv" };...float fCurrentHealth = 0.0;if (!ScriptCommand(&car_stopped, &dwPlayerCar))    // Is the car moving?...{ScriptCommand(&get_car_health, &dwPlayerCar, &fCurrentHealth); // Get the car health}




It returns 0. 


Second attemp: Getting the value from memory


float* fCarHealth=(float*)GameGetVehicle(dwPlayerCar);fCarHealth += 516;float fCarHealth2=*fCarHealth;



Same here. 



What's wrong? Please help me, i can't find a mistake.


The first one might possibly be failing due to what Patrick said, and the second is failing due to pointer arithmetic - fCarHealth += 516 on a float pointer will increment the pointer by (516*sizeof(float)). Typecasting as a byte pointer while you do that should sort it - (BYTE*)fCarHealth += 516.




This is the best speedometer i've seen. And the only one i use  . BUT...there seems to be a problem... I don't know is it just my pc or something, but this speedometer doesn't work with GTA: LC  . I've tried reinstalling the game...and gtalc... Anyone have the same problem?

I've not tried it on LC, but if their main.scm script doesn't have the $PLAYER_CHAR at 0x08 and $PLAYER_ACTOR at 0x0C then any scm commands sent through the hook using those will crash. It's easily fixable if you can compile the source, just the lines...




...in Custom.cpp need changing.




I'm not sure it solves the problem, but I think car health is returned as an integer value, and you're putting it in a float variable. Thus interpreting the returned bit-pattern as a float, while is was meant to be a Integer.

This is my fault, I said it'd be returned as a float, because thats how it is in memory.




Well, whenever I copy the thing into the root directory the game crashes. is there anything else I should be doing?

Nope that should be it. If you're not having the same problem as LT_McGyver with a custom main.scm, please repost here and i'll try to find out whats going on.

Link to post
Share on other sites

I have a dvd rom drive and both my ps2 disks but there is no exe. I think its extension is .sys or whatever. To get the labels you need I would need to use what prog to open them? I'd like to help but this is the only way I can. I have a hex editor if that is all I need.

Link to post
Share on other sites

I believe they are .SLUS files. I use IDA (interactive disassembler) to view labels.


If you could send those files to my email in my signature, that'd be great smile.gif Thanks.

Link to post
Share on other sites

Thanks for the info about what to use to decompile. Not my area but hopefully the files will help you more.

Edited by Mark Pagliaro
Link to post
Share on other sites

I believe the GTA3 PS2 executable is the better documented one. I'm not sure, I've only heard this third hand, I assume CyQ would be the one who knows everything about that. I wish I had to a damn DVD-ROM so I could access my PS2 discs, it seems as though they're collecting more dust as each day goes past.

Link to post
Share on other sites

yeah, only the gta3 version has labels, but there's heaps of duplicate code between vc and gta3 so it's useful still. the file i have is called SLES_503.30 (SLUS_205.52 is vc).

Link to post
Share on other sites

Bah! theres loads of info in here (gta3 slus) that could've helped confused.gif


Oh well, I know what function i'm calling for this animation routine now, and the proper parameters 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.

Link to post
Share on other sites


I tried to compile and link the source for speedo but got these errors. I have

the directx 9c SDK installed as well as the extra .lib file required to use that version of the SDK with MSVC++ 6.0


Can anyone suggest what's wrong?



Compiling resources...







Custom.obj : error LNK2001: unresolved external symbol


[email protected]

Custom.obj : error LNK2001: unresolved external symbol [email protected]

Custom.obj : error LNK2001: unresolved external symbol

[email protected]

Debug/Spookie.dll : fatal error LNK1120: 3 unresolved externals

Error executing link.exe.


Spookie.dll - 4 error(s), 0 warning(s)

Link to post
Share on other sites

Don't forget, when using DirectX you have to import the libraries. If you're using Microsoft Visual C++ 6.0 then go to Project>Settings>Link and under Object/Library Modules add d3d8.dll. That should fix your problem. I don't believe you have to add any other library modules, if you do just check the DirectX SDK folder and you'll find them in the /lib directory. Simple enough. Also, you may face a pure virtual function violation when using MSVC++ 6.0. As well, make sure you compile the project as a Dynamic Link Library (DLL), it won't compile as an executable as it wasn't created for that. Hope that solves your problems.

Link to post
Share on other sites

Those errors are because you're not including d3dx8.lib.


You can add this to the linker settings or simply put...


#pragma comment(lib, "d3dx8.lib")

...in the code.

Link to post
Share on other sites

Everybody, thanks for your replies to my question. I did as you suggested Spookie, and it compiled and linked no problem, producing a release version of the dll at 376KB size.


However, the game doesn't run, throwing up a dialog box straight away with the message "Application failed to intialize properly 0x000007b". The source was compiled using an educational version of MSVC++ 6.0, which, while it produces executables with a nag screen, as far as I was aware, produced ordinary dlls. I may be completely mistaken in this assumption. Oh well, looks like I'll just have buy my own copy of MSVC++ .NET.


Thanks again for all your help, everyone.



Edited by Cowpat
Link to post
Share on other sites

Cowpat, you need to add the defination file to the project (Speedo.def). You're getting that error because the dll isn't exporting any functions, and Vice City is expecting to find Direct3DCreate8 exported.

Link to post
Share on other sites

Cowpat, you never ran into any pure virtual function violations when compiling with MSVC++ 6.0? The first time around I included all the necessary libraries, made sure the DXSDK was referenced with the compiler fine, but upon compiling an annoying pure virtual function violation would always show up in SetCursorPosition. I finally got around to fixing it, but now whenever I throw the DLL in the Vice folder it crashes the game after starting up. I've been too lazy as of yet to fix this, I essentially just made a quick fix to avoid the violation which of course allowed it to compile but essentially created numerous flaws at runtime. Anyhow, I'll start fresh a little later today and get the code to compile in MSVC++ 6.0.

Link to post
Share on other sites


@Spookie: Yup, spot on, I'd not included the the .def file in the project. It now works fine. The fact that I'd never heard of .def files is no excuse, I should have checked first ph34r.gif


@Kryptos: I didn't get anything about pure virtual function violations, just the linking errors. Odd you should get something different. Did you modify the code at all?

Link to post
Share on other sites

i added to developer console a option, if it detects speedo mod it reveals a button named 'run gtavc in window' biggrin.gif


i will release new devc soon smile.gif


Link to post
Share on other sites

No Cowpat, I merely extracted everything from the archive, started a new DLL project, added all the necessary files, including all the aforementioned files, and it reported a pure virtual function violation. Anyhow, I've since fixed the problem.

Link to post
Share on other sites

Well, i can get it to compile (thanks kryptos), but when i get ingame, it (the speedometer) simply isnt there. I do have this error after compiling..


  Creating library Release/SpeedoSrc2.lib and object Release/SpeedoSrc2.exp

SpeedoSrc2.exp : warning LNK4070: /OUT:d3d8.dll directive in .EXP differs from output filename "Release/SpeedoSrc2.dll"; ignoring directive


MSVC++ 6.0, i have the dx9sdk..

Link to post
Share on other sites

This is caused because you compiled the source into SpeedoSrc2.dll when it should be d3d8.dll. The problem revolves around the .EXP file creating a different name then that of the created file. If you go to Project>Settings>Link and then change the Output Filename to d3d8.dll it should fix your problem. This is the reason why the the speedometer isn't being displayed. I assume you just renamed the SpeedoSrc2.dll to d3d8.dll.

Link to post
Share on other sites

Which SDK are you using? I had to install the newer, DXSDK 9, release before I could even compile the code. For anyone who was wondering, the pure virtual function violation was a result of my own wrongdoing. I had modified one of the DXSDK files which was causing major issues, and of course in my own stupidity I forgot to modify the file back to the original before compiling this.

Link to post
Share on other sites

The older, summer 2003 version. its the only i have handy. 9.0c would be nice, but im on 56k,. and the file is 227mb......ill have it later.

Link to post
Share on other sites


The older, summer 2003 version. its the only i have handy. 9.0c would be nice, but im on 56k,. and the file is 227mb......ill have it later.

I'm on dialup too, so I went to a little internet cafe and downloaded the 9c SDK there. It cost me £4.10, including the disc, and it was done in an hour. I also downloaded an 'Extras' file, which is apparently nessesary if you want to run it under MSVC 6.0 The important part of the Extras download is d3dx9.lib, which I just dropped into any Lib folders I could find in MSVC.


I would have thought though that the app would run with the 8.0 version of the SDK. I think you can name your dll d3d9.dll if you want, and the game does an incremental search through the dx versions, starting at 8.0


Kryptos: I'm not really up to speed on C++, so I'm glad I never had to fend off any pure virtual functions smile.gif

Link to post
Share on other sites

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:



const SCRIPT_COMMAND get_actor_coords  	= { 0x00A0,	"vfff" };	// var_actor, x, y, zconst SCRIPT_COMMAND is_key_pressed    = { 0x00E1, "ii" };  // int, intconst SCRIPT_COMMAND set_motion_blur  	= { 0x0374, "i" };  // intconst SCRIPT_COMMAND set_gamespeed    = { 0x015D, "f" };  // float (1 = 100%)const SCRIPT_COMMAND debug_on    	= { 0x00C3, "" };  // -/-const SCRIPT_COMMAND debug_off    	= { 0x00C4, "" };  // -/-const SCRIPT_COMMAND make_car_heavy    = { 0x01EC, "vi" };  // var_car, int (0/1)const SCRIPT_COMMAND explode_car    = { 0x020B, "v" };  // var_car


I wrote a quick function using some of these, as well as some of the older, opcodes. It takes advantage of the simplicity in calling is_key_pressed directly through the hook, and in the case of the brake or reverse button being pressed in a vehicle it slows the gamespeed down to 0.3 so you can pull some sweet slow motion stops and turns. It also speeds up the gamespeed as you push the accelerator.



void CustomScript(){ScriptCommand(&set_weather, WEATHER_STORM);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.3);}}


Don't forget to define the function in Custom.h. Anyhow, just some quick fun. Sorry most of the formatting didn't turn out. If you were wondering about the set_motion_blur opcode, I was testing it out with little luck, I just left it as having a 4-byte integer parameter for the time being.


Oh, and a little extra thing for those of you who like making things go boom in the night:



ScriptCommand(&make_car_heavy, &dwPlayerCar, 1);  	// Make the vehicle heavy.


Add that just after get_player_car is called in the CustomRender(...) function.

Edited by Kryptos
Link to post
Share on other sites

hi @all.

sorry for my very bad english. confused.gif

@spooky, can you make a dll-file(d3d8.dll) with a .cfg?

in the .cfg is written the name of other .dll-files (like scm-scripting^^).


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

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