Rúben Alexandre 124 Posted June 11, 2015 (edited) Boa noite comunidade, desde já este tópico é para partilhar um novo código c++ para utilização cujo o título indica!Abram o seguinte ficheiro: input_main.cpp e procuram por " if (ch->IncreaseChatCounter() >= 10) " Em baixo adicionem: if (!strcmp(ch->LastPlayerMessage, buf) && (thecore_pulse() < (ch->LastMessageAt + SPAM_WAIT_SEC * 25)) && !ch->SpamAllowBuf(buf) && ch->GetGMLevel() < GM_LOW_WIZARD) { if (ch->BlockChatAfter < 2) { ch->ChatPacket(CHAT_TYPE_INFO, ("You must wait 5 seconds to repeat your message")); ch->BlockChatAfter++; return iExtraLen; } else { ch->BlockChatAfter = 0; ch->PlayerPunish(false, SPAM_CHAT_BAN_TIME); return iExtraLen; } } else { if (!ch->BannListCheck(buf) && ch->GetGMLevel() < GM_LOW_WIZARD) { ch->PlayerPunish(true, SPAM_BAN_TIME); return iExtraLen; } if (!ch->SpamListCheck(buf) && ch->GetGMLevel() < GM_LOW_WIZARD) { ch->ChatPacket(CHAT_TYPE_INFO, ("You wrote a not allowed words!")); ch->PlayerPunish(false, SPAM_CHAT_BAN_TIME); return iExtraLen; } } Tot in input_main.cpp cautam: ch->GetMapIndex(), strlen(ch->GetName()))); Dedesubt adaugam: strcpy(ch->LastPlayerMessage, buf); ch->LastMessageAt = thecore_pulse(); ch->BlockChatAfter = 0; Deschidem char.h si cautam: BYTE GetChatCounter() const; Dedesubt adaugam: int LastMessageAt; int BlockChatAfter; char LastPlayerMessage[CHAT_MAX_LEN + 1]; void PlayerPunish(bool PowerPunish, int Duration); bool SpamListCheck(const char *Message); bool BannListCheck(const char *Message); bool SpamAllowBuf(const char *Message); Deschidem char.cpp si adaugam la sfarsit: void CHARACTER::playerPunish(bool PowerPunish, int Duration) { if (!PowerPunish) { AddAffect(AFFECT_BLOCK_CHAT, POINT_NONE, 0, AFF_NONE, Duration, 0, true); sys_log(0, "%s[%d] has been chatbanned because of spamming/writing words which are in the spamlist.txt", GetName(), GetPlayerID()); } else { std::auto_ptr<SQLMsg> msg(DBManager::instance().DirectQuery("UPDATE account.account SET availDt = FROM_UNIXTIME(UNIX_TIMESTAMP(CURRENT_TIMESTAMP()) + %i) WHERE id = %d", Duration, GetAID())); sys_log(0, "%s[%d] has been banned because of saying blacklisted word", GetName(), GetPlayerID()); GetDesc()->DelayedDisconnect(5); } } bool CHARACTER::SpamAllowBuf(const char *Message) { if (!strcmp(Message, "(Ȳ´ç)") || !strcmp(Message, "(µ·)") || !strcmp(Message, "(±â»Ý)") || !strcmp(Message, "(ÁÁľĆ)") || !strcmp(Message, "(»ç¶ű)") || !strcmp(Message, "(şĐłë)") || !strcmp(Message, "(ľĆÇĎ)") || !strcmp(Message, "(żěżď)") || !strcmp(Message, "(ÁËĽŰ)")) { return true; } return false; } bool CHARACTER::SpamListCheck(const char *Message) { for (int i = 0; i < SpamBlockListArray.size(); i++) { if (!strcmp(Message, SpamBlockListArray.c_str())) { return false; } } return true; } bool CHARACTER::BannListCheck(const char *Message) { for (int i = 0; i < SpamBannListArray.size(); i++) { if (!strcmp(Message, SpamBannListArray.c_str())) { return false; } } return true; } Adaugam in sursa game 2 fisiere: spamblock.cpp spamblock.h In spamblock.cpp adaugam: #include "fstream" #include "string" #include "sstream" #include "stdafx.h" #include "../../common/length.h" std::vector<std::string> SpamBlockListArray; std::vector<std::string> SpamBannListArray; void LoadBlockSpamList() { std::string TempBlockList; std::ifstream File("chat/blockspamlist.lst"); if (!File.is_open()) { sys_log(0, "WARNING: cannot open chat/blockspamlist.lst"); return; } SpamBlockListArray.clear(); while (!File.eof()) { File >> TempBlockList; SpamBlockListArray.push_back(TempBlockList); } File.close(); } void LoadBannSpamList() { std::string TempBannList; std::ifstream File("chat/bannspamlist.lst"); if (!File.is_open()) { sys_log(0, "WARNING: cannot open chat/bannspamlist.lst"); return; } SpamBannListArray.clear(); while (!File.eof()) { File >> TempBannList; SpamBannListArray.push_back(TempBannList); } File.close(); } In sapmblock.h adaugam: #include "string" #include "../../common/length.h" extern void LoadBlockSpamList(); extern void LoadBannSpamList(); extern std::vector<std::string> SpamBlockListArray; extern std::vector<std::string> SpamBannListArray; Ne ducem iar in char.cpp si adaugam la inceput: #include "spamblock.h" Ne ducem in main.cpp si adaugam: #include "spamblock.h" Cautam in main.cpp: PanamaLoad(); si adaugam dedesubt: LoadBlockSpamList(); LoadBannSpamList(); Ne ducem in common/length.h si adaugam: SPAM_WAIT_SEC = 5, // The player can duplicate his message after 5 sec SPAM_CHAT_BAN_TIME = 60, // The player will receive 60 seconds chat ban, if he is saying a spamlist word SPAM_BAN_TIME = 3600, // The player will receive 1 hour ban, if he is saying a banlist word Ne ducem in game/cmd_gm.cpp si cautam: ACMD(do_reload) si in functia de mai sus ACMD(do_reload) adaugam: case 'b': ch->ChatPacket(CHAT_TYPE_INFO, "Reloading bann/spam list infomations."); LoadBlockSpamList(); LoadBannSpamList(); sys_log(0, "Reloading bann/spam list infomations."); break; Dupa care ne ducem sus de tot la inceput(tot in cmd_gm.cpp)si adaugam: #include "spamblock.h" Acum dupa ce am terminat cu sursa ne ducem in ch-urile noastre si creeam 2 fisiere: blockspamlist.lst bannspamlist.lst Em relação ao chat avançado não percebi qual a modificação mas também não experimentei, o mesmo falo em relação aos créditos quem publicou referiu que o criado não quis usar a sua identidade para créditos por isso, só sei que provavelmente é romeno.Fonte: FreakPlay(dot)net Edited June 11, 2015 by яυbєи c: (see edit history) Share this post Link to post Share on other sites
Tyler Durden 556 Posted June 11, 2015 Para quem quiser um tutorial a sério e bem feito. http://metin2dev.org/board/index.php?/topic/169-cadvanced-chat-38-spam-protection/ Share this post Link to post Share on other sites
Rúben Alexandre 124 Posted June 11, 2015 Para quem quiser um tutorial a sério e bem feito. http://metin2dev.org/board/index.php?/topic/169-cadvanced-chat-38-spam-protection/ Boa opinião, se quiseres partilhar mais comunidades estás a vontade.. Share this post Link to post Share on other sites
Tyler Durden 556 Posted June 11, 2015 Não precisas de ter medo da M2dev, não é nenhuma ameaça para a CG. Apenas porque mal se entende o que postaste. Share this post Link to post Share on other sites
Rúben Alexandre 124 Posted June 11, 2015 Não precisas de ter medo da M2dev, não é nenhuma ameaça para a CG. Apenas porque mal se entende o que postaste. medo...? desculpa lá analfabeto. Share this post Link to post Share on other sites
Laurindinha 319 Posted June 11, 2015 Tanta coisa por se mostrar um sitio alternativo onde está muito mais organizado e explicado. #StopSpam Share this post Link to post Share on other sites
Shad0w 347 Posted June 11, 2015 Bem mais uma vez so tenho isso a dizer. 2 Tyler Durden and ☆♕ CabrinhaSexy ♕☆ reacted to this Share this post Link to post Share on other sites