Pastebin

New pastes are no longer accepted · Stats

Latest Pastes

delete chars&acct command

else if (command.length() >= 7 && command.compare(0,7,"delacct") == 0 && this->player->character->admin >= static_cast<int>(this->server->world->admin_config["delacct"]))
        {

            Character *victim = ((arguments.size() >= 1) ? this->player->character->world->GetCharacter(arguments[0]) : this->player->character);

			if (!victim)return false;

            std::string name = victim->name;

            if(victim) this->server->world->Kick(0, victim, false);

            Database_Result res = this->server->world->db.Query("SELECT `account` FROM `characters` WHERE `name` = '$'", name.c_str());
            std::tr1::unordered_map<std::string, util::variant> row = res.front();

            std::string account = GetRow<std::string>(row, "account");

            Database_Result res1 = this->server->world->db.Query("SELECT COUNT(1) AS `count` FROM `characters` WHERE `account` = '$'", account.c_str());

            this->server->world->db.Query("DELETE FROM `characters` WHERE `account` = '$'", account.c_str());

            int accts = static_cast<int>(res1.front()["count"]);

            this->server->world->db.Query("DELETE FROM `accounts` WHERE `username` = '$'", account.c_str());

            Console::Out(util::to_string(accts) + " characters and acct " + account + " was deleted by " + this->player->character->name + "." );

            UTIL_PTR_VECTOR_FOREACH(this->server->world->characters, Character, from)
            {
                if(from->admin)
                {
                    PacketBuilder builder(PACKET_TALK, PACKET_ADMIN);
                    builder.AddBreakString("Server");
                    builder.AddBreakString(util::to_string(accts) + " characters and acct " + account + " was deleted by " + this->player->character->name + "." );
                    from->Send(builder);
                }
            }
        }