Ejemplo n.º 1
0
bool ChatHandler::HandleCharacterEraseCommand(char* args)
{
    char* nameStr = ExtractLiteralArg(&args);
    if (!nameStr)
        return false;

    Player* target;
    ObjectGuid target_guid;
    std::string target_name;
    if (!ExtractPlayerTarget(&nameStr, &target, &target_guid, &target_name))
        return false;

    uint32 account_id;

    if (target)
    {
        account_id = target->GetSession()->GetAccountId();
        target->GetSession()->KickPlayer();
    }
    else
        account_id = sObjectMgr.GetPlayerAccountIdByGUID(target_guid);

    std::string account_name;
    sAccountMgr.GetName (account_id,account_name);

    Player::DeleteFromDB(target_guid, account_id, true, true);
    PSendSysMessage(LANG_CHARACTER_DELETED, target_name.c_str(), target_guid.GetCounter(), account_name.c_str(), account_id);
    return true;
}
Ejemplo n.º 2
0
//mute player for some times, in global channels only
bool ChatHandler::HandleChannelMuteCommand(char* args)
{
    char* nameStr = ExtractOptNotLastArg(&args);

    Player* target;
    ObjectGuid target_guid;
    std::string target_name;
    if (!ExtractPlayerTarget(&nameStr, &target, &target_guid, &target_name))
        return false;

    uint32 notspeaktime;
    if (!ExtractUInt32(&args, notspeaktime))
        return false;

    uint32 account_id = target ? target->GetSession()->GetAccountId() : sObjectMgr.GetPlayerAccountIdByGUID(target_guid);

    // find only player from same account if any
    if (!target)
    {
        if (WorldSession* session = sWorld.FindSession(account_id))
            target = session->GetPlayer();
    }

    // FG: limit mutetime if set in conf
    if(uint32 maxtime = sWorld.getConfig(CONFIG_UINT32_MAX_CHANNEL_MUTETIME))
    {
        notspeaktime = std::min(maxtime,notspeaktime);
    }

    // must have strong lesser security level
    if (HasLowerSecurity(target, target_guid, true))
        return false;

    time_t mutetime = time(NULL) + notspeaktime*60;

    if (target)
        target->GetSession()->m_channelMuteTime = mutetime;

    LoginDatabase.PExecute("UPDATE account SET chanmutetime = " UI64FMTD " WHERE id = '%u'", uint64(mutetime), account_id);

    if (target)
        ChatHandler(target).PSendSysMessage(LANG_YOUR_GLOBAL_CHANNELS_CHAT_DISABLED, notspeaktime);

    std::string nameLink = playerLink(target_name);

    PSendSysMessage(LANG_YOU_DISABLE_CHANNEL_CHAT, nameLink.c_str(), notspeaktime);
    return true;
}
Ejemplo n.º 3
0
//unmute player, in global channels only
bool ChatHandler::HandleChannelUnmuteCommand(char* args)
{
    Player* target;
    ObjectGuid target_guid;
    std::string target_name;
    if (!ExtractPlayerTarget(&args, &target, &target_guid, &target_name))
        return false;

    uint32 account_id = target ? target->GetSession()->GetAccountId() : sObjectMgr.GetPlayerAccountIdByGUID(target_guid);

    // find only player from same account if any
    if (!target)
    {
        if (WorldSession* session = sWorld.FindSession(account_id))
            target = session->GetPlayer();
    }

    if (target)
    {
        if (target->CanSpeak())
        {
            SendSysMessage(LANG_CHAT_ALREADY_ENABLED);
            SetSentErrorMessage(true);
            return false;
        }

        target->GetSession()->m_channelMuteTime = 0;
    }

    LoginDatabase.PExecute("UPDATE account SET chanmutetime = '0' WHERE id = '%u'", account_id);

    if (target)
        ChatHandler(target).PSendSysMessage(LANG_YOUR_GLOBAL_CHANNELS_CHAT_ENABLED);

    std::string nameLink = playerLink(target_name);

    PSendSysMessage(LANG_YOU_ENABLE_CHANNEL_CHAT, nameLink.c_str());
    return true;
}
Ejemplo n.º 4
0
bool ChatHandler::HandlePunishCommand(char *args)
{
    Player *plr = NULL;
    std::string pname;
    uint64 plr_guid = 0;
    uint32 accid = 0;
    if(!ExtractPlayerTarget(&args, &plr, NULL, &pname))
        return false;

    if(plr)
        accid = plr->GetSession()->GetAccountId();
    else
    {
        std::string pname_esc(pname);
        CharacterDatabase.escape_string(pname_esc);
        QueryResult *result = CharacterDatabase.PQuery("SELECT account FROM characters WHERE name = '%s'", pname_esc.c_str());
        if(!result)
        {
            SendSysMessage(LANG_PLAYER_NOT_FOUND);
            SetSentErrorMessage(true);
            return false;
        }
        Field *fields = result->Fetch();
        accid = fields[0].GetUInt32();
        delete result;
    }

    // extra check, not sure if really necessary, but we better be on the safe side!
    if(!accid)
    {
        SendSysMessage(LANG_PLAYER_NOT_FOUND);
        SetSentErrorMessage(true);
        return false;
    }

    // find only player from same account if any
    if (!plr)
    {
        if (WorldSession* session = sWorld.FindSession(accid))
        {
            plr = session->GetPlayer();
            pname = plr->GetName();
        }
    }

    char *what = ExtractArg(&args);
    char *reason = ExtractArg(&args);

    std::string strWhat(what ? what : "");

    bool handled = sPunishMgr.Handle(accid, plr, m_session->GetPlayer(), pname, strWhat, reason ? reason : GetMangosString(LANG_NO_REASON_GIVEN));

    if(!handled)
    {
        PSendSysMessage(LANG_NO_RECORD_IN_DB, strWhat.c_str());
        SetSentErrorMessage(true);
        return false;
    }

    return true;
}