SeaAngel | Date: Tuesday, 2012-04-10, 8:35 AM | Message # 1 |
3D Modeling
Group: Administrators
Messages: 972
Awards: 1
Reputation: 42
Status: Offline
| First we create a new chat commands chain: Code VAR(BOOL, CanEdit) CanEdit = TRUE;
BOOL FASTCALL Input(WCHAR * Text) { CHAR Buffer[100]; CHAR Message[100]; CHAR * Argument[32];
WideCharToMultiByte(CP_ACP, 0, Text, -1, Buffer, sizeof(Buffer), 0, 0); strcpy(Message, Buffer); INT Arguments = StringTokenize(Buffer + 1, ' ', Argument, 32);
if (Buffer[0] == '#') ///the # suffix { if ((!_stricmp(Argument[0], "edit")) && IsHost) /// edit toggle { if (Argument[1]) {
if(CanEdit) { !CanEdit; Print(0, 4, "ÿc4<ÿc8D2Maelstromÿc4>ÿc0: Stat editing has been ÿc1Disabled"); }
else { CanEdit; Print(0, 4, "ÿc4<ÿc8D2Maelstromÿc4>ÿc0: Stat editing has been ÿc2Enabled"); }
return FALSE; } }
if ((!_stricmp(Argument[0], "life")) && CanEdit) /// #life command { if (Argument[1]) {
(SetUnitStat(Me, STAT_MINHP, atoi(Argument[1])) >> 8); (SetUnitStat(Me, STAT_MAXHP, atoi(Argument[1])) >> 8); Print(0, 4, "ÿc4<ÿc8D2Maelstromÿc4>ÿc0: Your Life has been set to %s.", Argument[1]);
return FALSE; } }
if ((!_stricmp(Argument[0], "mana")) && CanEdit) /// #mana command { if (Argument[1]) {
(SetUnitStat(Me, STAT_MINMANA, atoi(Argument[1])) >> 8); (SetUnitStat(Me, STAT_MAXMANA, atoi(Argument[1])) >> 8); Print(0, 4, "ÿc4<ÿc8D2Maelstromÿc4>ÿc0: Your Mana has been set to %s.", Argument[1]);
return FALSE; } }
if ((!_stricmp(Argument[0], "stam")) && CanEdit) /// #stam command { if (Argument[1]) {
(SetUnitStat(Me, STAT_MINSTAM, atoi(Argument[1])) >> 8); (SetUnitStat(Me, STAT_MAXSTAM, atoi(Argument[1])) >> 8); Print(0, 4, "ÿc4<ÿc8D2Maelstromÿc4>ÿc0: Your Stamina has been set to %s.", Argument[1]);
return FALSE; } }
if ((!_stricmp(Argument[0], "str")) && CanEdit) /// #str command { if (Argument[1]) {
SetUnitStat(Me, STAT_STRENGTH, atoi(Argument[1])); Print(0, 4, "ÿc4<ÿc8D2Maelstromÿc4>ÿc0: Your Strength has been set to %s.", Argument[1]);
return FALSE; } }
if ((!_stricmp(Argument[0], "dex")) && CanEdit) /// #dex command { if (Argument[1]) {
SetUnitStat(Me, STAT_DEXTERITY, atoi(Argument[1])); Print(0, 4, "ÿc4<ÿc8D2Maelstromÿc4>ÿc0: Your Dexterity has been set to %s.", Argument[1]);
return FALSE; } }
if ((!_stricmp(Argument[0], "vit")) && CanEdit) /// #vit command { if (Argument[1]) {
SetUnitStat(Me, STAT_VITALITY, atoi(Argument[1])); Print(0, 4, "ÿc4<ÿc8D2Maelstromÿc4>ÿc0: Your Vitality has been set to %s.", Argument[1]);
return FALSE; } }
if ((!_stricmp(Argument[0], "enr")) && CanEdit) /// #enr command { if (Argument[1]) {
SetUnitStat(Me, STAT_ENERGY, atoi(Argument[1])); Print(0, 4, "ÿc4<ÿc8D2Maelstromÿc4>ÿc0: Your Energy has been set to %s.", Argument[1]);
return FALSE; } }
if ((!_stricmp(Argument[0], "fcr")) && CanEdit) /// #fcr command { if (Argument[1]) {
SetUnitStat(Me, STAT_FCR, atoi(Argument[1])); Print(0, 4, "ÿc4<ÿc8D2Maelstromÿc4>ÿc0: Your Faster Cast Rate has been set to %s%%.", Argument[1]);
return FALSE; } }
if ((!_stricmp(Argument[0], "ias")) && CanEdit) /// #ias command { if (Argument[1]) {
SetUnitStat(Me, STAT_IAS, atoi(Argument[1])); Print(0, 4, "ÿc4<ÿc8D2Maelstromÿc4>ÿc0: Your Increased Attack Speed has been set to %s%%.", Argument[1]);
return FALSE; } }
if ((!_stricmp(Argument[0], "frw")) && CanEdit) /// #frw command { if (Argument[1]) {
SetUnitStat(Me, STAT_FRW, atoi(Argument[1])); Print(0, 4, "ÿc4<ÿc8D2Maelstromÿc4>ÿc0: Your Faster Run/Walk has been set to %s%%.", Argument[1]);
return FALSE; } }
}
return TRUE; }
The needed pointers. They are 1.13c, but are easy to port: Code D2Common_SetUnitStat, LPUNITANY STDCALL, (LPUNITANY Unit, DWORD Stat, DWORD Amount, DWORD Param), -10887) D2Client_PrintGameString, VOID STDCALL, (WCHAR * Message, INT Color), 0x7D850) D2Client_PrintPartyString, VOID STDCALL, (WCHAR * Message, INT Color), 0x7D610)
The Print function I use: Code BOOL Print(BOOL Bottom, INT Color, CHAR * Format, ...) { if (!ClientReady(FALSE)) return FALSE;
if (strlen(Format) <= NULL) return FALSE;
CHAR *szString = new CHAR[8192]; ::memset(szString, 0, 8192); va_list vaArgs;
va_start(vaArgs, Format); vsprintf(szString, Format, vaArgs); va_end(vaArgs);
WCHAR Buffer[8192] = L""; MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, szString, (INT)strlen(szString), Buffer, (INT)strlen(szString));
if (Bottom) D2CLIENT_PrintPartyString(Buffer, Color); else D2CLIENT_PrintGameString(Buffer, Color);
delete[] szString; return TRUE; }
and this: [codeINT StringTokenize(CHAR * Input, CHAR Separator, LPSTR * TokenBuffer, INT MaxTokens) { CHAR * P = Input; INT i = 0;
do { TokenBuffer[i] = P; P = strchr(P, Separator);
if (P) *(P++) = 0; }
while (P && ++i < MaxTokens); return ++i; }[/code]
Screenshot
Special thanks to xXWhistXx
|
|
| |