当前位置: 首页>>代码示例>>C++>>正文


C++ ChatChannel::sendToAll方法代码示例

本文整理汇总了C++中ChatChannel::sendToAll方法的典型用法代码示例。如果您正苦于以下问题:C++ ChatChannel::sendToAll方法的具体用法?C++ ChatChannel::sendToAll怎么用?C++ ChatChannel::sendToAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ChatChannel的用法示例。


在下文中一共展示了ChatChannel::sendToAll方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: talkToChannel

bool Chat::talkToChannel(Player* player, SpeakClasses type, const std::string& text, uint16_t channelId)
{
    ChatChannel* channel = getChannel(player, channelId);

    if (!channel || !player) {
        return false;
    }

    if (player->getAccountType() < ACCOUNT_TYPE_GAMEMASTER) {
        if (player->getLevel() < 2 && channelId < CHANNEL_PARTY && channelId != CHANNEL_ADVERTISINGROOKGAARD) {
            player->sendCancel("You may not speak into channels as long as you are on level 1.");
            return false;
        } else if ((channelId == CHANNEL_ADVERTISING || channelId == CHANNEL_ADVERTISINGROOKGAARD) && player->hasCondition(CONDITION_CHANNELMUTEDTICKS, channelId)) {
            player->sendCancel("You may only place one offer in two minutes.");
            return false;
        } else if (channelId == CHANNEL_HELP && player->hasCondition(CONDITION_CHANNELMUTEDTICKS, CHANNEL_HELP)) {
            player->sendCancel("You are muted from the Help channel for using it inappropriately.");
            return false;
        }
    }

    if (channelId == CHANNEL_HELP && player->getAccountType() >= ACCOUNT_TYPE_TUTOR && text.length() > 6) {
        if (text.length() > 6 && text.substr(0, 6) == "!mute ") {
            std::string param = text.substr(6);
            trimString(param);
            Player* paramPlayer = g_game.getPlayerByName(param);

            if (paramPlayer && paramPlayer->getAccountType() < player->getAccountType()) {
                if (!paramPlayer->hasCondition(CONDITION_CHANNELMUTEDTICKS, CHANNEL_HELP)) {
                    Condition* condition = Condition::createCondition(CONDITIONID_DEFAULT, CONDITION_CHANNELMUTEDTICKS, 3600000, 0, false, CHANNEL_HELP);
                    paramPlayer->addCondition(condition);

                    std::ostringstream ss;
                    ss << paramPlayer->getName() << " has been muted by " << player->getName() << " for using Help Channel inappropriately.";
                    channel->sendToAll(ss.str(), SPEAK_CHANNEL_R1);
                } else {
                    player->sendCancel("That player is already muted.");
                }
            } else {
                player->sendCancel("A player with that name is not online.");
            }

            return true;
        } else if (text.length() > 8 && text.substr(0, 8) == "!unmute ") {
            std::string param = text.substr(8);
            trimString(param);
            Player* paramPlayer = g_game.getPlayerByName(param);

            if (paramPlayer && paramPlayer->getAccountType() < player->getAccountType()) {
                Condition* condition = paramPlayer->getCondition(CONDITION_CHANNELMUTEDTICKS, CONDITIONID_DEFAULT, CHANNEL_HELP);

                if (condition && condition->getTicks() > 0) {
                    paramPlayer->removeCondition(condition);

                    std::ostringstream ss;
                    ss << paramPlayer->getName() << " has been unmuted by " << player->getName() << ".";
                    channel->sendToAll(ss.str(), SPEAK_CHANNEL_R1);
                } else {
                    player->sendCancel("That player is not muted.");
                }
            } else {
                player->sendCancel("A player with that name is not online.");
            }

            return true;
        }
    }

    if (channelId == CHANNEL_GUILD && player->getGuildLevel() > 1) {
        type = SPEAK_CHANNEL_O;
    }

    return channel->talk(player, type, text);
}
开发者ID:24312108k,项目名称:forgottenserver,代码行数:74,代码来源:chat.cpp


注:本文中的ChatChannel::sendToAll方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。