
Originally Posted by
Vusion
Was talking about something similar with SuperWaffle just before you posted that. I was gonna increment variable x which I'm going to declare and whenever x is divisible by 3, store timeGetTime() and whenever another's message is sent, if the difference between the time stored and the current time is less than 3000, throw a message.
Here's the checks I had on Goat, should cover most (if not all) of them. The latter part is to verify the same message isn't submitted 3 times in a row (PLS, ME NOOB BR, ME SWAP WIF U), even if they add spaces, alt codes or other bullshit at the end.
Code:
bool MMatchServer::OnChannelChat(struct MUID &uidChar, struct MUID &uidChannel, char *szMessage) {
GoatObject *pGoatObj = GoatServer::getInstance()->getGoat(&uidChar);
MMatchServer *pMMatchServer = MMatchServer::GetInstance();
MMatchObject *pObject = pMMatchServer->GetObjectA(&uidChar);
MMatchChannel *pChannel = pMMatchServer->FindChannel(uidChannel);
if (pObject == NULL || pGoatObj == NULL || pChannel == NULL) {
return false;
}
//GoatServer::checkTimeout(pGoatObj, pObject, NULL);
if (pObject->m_AccountInfo.m_nPGrade == GOAT_PENALTY_CHAT || pObject->m_AccountInfo.m_nPGrade == GOAT_PENALTY_CHAT_AND_TAUNT) {
Logging::writeObjectLog(pObject, "Has attempted to chat in channel [%u-%u] but his goat penalty is set to %i.", uidChannel.LowID, uidChannel.HighID, pObject->m_AccountInfo.m_nPGrade);
GoatProtection::banHacker(pObject, "Penalty hacking.");
return false;
}
if (pObject->m_nPlace != MMatchObject::CHANNEL) {
Logging::writeObjectLog(pObject, "Has attempted to chat in channel [%u-%u] but MMatchPlace is set to %i.", uidChannel.LowID, uidChannel.HighID, pObject->m_nPlace);
GoatProtection::banHacker(pObject, "Channel spamming.");
return false;
}
if (pObject->m_ChannelInfo.m_uidChannel.HighID != uidChannel.HighID) {
Logging::writeObjectLog(pObject, "Has attempted to channel chat in channel [%u-%u] while he is at channel [%u-%u].", uidChannel.LowID, uidChannel.HighID, pObject->m_ChannelInfo.m_uidChannel.LowID, pObject->m_ChannelInfo.m_uidChannel.HighID);
GoatProtection::banHacker(pObject, "Channel spamming.");
return false;
}
DWORD dwTime = GetTickCount();
if (pGoatObj->m_dwLastChat > (dwTime - 500)) {
Logging::writeObjectLog(pObject, "Has posted a channel message %u milliseconds after his previous!", (dwTime - pGoatObj->m_dwLastChat));
pMMatchServer->DisconnectObject(uidChar); //Lucky guy, I'd be better off banning him.
return false;
}
if (pGoatObj->m_dwLastChat != NULL && strncmp(pGoatObj->m_szLastChat, szMessage, strlen(pGoatObj->m_szLastChat)) == 0 && ++pGoatObj->m_nSpamCount >= 3) {
Logging::writeObjectLog(pObject, "Has posted the same channel chat message three times in a row. Message: %s", szMessage);
GoatServer::popupPlayer(pObject, "That looks like spam. Your connection to the gameserver will be terminated within 3 seconds.");
pObject->disconnect(3);
return false;
}
//Logging::writeChannelLog(pObject, pChannel, szMessage);
strncpy_s(pGoatObj->m_szLastChat, szMessage, 128);
pGoatObj->m_dwLastChat = dwTime;
return true;
}