[email protected] Posted November 14, 2007 Share Posted November 14, 2007 (edited) 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 August 26, 2009 by Dutchy3010 Link to comment Share on other sites More sharing options...
Seemann Posted November 15, 2007 Share Posted November 15, 2007 Does it require the DirectX SDK to be compiled? If so, for what? Sanny Builder 3 • SA Memory Handling • OpenIV • gtamodding.com CLEO.li - The CLEO Library - Official site Link to comment Share on other sites More sharing options...
[email protected] Posted November 15, 2007 Author Share Posted November 15, 2007 Does it require the DirectX SDK to be compiled? If so, for what? Nope, it doesn't need the DX SDK . Link to comment Share on other sites More sharing options...
ceedj Posted November 15, 2007 Share Posted November 15, 2007 This is truly "All that." Seriously. CRT stuff, multiple threads, GXT goodies ,existing SCM untouched. Egads, it's almost too good to be true. 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 More sharing options...
aad Posted November 15, 2007 Share Posted November 15, 2007 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 More sharing options...
[email protected] Posted November 15, 2007 Author Share Posted November 15, 2007 (edited) 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 . 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 November 15, 2007 by [email protected] Link to comment Share on other sites More sharing options...
Seemann Posted November 16, 2007 Share Posted November 16, 2007 OK, I can confirm that with some changes it works with Visual Studio 2005 (VS8). Good work! However, CLEO 3 scripts seem to be more user-friendly even without object-oriented programming stuff, IMO. Sanny Builder 3 • SA Memory Handling • OpenIV • gtamodding.com CLEO.li - The CLEO Library - Official site Link to comment Share on other sites More sharing options...
[email protected] Posted November 16, 2007 Author Share Posted November 16, 2007 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 . PS: more examples are inside the box . Link to comment Share on other sites More sharing options...
ceedj Posted November 16, 2007 Share Posted November 16, 2007 (edited) 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. 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. 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 November 17, 2007 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 More sharing options...
[email protected] Posted November 24, 2007 Author Share Posted November 24, 2007 (edited) 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 . I also used ceedj's suggestions to modify opcodes.h, thanks for that Edited November 24, 2007 by [email protected] Link to comment Share on other sites More sharing options...
ceedj Posted November 27, 2007 Share Posted November 27, 2007 (edited) 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 . I also used ceedj's suggestions to modify opcodes.h, thanks for that 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. 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 November 27, 2007 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 More sharing options...
[email protected] Posted November 30, 2007 Author Share Posted November 30, 2007 (edited) 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 . I also used ceedj's suggestions to modify opcodes.h, thanks for that 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. 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 Edited November 30, 2007 by [email protected] Link to comment Share on other sites More sharing options...
ceedj Posted December 1, 2007 Share Posted December 1, 2007 You know, I hate it when you make it look SO easy. Jerk. Thanks buddy. 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 More sharing options...
[email protected] Posted December 1, 2007 Author Share Posted December 1, 2007 You know, I hate it when you make it look SO easy. Jerk. Thanks buddy. Oh yeah, can I use readSCMvar(blah) anywhere I need to? Would be useful for scm mods like Space's All in One, etc. Yes, you can Link to comment Share on other sites More sharing options...
ceedj Posted December 4, 2007 Share Posted December 4, 2007 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 More sharing options...
Peter Posted December 4, 2007 Share Posted December 4, 2007 Check out VirtualProtect, the memory address you're trying to write to is write-protected, you need to get access first Link to comment Share on other sites More sharing options...
ceedj Posted December 4, 2007 Share Posted December 4, 2007 (edited) 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. 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. Edited December 4, 2007 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 More sharing options...
UZI-I Posted December 4, 2007 Share Posted December 4, 2007 DWORD dw[2];VirtualProtect ( (PVOID) 0x863984 , 4, PAGE_EXECUTE_READWRITE, &dw[0] );*(float*)0x863984 = 0.004f;VirtualProtect ( (PVOID) 0x863984 , 4, dw[0], &dw[1] ); Link to comment Share on other sites More sharing options...
ceedj Posted December 4, 2007 Share Posted December 4, 2007 (edited) Thanks for that; there's not nearly enough examples on how to best use SA memory stuff with C++. Edited December 4, 2007 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 More sharing options...
UZI-I Posted December 4, 2007 Share Posted December 4, 2007 (edited) np In-process its better to use Pointer stuff Edited December 4, 2007 by UZI-I Link to comment Share on other sites More sharing options...
Peter Posted December 5, 2007 Share Posted December 5, 2007 Just wait until you figure out what you can do with hooking full functions, you'll be amazed Link to comment Share on other sites More sharing options...
ceedj Posted December 5, 2007 Share Posted December 5, 2007 (edited) Just wait until you figure out what you can do with hooking full functions, you'll be amazed That is the absolute nicest way I've ever been called a complete idiot. Thanks. Edited December 5, 2007 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 More sharing options...
Sacky Posted December 5, 2007 Share Posted December 5, 2007 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 More sharing options...
ceedj Posted December 10, 2007 Share Posted December 10, 2007 Bee-u-ti-fal! 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 More sharing options...
[email protected] Posted December 10, 2007 Author Share Posted December 10, 2007 Bee-u-ti-fal! Thanks Sacky. DEFINE_OPCODE(set_car_speed_now, 0x04AB, "vf"); Switch to 04BA. Fixed 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 . Link to comment Share on other sites More sharing options...
DexX Posted December 12, 2007 Share Posted December 12, 2007 OK, I can confirm that with some changes it works with Visual Studio 2005 (VS8). Good work! 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. Link to comment Share on other sites More sharing options...
Seemann Posted December 12, 2007 Share Posted December 12, 2007 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? Sanny Builder 3 • SA Memory Handling • OpenIV • gtamodding.com CLEO.li - The CLEO Library - Official site Link to comment Share on other sites More sharing options...
DexX Posted December 12, 2007 Share Posted December 12, 2007 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. Link to comment Share on other sites More sharing options...
[email protected] Posted December 12, 2007 Author Share Posted December 12, 2007 (edited) 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 Edit edit edit: after you've downloaded advapi32.lib, you have to link your application against it of course Edited December 12, 2007 by [email protected] Link to comment Share on other sites More sharing options...
ceedj Posted December 20, 2007 Share Posted December 20, 2007 (edited) Greetings. 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... 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. 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 December 21, 2007 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 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