Adding commands to your gunz
This code is for you add commands to your gunz using ZChatCmdManager class.
This is for ONLY coders, i will not answer newbie questions.
ZChatCmdManager.h
Code:
#pragma once
class ZChatCmdManager
{
public:
void ZChatCmdManager::AddCommand(int, char*, void (__cdecl *)( char *, int, char ** ), ULONG, int, int, bool, char*, char*);
};
ZChat.h
Code:
#pragma once
#include "ZChatCmdManager.h"
class ZChat // 0x1c7c
{
public:
void *vTable;
ZChatCmdManager m_CmdManager; // +0x4(0x1c)
ULONG m_nLastInputTime; // +0x20(0x4)
int m_nSameMsgCount; // +0x24(0x4)
char m_nLastInputMsg[512]; // +0x28(0x200)
ULONG m_nLastAbuseTime; // +0x228(0x4)
int m_nAbuseCounter; // +0x22c(0x4)
char m_szWhisperLastSender[64]; // +0x230(0x40)
char Unknow[6668];
};
ZChatCmdManager.cpp
Code:
#include "zchatcmdmanager.h"
void ZChatCmdManager::AddCommand( int nID, char *szName, void(__cdecl *fnProc)( char *, int, char ** ), ULONG flag, int nMinArgs, int nMaxArgs, bool bRepeatEnabled, char *szUsage, char *szHelp )
{
__asm
{
push szHelp
push szUsage
push bRepeatEnabled
push nMaxArgs
push nMinArgs
push flag
push fnProc
push szName
push nID
mov ecx, this
mov eax, 0x431170 //! 08 July Address
call eax
}
}
Now i will post the code for you use this funcion :
Code:
#define ZGetGameInterface() ((DWORD(*)())0x4AD790)()
void ChatCmd_Close_Game( char *line, int argc, char *argv[] )
{
ExitProcess(0);
}
void ChatCmd_ForADMandGMonly( char *line, int argc, char *argv[] )
{
ExitProcess(0);
}
void ZComandos()
{
//! You will need to have ZGetGameInterface function
while( !ZGetGameInterface() ) Sleep(50);
ZChat *m_pChat = (ZChat*)(ZGetGameInterface() + 0x380);
m_pChat->m_CmdManager.AddCommand( 0, "close_game", ChatCmd_Close_Game, 0xF, -1, -1, 1, "/close_game", (char*)0x62286C );
//! For ADM and GM Only, because flag is 0x80
m_pChat->m_CmdManager.AddCommand( 0, "test", ChatCmd_ForADMandGMonly, 0x80, -1, -1, 1, "/test", (char*)0x62286C );
}
Re: Adding commands to your gunz
Good job, but can u explain what's /test gonna do?
Quote:
Originally Posted by
espanish
Code:
m_pChat->m_CmdManager.AddCommand( 0, "test", ChatCmd_ForADMandGMonly, 0x80, -1, -1, 1, "/test", (char*)0x62286C );
Re: Adding commands to your gunz
Nice contribution other than gfx work, and modelling, coding hasn't been around much.
Re: Adding commands to your gunz
Quote:
Originally Posted by
robertinh07
Good job, but can u explain what's /test gonna do?
Is the usage ... for you use the command you need to type /test on chat.
the other "test" parameter is the command name.
Re: Adding commands to your gunz
example: if I wanted to create a command using only Admins and that when he entered, and activated all the players could no longer speak
So I would use this base? ZChatCmdManager
Re: Adding commands to your gunz
Quote:
Originally Posted by
espanish
Is the usage ... for you use the command you need to type /test on chat.
the other "test" parameter is the command name.
thank you, it's really gonna be help me.
Re: Adding commands to your gunz
Re: Adding commands to your gunz
lol no
Code:
m_pChat->m_CmdManager.AddCommand( 0, "close_game", ChatCmd_Close_Game, 0xF, -1, -1, 1, "/close_game", (char*)0x62286C );
the third parameter is a callback function, is the function that will be called when you type /close_bame or /test on the othe case. That functions only calls "ChatCmd_Close_Game" wich only calls "ExitProgram(0)", you can change that to anything you want, like sending a packet or editing some game types or crap like that.
Re: Adding commands to your gunz
1>.\Ragezone Inter.cpp(27) : error C2228: left of '.AddCommand' must have class/struct/union
help me pls?
Re: Adding commands to your gunz
Re: Adding commands to your gunz
Quote:
Originally Posted by
Phailure772
You see? "espanish" users are like the worst persons in the planet (I'm from Perú, so yep I'm a spanish user)