😎 Don't always PushToConsole
I'm fairly new here and just got some of my own initial hacks working with help from the amazing source of information I've found in the forums. One thing I'm noticing a lot are unnecessary PTC in while loops so I thought I'd call it out since I noticed my CA would crash/exit until I fixed it.
Example of what not to do:
Some of this can be mitigated by detecting if the Console shell exists before pushing a command to the LTC. This type of checking is always good:
Another case of the never-ending pushes that I see floating around the forums are when you set a flag based on a key-event (or whatever), and then either always push the command to be active or inactive:
Those "Sleep" commands can only do so much, but you are essentially constantly pushing commands (either chams-on or chams-off) all the time. Rather, if you want something simple, then just do the command push and flag update on the key event:
So far I've seen better hack success and less CA exit/crashes.
On a slight side note, I'm also seeing less exits when doing "Release" quality builds from VS2008 and packing the DLL through UPX.
Anyways, I hope this helps. If not, then... well... hello.
Regards,
--Phot0n
Example of what not to do:
Code:
while(true) {
PushToConsole("...");
}
Code:
void __cdecl PushToConsole( const char* szCmd )
{
DWORD dwCShell = (DWORD)GetModuleHandleA("CShell.dll");
if( dwCShell != NULL )
...
Another case of the never-ending pushes that I see floating around the forums are when you set a flag based on a key-event (or whatever), and then either always push the command to be active or inactive:
Code:
bool chams = false;
while(true) {
// Chams
if(GetAsyncKeyState(VK_NUMPAD1)&1) {
chams = !chams;
}
...
if(chams) {
PushToConsole("SkelModelStencil 0");
} else {
PushToConsole("SkelModelStencil 1");
}
Sleep(100);
...
}
Code:
while(true) {
// Chams
if(GetAsyncKeyState(VK_NUMPAD1)&1)
{
if(chams) {
PushToConsole("SkelModelStencil 0");
} else {
PushToConsole("SkelModelStencil 1");
}
chams = !chams;
Sleep(100);
}
...
}
On a slight side note, I'm also seeing less exits when doing "Release" quality builds from VS2008 and packing the DLL through UPX.
Anyways, I hope this helps. If not, then... well... hello.
Regards,
--Phot0n
