bool ChatHandler::HandleIRCpmCommand(const char* args) { std::string Msg = args; if ((sIRC.IRC_CMDS_MASK & 2) == 0) { Msg = "WoW <-> iRC pm system disabled"; PSendSysMessage(Msg.c_str()); return true; } if (Msg.find(" ") == std::string::npos) return false; std::string To = Msg.substr(0, Msg.find(" ")); Msg = Msg.substr(Msg.find(" ") + 1); sIRC.SendIRCpm(m_session->GetPlayer(), To, Msg); Msg = "|cffCC4ACCTo [" + To + "]: " + Msg + "|r"; PSendSysMessage(Msg.c_str()); return true; } bool ChatHandler::HandlePVPCommand(const char * args) { Player *chr = m_session->GetPlayer(); if(chr->isInFlight()) { SendSysMessage(LANG_YOU_IN_FLIGHT); return true; } if(chr->isInCombat()) { SendSysMessage(LANG_YOU_IN_COMBAT); return true; } if (!*args) { SendSysMessage("Usage - .pvp enter or .pvp leave"); return true; } std::string argstr = (char*)args; if (argstr == "enter") { //add check to see if player has left arena QueryResult *result = sDatabase.PQuery("SELECT `time` , `in_arena` FROM `pvp_cmd_data` WHERE `playerid` = '%d'", chr->GetGUIDLow()); if(result) { Field *fields = result->Fetch(); uint32 arenatime = fields[0].GetUInt32(); uint32 inarena = fields[1].GetUInt32(); uint32 pvpcooldown = (time(NULL) - arenatime); if (pvpcooldown < 3800) { uint32 pvpcooldown2 = (3800 - pvpcooldown); std::string pvptimeleft = secsToTimeString(pvpcooldown2); PSendSysMessage("You have to wait %s before you can use this command again", pvptimeleft); return true; } if (inarena == 1) { sDatabase.PExecute( "UPDATE SET `time` =%d , `in_arena` =0 WHERE `playerid`= %d", time(NULL), chr->GetGUIDLow()); SendSysMessage("You did not leave the arena, resetting cooldown"); return true; } } PSendSysMessage("Teleporting you to STV Arena"); sDatabase.PExecute( "DELETE FROM `pvp_cmd_data` WHERE `playerid`= %d", chr->GetGUIDLow()); sDatabase.PExecute( "INSERT INTO `pvp_cmd_data` VALUES(%d, %d, 1, %f, %f, %f, %d)", chr->GetGUIDLow(), time(NULL), chr->GetPositionX(), chr->GetPositionZ(), chr->GetPositionY(), chr->GetMapId()); if ( chr->GetTeam() == ALLIANCE ) { chr->TeleportTo(0, -13228.1, 227.833, 32.8926, 0); return true; } else { chr->TeleportTo(0, -13178.80, 317.1, 33.25, 0); return true; } } else if (argstr == "leave") { Player* _player = m_session->GetPlayer(); QueryResult *result = sDatabase.PQuery("SELECT `time` , `in_arena` , `myx` , `myy` , `myz` , `mymap` FROM `pvp_cmd_data` WHERE `playerid` = '%d'", chr->GetGUIDLow()); if(result) { Field *fields = result->Fetch(); uint32 inarena = fields[1].GetUInt32(); double MyX = fields[1].GetFloat(); double MyY = fields[2].GetFloat(); double MyZ = fields[3].GetFloat(); uint32 MyMap = fields[4].GetUInt32(); uint32 arenatime1 = fields[0].GetUInt32(); uint32 pvpcooldown1 = (time(NULL) - arenatime1); if (pvpcooldown1 < 900) { uint32 pvpcooldown2 = (3800 - pvpcooldown1); std::string pvptimeleft1 = secsToTimeString(pvpcooldown2); PSendSysMessage("You have to wait %s before you can use this command again", pvptimeleft1); return true; } if (inarena == 0) { SendSysMessage("You are not in the arena"); return true; } else { PSendSysMessage("Teleporting you out of Arena"); sDatabase.PExecute( "UPDATE SET `time` =%d , `in_arena` =0 WHERE `playerid`= %d", time(NULL), chr->GetGUIDLow()); chr->TeleportTo(MyMap, MyX, MyY, MyZ, 0); return true; } } } else SendSysMessage("Usage - .pvp enter or .pvp leave"); return true; }