About hotkeys again [changing weapon text]

Posts 1–9 of 9 · Page 1 of 1
About hotkeys again [changing weapon text]
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:
http://www.mpgh.net/forum/242-crossf...apon-text.html
xD

Quote Originally Posted by [mi5 View Post
xD

What kind of fucking post is this? :/
Anyway good luck @Sneak84. Sorry I can't help here . (lacking sufficient knowledge)
The game doesn't store the length of the string nor will C try to recognize zero-terminated strings from memory. Specify the size yourself.
Quote Originally Posted by TrollerCoaster View Post
The game doesn't store the length of the string nor will C try to recognize zero-terminated strings from memory. Specify the size yourself.
Code:
typedef struct {
     char* name;
} old_name;

old_name old[700];

// 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, 15);
            }
      }
   }
}

//
if ( GetAsyncKeyState(VK_F2) )
{
   SaveWT(CShell);
}
The game crashes when i try to backup the text (pressing F2). Maybe there is another way to backup/restore (withot structure and memcpy)?
Thx, desertflame.

Guys, what the fuck with you? Include your brains and think a little bit. Enought to do an auto on hacks.
@Sneak84 found something that may help you.
Here it is

~Credits : Dakr54
1. Wtf are you doing???
2. It seems that you do not know how to code just simple basic & arrys
3. please learn first, then come here and ask..

If i'm false, here is the Solution:
- go ingame, scan the weapon char with CE
- find pointer
- use an Backup Array call it before you edit it..
- check it with bool
- if checked > u can edit & reset
Quote Originally Posted by Code[VB] View Post
1. Wtf are you doing???
2. It seems that you do not know how to code just simple basic & arrys
3. please learn first, then come here and ask..

If i'm false, here is the Solution:
- go ingame, scan the weapon char with CE
- find pointer
- use an Backup Array call it before you edit it..
- check it with bool
- if checked > u can edit & reset
looks not so easy, but thanks for the solution. never said that i'm good at c++, still learning.
Posts 1–9 of 9 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us