本文整理汇总了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);
}