- Joined
- Jun 10, 2012
- Messages
- 566
- Reaction score
- 134
BotHidenSeek.cpp
void CEventHideAndSeek::Clear()
{
this->m_RemainTime = 0;
this->m_TickCount = GetTickCount();
this->m_GmIndex = 0;
this->MinutesLeft = -1;
this->m_EventHideAndSeek = 0;
}
void CEventHideAndSeek::MainProc() // OK
{
DWORD elapsed = GetTickCount() - this->m_TickCount;
if (elapsed < 1000)
{
return;
}
this->m_TickCount = GetTickCount();
if (this->m_RemainTime > 0)
{
int minutes = this->m_RemainTime / 60;
if ((this->m_RemainTime % 60) == 0)
{
minutes--;
}
if (this->MinutesLeft != minutes)
{
this->MinutesLeft = minutes;
StringSendAll("[HidenAndSeeK] The event end in minute(s)!", 0);
}
if (this->m_RemainTime <= 10)
{
GCServerMsgStringSend("[HidenAndSeeK] The event end in %d second(s)", m_RemainTime, 1);
}
this->m_RemainTime--;
if (this->m_RemainTime <= 0)
{
this->m_EventHideAndSeek = 0;
GCServerMsgStringSend("[HidenAndSeeK] Dont no winner!", m_RemainTime, 0);
LogAddFuncColor(COLOR_RED, "[EVENT HIDE AND SEEK] Close");
}
}
}
void CEventHideAndSeek::CommandEventHideAndSeek(int aIndex, char* arg) // OK
{
OBJECTSTRUCT * lpObj = (OBJECTSTRUCT*)OBJECT_POINTER(aIndex);
if (pComandos.HiddenSeekSwitch == 0)
{
MsgOutput(aIndex, "[AVISO] Comando desactivado!");
return;
}
if (lpObj->Authority < 2 && pComandos.GGGM != 0)
{
GCServerMsgStringSend("[AVISO] Comando solo para GameMasters!", aIndex , 1);
return;
}
if (this->m_RemainTime > 0)
{
this->Clear();
LogAddFuncColor(COLOR_RED, "[EVENT HIDE AND SEEK] Canceled");
GCServerMsgStringSend("[HidenAndSeeK] Canceled!", aIndex, 0);
return;
}
this->m_EventHideAndSeek = 1;
this->m_GmIndex = lpObj->m_Index;
this->m_RemainTime = pComandos.HiddenSeekTiempoSwitch * 60;
MsgOutput(aIndex, "[HidenAndSeeK] %s Started event!", lpObj->Name);
GCServerMsgStringSend("[HidenAndSeeK] Look for the GM and trade!", aIndex, 0);
LogAddFuncColor(COLOR_RED, "[EVENT HIDE AND SEEK] Start");
}
int CEventHideAndSeek::EventHideAndSeekTrade(int aIndex) // OK
{
if (pComandos.HiddenSeekSwitch == 0)
{
MsgOutput(aIndex, "[AVISO] Comando desactivado!");
return 0;
}
if (this->m_EventHideAndSeek == 0)
{
return 0;
}
if (this->m_GmIndex != aIndex)
{
return 0;
}
LPOBJ lpObj = &gObj[aIndex];
this->Clear();
MsgOutput(aIndex, "[HidenAndSeeK] %s Winner of event!", lpObj->Name);
// Reware
//if (gServerInfo.m_EventHideAndSeekAutoReward1 > 0 || gServerInfo.m_EventHideAndSeekAutoReward2 > 0 || gServerInfo.m_EventHideAndSeekAutoReward3 > 0)
//{
// GDSetCoinSend(lpObj->Index, gServerInfo.m_EventHideAndSeekAutoReward1, gServerInfo.m_EventHideAndSeekAutoReward2, gServerInfo.m_EventHideAndSeekAutoReward3, "HideAndSeek");
//}
LogAddFuncColor(COLOR_RED, "[EVENT HIDE AND SEEK] Finish (Winner: %s)", lpObj->Name);
return 1;
}
BotHidenSeek.h
#pragma once
class CEventHideAndSeek
{
public:
CEventHideAndSeek();
virtual ~CEventHideAndSeek();
void MainProc();
void Clear();
void CommandEventHideAndSeek(int aIndex, char* arg);
int EventHideAndSeekTrade(int aIndex);
private:
int m_GmIndex;
int m_RemainTime;
int m_TickCount;
int m_EventHideAndSeek;
int MinutesLeft;
};
extern CEventHideAndSeek gEventHideAndSeek;
Commandos.cpp
void ChatDataSend(int aIndex, unsigned char* aRecv)
{
if (_memicmp(&aRecv[13], pComandos.HiddenSeekCMD, strlen(pComandos.HiddenSeekCMD)) == 0)
{
gEventHideAndSeek.CommandEventHideAndSeek(aIndex, (char*)aRecv + 13 + strlen(pComandos.HiddenSeekCMD));
}
}
void Comandos()
{
// HidenAndSeek
pComandos.HiddenSeekSwitch = GetPrivateProfileIntA("HIDENSEEK", "Switch", 0, Aminyuz_Comandos);
pComandos.HiddenSeekTiempoSwitch = GetPrivateProfileIntA("HIDENSEEK", "MaxTime", 1, Aminyuz_Comandos);
GetPrivateProfileStringA("HIDENSEEK", "Comando", "/HiddenSeek", pComandos.HiddenSeekCMD, 8, Aminyuz_Comandos);
}
Command.h
struct COMANDOS
{
int HiddenSeekSwitch;
int HiddenSeekTiempoSwitch;
char HiddenSeekCMD[20];
}
Trade.cpp
void GCTradeRequest(PMSG_TRADE_REQUEST* objMsg, DWORD aIndex)
{
if (gEventHideAndSeek.EventHideAndSeekTrade(aIndex) == 1)
{
return;
}
}
Aminyuz.cpp
extern "C" _declspec(dllexport) void Aminyuz()
{
gEventHideAndSeek.MainProc();
}
Comandos.ini
[HIDENSEEK]
Switch = 1
MaxTime = 360
Comando = /HiddenSeek
Creditos:
Aminyuz - Files Base
Louis - Devolper S6
Melo920 - Adaptar 97d