SC2 Print Text in Chat
Posted: July 17th, 2010, 1:19 am
Well, time to contribute some. This is probably one of basics, if you havn't figured out how to print text into the chat, well. Here is the code to do so:
Code:
typedef void (__thiscall* CGameUi_PrintString_t) ( CGameUi* lpcGameUi, int nMode, LPSTR* lpszString );
static const CGameUi_PrintString_t CGameUi_PrintString = (CGameUi_PrintString_t) 0x009B3F20;
// Pattern: 55 8B EC 8B 45 08 83 C0 FF 83 F8 08 77 6F
class CGameUi
{
public:
static CGameUi* GetInstance( void )
{
return *(CGameUi**) 0x1584FB8;
// Pattern for CGameUi: 8B 15 ?? ?? ?? ?? 8B 82 D4 01 00 00 84 C0 78 2E A9 00 01 00 00 75 27
// Offset: +0x02
}
void PrintString( int nMode, LPSTR lpszString )
{
LPSTR lpszStrings[2] = { lpszString, lpszString + strlen( lpszString ) };
CGameUi_PrintString( this, nMode, lpszStrings );
}
};
Sample usage:
Code:
void
CMaphack::GameFinishedLoading( void )
{
CGameUi::GetInstance( )->PrintString( 6, "Hello World!" );
return ( );
}
Code:
typedef void (__thiscall* CGameUi_PrintString_t) ( CGameUi* lpcGameUi, int nMode, LPSTR* lpszString );
static const CGameUi_PrintString_t CGameUi_PrintString = (CGameUi_PrintString_t) 0x009B3F20;
// Pattern: 55 8B EC 8B 45 08 83 C0 FF 83 F8 08 77 6F
class CGameUi
{
public:
static CGameUi* GetInstance( void )
{
return *(CGameUi**) 0x1584FB8;
// Pattern for CGameUi: 8B 15 ?? ?? ?? ?? 8B 82 D4 01 00 00 84 C0 78 2E A9 00 01 00 00 75 27
// Offset: +0x02
}
void PrintString( int nMode, LPSTR lpszString )
{
LPSTR lpszStrings[2] = { lpszString, lpszString + strlen( lpszString ) };
CGameUi_PrintString( this, nMode, lpszStrings );
}
};
Sample usage:
Code:
void
CMaphack::GameFinishedLoading( void )
{
CGameUi::GetInstance( )->PrintString( 6, "Hello World!" );
return ( );
}