I want to change/restore weapon text in the lower right corner.
I think i need to backup old text for weapons to make it work, so i'm define 3 functions: first function change the text for all weapons, second save the original text, third restore it.
Code:
typedef struct {
char* name;
} old_name;
old_name old[700];
// change text for all weapons
void ChangeWT(DWORD CShell, char * String)
{
DWORD pWeaponMgr = *(DWORD*) ( CShell + WeaponMgr );
int sizeString = strlen(String);
if ( pWeaponMgr )
{
for ( int i = 0; i < 700; i++ )
{
DWORD pWeapon = *(unsigned long*) ( pWeaponMgr + (i*4) );
if ( pWeapon )
{
char * weaponName = (char*) ( pWeapon + 0x000008 );
memcpy(weaponName, String, sizeString);
}
}
}
}
// backup text for all weapons
void SaveWT(DWORD CShell)
{
DWORD pWeaponMgr = *(DWORD*) ( CShell + WeaponMgr );
if ( pWeaponMgr )
{
for ( int i = 0; i < 700; i++ )
{
DWORD pWeapon = *(unsigned long*) ( pWeaponMgr + (i*4) );
if ( pWeapon )
{
char * weaponName = (char*) ( pWeapon + 0x000008 );
memcpy(old[i].name, weaponName, lstrlen(weaponName));
}
}
}
}
// restore saved text
void RestoreWT(DWORD CShell)
{
DWORD pWeaponMgr = *(DWORD*) ( CShell + WeaponMgr );
if ( pWeaponMgr )
{
for ( int i = 0; i < 700; i++ )
{
DWORD pWeapon = *(unsigned long*) ( pWeaponMgr + (i*4) );
if ( pWeapon )
{
char * weaponName = (char*) ( pWeapon + 0x000008 );
memcpy(weaponName, old[i].name, lstrlen(old[i].name));
}
}
}
}
if ( !bInitHacks )
{
SaveWT(CShell);
bInitHacks = true;
}
// in another thread
if ( GetAsyncKeyState(VK_F9) )
{
bNoReload =! bNoReload;
if ( bNoReload )
// if user press f9 then we enable hack and change a weapon text for 3 seconds
ChangeWT(CShell, "No reload: ON");
else
ChangeWT(CShell, "No reload: OFF");
Sleep(3000);
// then we just restore the original text
RestoreWT(CShell);
}
Is not that cool? But help me with restoring text. When i use this way, game crashes when i join in room.
Oh forget, original idea for changing weapon text: dakr54. Here:
https://www.mpgh.net/forum/242-crossf...apon-text.html