//// MxWoW Official Module //// Web Helper //// Dev: mikx //// Git: https://mxgit.ovh/MxWoW/mod-mxwow-webhelper #include "Define.h" #include "GossipDef.h" #include "Item.h" #include "Player.h" #include "ScriptedGossip.h" #include "ScriptMgr.h" #include "Spell.h" #include "Configuration/Config.h" #include "Chat.h" class mxwow_webhelper : public PlayerScript { public: mxwow_webhelper() : PlayerScript("mxwow_webhelper") {} void OnPlayerLogin(Player* player) override { QueryResult queryAccount = LoginDatabase.Query("SELECT * FROM account WHERE id = {}", player->GetSession()->GetAccountId()); if(queryAccount){ std::string userName = (*queryAccount)[1].Get(); if(userName.find("RNDBOT") != std::string::npos){ // Is a bot LoginDatabase.Execute("INSERT INTO mxw_web_online (aid, cid, isBot) VALUES ({}, {}, {})", player->GetSession()->GetAccountId(), player->GetGUID().GetRawValue(), 1); } else { // Is a real player LoginDatabase.Execute("INSERT INTO mxw_web_online (aid, cid, isBot) VALUES ({}, {}, {})", player->GetSession()->GetAccountId(), player->GetGUID().GetRawValue(), 0); } } } void OnPlayerLogout(Player* player) override { LoginDatabase.Execute("DELETE FROM mxw_web_online WHERE aid = {} AND cid = {}", player->GetSession()->GetAccountId(), player->GetGUID().GetRawValue()); } }; class mxwow_webhelperWorld : public WorldScript { public: mxwow_webhelperWorld() : WorldScript("mxwow_webhelperWorld") {} void OnShutdown() override { LoginDatabase.Execute("DELETE FROM mxw_web_online"); } }; void AddMxWoWWebHelperScripts() { new mxwow_webhelper(); new mxwow_webhelperWorld(); }