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|SA] Spooky-style SCM Hook


JGuntherS@NL
 Share

Recommended Posts

I have created an SCM hook for GTA: San Andreas that works like Spooky's SCM hook for VC, with script classes and such. However, it runs next to the original SCM so the original missions will still be available. It is based on my SA Injector, so it has full CRT functionality. It also has an GXT hook for custom text entries. A lot of code is just robbed from either op9080's SA SCM hook, spooky's VC SCM Hook and my own injector, credits to them!

 

I think it is quite self-explanatory, just look at CustomScript.cpp and CustomGXT.h

 

If you're having trouble with hash_map, change #define USE_HASH_MAP in commonincs.h into #define USE_HASH_MAP_IN_STDEXT, or if that doesn't work, just delete that line. Performance will drop sligthly in that case.

 

Download link (current version: v3): http://www.pawfectfilms.com/mods/SA_Injector3.zip

 

Changelog:

 

v1: initial version

 

v2: added an op9080-hook-like script class

 

v3: added support for using -1 instead of actor variable, fixed some issues in opcodes.h

Edited by Dutchy3010
Link to comment
Share on other sites

This is truly "All that." Seriously.

 

CRT stuff, multiple threads, GXT goodies ,existing SCM untouched. Egads, it's almost too good to be true. happy.gif I'll provide my updated Opcodes.h here for those that use this hook.

 

Great job, [email protected]!!!

I'm actually not against democracy though. I'm against things I think are f*cking stupid. I think this is f*cking stupid. - Sweets

Link to comment
Share on other sites

I have created an SCM hook for GTA: San Andreas that works like Spooky's SCM hook for VC, with script classes and such. However, it runs next to the original SCM so the original missions will still be available. It is based on my SA Injector, so it has full CRT functionality. It also has an GXT hook for custom text entries. A lot of code is just robbed from either op9080's SA SCM hook, spooky's VC SCM Hook and my own injector, credits to them!

 

I think it is quite self-explanatory, just look at CustomScript.cpp and CustomGXT.h

 

If you're having trouble with hash_map, change #define USE_HASH_MAP in commonincs.h into #define USE_HASH_MAP_IN_STDEXT, or if that doesn't work, just delete that line. Performance will drop sligthly in that case.

 

Download link: http://jesse.thorbit.nl/sainject/scmhook.zip

Hope it works with Visual Studio 6, if not then i really need to get an other version right away.

Dont imitate, recreate or copy just get your own ideas. Simplicity makes difficulty easy

Just for dev's of the myriad team http://www.aadblaauw.6x.to/

Link to comment
Share on other sites

 

I have created an SCM hook for GTA: San Andreas that works like Spooky's SCM hook for VC, with script classes and such. However, it runs next to the original SCM so the original missions will still be available. It is based on my SA Injector, so it has full CRT functionality. It also has an GXT hook for custom text entries. A lot of code is just robbed from either op9080's SA SCM hook, spooky's VC SCM Hook and my own injector, credits to them!

 

I think it is quite self-explanatory, just look at CustomScript.cpp and CustomGXT.h

 

If you're having trouble with hash_map, change #define USE_HASH_MAP in commonincs.h into #define USE_HASH_MAP_IN_STDEXT, or if that doesn't work, just delete that line. Performance will drop sligthly in that case.

 

Download link: http://jesse.thorbit.nl/sainject/scmhook.zip

Hope it works with Visual Studio 6, if not then i really need to get an other version right away.

Everything should work, except MSVC++ 6 doesn't have the hash_map by default. You could implement it yourself, find the correct files somewhere or just update to MSVC2003, which is what I'd advise you to do tounge.gif. If you want to use it with MSVC6 without hash_map, comment out or delete the line #define USE_HASH_MAP in commonincs.h.

Edited by [email protected]
Link to comment
Share on other sites

OK, I can confirm that with some changes it works with Visual Studio 2005 (VS8). Good work! icon14.gif

 

However, CLEO 3 scripts seem to be more user-friendly even without object-oriented programming stuff, IMO.

Link to comment
Share on other sites

I've uploaded a new version, this version also supports to some extent the way op9080 uses to script in C++.

 

Example code:

theScript << interior_access << "PDOMES" << 1 << EXEC;

 

 

A bit of a 'best of both worlds' idea smile.gif.

 

PS: more examples are inside the box wink.gif.

Link to comment
Share on other sites

 

DEFINE_OPCODE(put_player, 0x0055, "vfff");DEFINE_OPCODE(create_coordinate, 0x0400, "vfffvvv");

 

 

No longer supported in SA. There are a few others; I'll weed 'em out as I go. smile.gif

 

EDIT: Just a reminder: with multiple threads now, make sure your "waits" are distributed properly; this impacts which threads get higher priority. Not new info by any stretch, but after using one thread with the C++ hooks for so long, you tend to forget. wink.gif

 

EDIT 2:

 

DEFINE_OPCODE(get_car_color, 0x03F3, "vii");  	// var_car col1 col2

 

 

Change the "vii" to "vvv", or your game will crash if you try to get colors from cars.

Edited by ceedj

I'm actually not against democracy though. I'm against things I think are f*cking stupid. I think this is f*cking stupid. - Sweets

Link to comment
Share on other sites

I've uploaded a new version that supports the substitution of an actor variable with -1, which is used in defining actor animation sequences. Things like

CallOpcode(&AT_look_around, -1);

should work now smile.gif.

 

I also used ceedj's suggestions to modify opcodes.h, thanks for that smile.gif

Edited by [email protected]
Link to comment
Share on other sites

 

I've uploaded a new version that supports the substitution of an actor variable with -1, which is used in defining actor animation sequences. Things like
CallOpcode(&AT_look_around, -1);

should work now smile.gif.

 

I also used ceedj's suggestions to modify opcodes.h, thanks for that smile.gif

Just to clarify, it's not just for actors; this fix works with any opcode that takes either a handle or -1 as a parameter. smile.gif When setting up opcodes in Opcodes.h, just make the parameter in question a v.

 

Hey JGS, how can we add NOT to opcodes? Doing CallOpcode(!&blapcode); throws a compilation error. I'm just creating a second opcode for now:

 

(blahpcode, "0x0684", "")

 

(nblahpcode, "0x8684", "")

 

Any ideas?

Edited by ceedj

I'm actually not against democracy though. I'm against things I think are f*cking stupid. I think this is f*cking stupid. - Sweets

Link to comment
Share on other sites

 

I've uploaded a new version that supports the substitution of an actor variable with -1, which is used in defining actor animation sequences. Things like
CallOpcode(&AT_look_around, -1);

should work now smile.gif.

 

I also used ceedj's suggestions to modify opcodes.h, thanks for that smile.gif

Just to clarify, it's not just for actors; this fix works with any opcode that takes either a handle or -1 as a parameter. smile.gif When setting up opcodes in Opcodes.h, just make the parameter in question a v.

 

Hey JGS, how can we add NOT to opcodes? Doing CallOpcode(!&blapcode); throws a compilation error. I'm just creating a second opcode for now:

 

(blahpcode, "0x0684", "")

 

(nblahpcode, "0x8684", "")

 

Any ideas?

You could use

if (!CallOpcode(&..., ...))

That'll work, as it's just a C not wink.gif

Edited by [email protected]
Link to comment
Share on other sites

You know, I hate it when you make it look SO easy. Jerk. tounge.gif

 

Thanks buddy. smile.gif

 

Oh yeah, can I use readSCMvar(blah) anywhere I need to? Would be useful for scm mods like Space's All in One, etc.

I'm actually not against democracy though. I'm against things I think are f*cking stupid. I think this is f*cking stupid. - Sweets

Link to comment
Share on other sites

Sorry if this seems goofy, but I'm having a problem with this:

 

 

float* pfGravity = (float*)0x863984;*pfGravity = 0.008f

 

 

Is crashing the game. Actually, it's just the second line. I tested it further by doing this:

 

 

CallOpcode(&toggle_hud, 0);CallOpcode(&toggle_radar, 0);SCRIPT_WAIT(5000);*pfGravity = 0.008f;

 

 

Sure enough, crash after a 5 second wait. I know the addy is ok, but this is the same way I did it in Spookie's VC hook for LC. Is there something I'm missing?

I'm actually not against democracy though. I'm against things I think are f*cking stupid. I think this is f*cking stupid. - Sweets

Link to comment
Share on other sites

Check out VirtualProtect, the memory address you're trying to write to is write-protected, you need to get access first smile.gif

Link to comment
Share on other sites

I had a feeling, but wasn't sure how to do it with floats. I'll look into it some more. Thanks very much for the help. smile.gif

 

EDIT: Ok, I got it to work. A bit inelegant though. Sacky gave me this for my custom loading screens:

 

 

void Patch_DEF ( DWORD dwAddress,  BYTE *bRawData, int iSize ){DWORD dw[2];VirtualProtect ( (PVOID) dwAddress, iSize, PAGE_EXECUTE_READWRITE, &dw[0] );memcpy ( (PVOID) dwAddress, bRawData, iSize );VirtualProtect ( (PVOID) dwAddress, iSize, dw[0], &dw[1] );}

 

 

My code for gravity:

 

BYTE bGravity[] = { 0x6F, 0x12, 0x83, 0x3B };Patch_DEF(0x863984, bGravity, 4); 

 

 

That translates to 0.004, (3B83126F) or half-gravity. My question: can anyone suggest a way to use the float value instead? Not a huge deal, but I want to add gravity values to my config file; I think 1 float is easier to deal with than hex combos. Thanks. smile.gif

Edited by ceedj

I'm actually not against democracy though. I'm against things I think are f*cking stupid. I think this is f*cking stupid. - Sweets

Link to comment
Share on other sites

 

DWORD dw[2];VirtualProtect ( (PVOID) 0x863984 , 4, PAGE_EXECUTE_READWRITE, &dw[0] );*(float*)0x863984 = 0.004f;VirtualProtect ( (PVOID) 0x863984 , 4, dw[0], &dw[1] );

 

 

biggrin.gif

Link to comment
Share on other sites

Thanks for that; there's not nearly enough examples on how to best use SA memory stuff with C++. smile.gif

Edited by ceedj

I'm actually not against democracy though. I'm against things I think are f*cking stupid. I think this is f*cking stupid. - Sweets

Link to comment
Share on other sites

 

Just wait until you figure out what you can do with hooking full functions, you'll be amazed smile.gif

That is the absolute nicest way I've ever been called a complete idiot. Thanks. lol.gif

Edited by ceedj

I'm actually not against democracy though. I'm against things I think are f*cking stupid. I think this is f*cking stupid. - Sweets

Link to comment
Share on other sites

If you want a nice little float patch function try this:

 

 

void Patch_Float(DWORD dwAddress,float fltData){char* cTmp = (char*)&fltData;BYTE bTmp[] = { cTmp[0], cTmp[1], cTmp[2], cTmp[3] };Patch(dwAddress,bTmp);}

 

 

Use:

 

 

Patch_Float(0x863984,0.008f);

 

Link to comment
Share on other sites

Bee-u-ti-fal! biggrin.gif Thanks Sacky.

 

 

DEFINE_OPCODE(set_car_speed_now, 0x04AB, "vf");	

 

 

Switch to 04BA.

I'm actually not against democracy though. I'm against things I think are f*cking stupid. I think this is f*cking stupid. - Sweets

Link to comment
Share on other sites

Bee-u-ti-fal! biggrin.gif Thanks Sacky.

 

 

DEFINE_OPCODE(set_car_speed_now, 0x04AB, "vf");	

 

 

Switch to 04BA.

Fixed smile.gif

 

Furthermore:

 

void Patch_Float(DWORD dwAddress,float fltData){   Patch(dwAddress,*((DWORD *)&fltData));}

 

This might be a little bit neater, but it doesn't matter much smile.gif.

 

Link to comment
Share on other sites

 

OK, I can confirm that with some changes it works with Visual Studio 2005 (VS8). Good work!  icon14.gif

 

However, CLEO 3 scripts seem to be more user-friendly even without object-oriented programming stuff, IMO.

care to list those changes? i tried building the project in VS 2005 Express, and get a hefty 39 errors, 20 warnings.

Lurking..

Link to comment
Share on other sites

Well, I have VS2008 Pro, so you might have problems with the Platform SDK, do you have one?

 

I just checked the latest version and all I was need to do is to comment out the line '#define USE_HASH_MAP' in the commonincs.h to get the project compiled successfully.

 

It's strange as I remember I replaced all occurences of the 'strcpy' function with the 'strcpy_s' one in one of the previous releases.

 

What errors do you get?

Link to comment
Share on other sites

 

Well, I have VS2008 Pro, so you might have problems with the Platform SDK, do you have one?

due to the size of the PSDK, i don't update it very often (i'm on 56k), so i have the same version i installed about a year ago. and to say i have "problems" with it, is to describe my entire experience with it!

 

as for the errors, here's my buildlog before i comment out the hash map line...

www.3dhole.com/gtafiles/BuildLog_prehash.htm

and after...

www.3dhole.com/gtafiles/BuildLog_posthash.htm

After i comment it out, i get a mere 3 errors.

Lurking..

Link to comment
Share on other sites

 

Well, I have VS2008 Pro, so you might have problems with the Platform SDK, do you have one?

due to the size of the PSDK, i don't update it very often (i'm on 56k), so i have the same version i installed about a year ago. and to say i have "problems" with it, is to describe my entire experience with it!

 

as for the errors, here's my buildlog before i comment out the hash map line...

www.3dhole.com/gtafiles/BuildLog_prehash.htm

and after...

www.3dhole.com/gtafiles/BuildLog_posthash.htm

After i comment it out, i get a mere 3 errors.

It seems that your advapi32.lib is too old. The functions RegQueryValueEx and RegOpenKey have been introduced in Windows 2000, and I think your platform SDK is pre-2000. I uploaded the my advapi32.lib here: http://jesse.thorbit.nl/sainject/rotzooi/AdvAPI32.Lib

 

Edit: or do you actually have a pre-2000 Windows version?

 

Edit edit: it may be that these functions already existed prior to Windows 2000, I don't really get the MSDN sometimes tounge.gif

 

Edit edit edit: after you've downloaded advapi32.lib, you have to link your application against it of course

Edited by [email protected]
Link to comment
Share on other sites

  • 2 weeks later...

Greetings. smile.gif

 

Having a small problem; I have a function that works in one thread but seems to be ignored in others. Any ideas on why this might be? Could this be similar to a problem I have with a set of action sequences (SA code) I have that all work in the main animation thread, but not the secondary one?

 

EDIT: Ok, it loads at the beginning of the thread I want, just not at the point in the thread that I want... confused.gif

 

Sigh. Any way I can just take the post back? No? Ok, might as well complete the embarrassment...

 

 

StoreMainCheck13:if (TrailerCheck4 == 1){pTrailer4->GetCarCoord(&fT4X, &fT4Y, &fT4Z);pTrailer4->GetCarZ(&fT4Zangle);//if (FileStore == 1)pGame->TextNow("STORE", 5000, 1);FileSavePosition();StoreAll = 1;goto CreatePed1;} else { StoreAll = 1; pGame->TextNow("STORE", 5000, 1); goto CreatePed1;}}

 

 

Yeah, that's right. I need to put FileSavePosition(); after the ELSE as well. What annoys me is that I spent several hours trying to figure this out, and I KNEW it would be something stupid. Gah. Sorry for the trouble. lol.gif

 

EDIT: In case anyone's interested, this is my resulting output file (go me!):

 

 

#################################San An Studios 4 Save File#EDIT AT YOUR OWN RISK!!!#REMEMBER, IF YOU BREAK IT, I'LL LAUGH! ##################################Ped1#Ped Number, Special Actor/Model ID, Special Switch1 9 0#Coords (X, Y, Z, Z Angle)2030.196 996.363 10.813 84.121##Ped2#Ped Number, Special Actor/Model ID, Special Switch2 BBTHIN 1#Coords (X, Y, Z, Z Angle)2030.503 994.693 10.813 66.205#

 

Edited by ceedj

I'm actually not against democracy though. I'm against things I think are f*cking stupid. I think this is f*cking stupid. - Sweets

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

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