Guild Leaders Channel (9.X and 8.6)

WTF.Error

Member
Joined
Aug 8, 2007
Messages
492
Reaction score
9
Guild Leaders Channel


This channel is especially for Guild Leaders, where they could chat with each other about upcoming battles et cetera. It has been tested on latest revision, (protocol 9.70 r5893).

Good to know
- Only Guild Leaders will be able to enter the channel.
- It will show their Guild Name next to their own so others can see which guild they're representing.

I'll use channel ID 10, so if that ID is taken already then change to another one!

channels.xml
XML:
<channel id="10" name="Guild Leaders"/>
chat.cpp

Find bool ChatChannel::talk and replace it or compare it with this one.

9.X
Code:
bool ChatChannel::talk(Player* player, MessageClasses type, const std::string& text, uint32_t statementId)
{
    UsersMap::iterator it = m_users.find(player->getID());
    if(it == m_users.end())
        return false;


    if(m_condition && !player->hasFlag(PlayerFlag_CannotBeMuted))
    {
        if(Condition* condition = m_condition->clone())
            player->addCondition(condition);
    }


    for(it = m_users.begin(); it != m_users.end(); ++it) {
    if(m_id == 10) {
    std::stringstream ss;
    ss << player->getName() << " [" << player->getGuildName() << "]";
        it->second->sendChannelMessage(ss.str(), std::string(text), type, (uint8_t)m_id);      
    } else {
    it->second->sendCreatureChannelSay(player, type, text, m_id, statementId);
  }
}


    if(hasFlag(CHANNELFLAG_LOGGED) && m_file->is_open())
        *m_file << "[" << formatDate() << "] " << player->getName() << ": " << text << std::endl;


    return true;
}
8.6
Code:
bool ChatChannel::talk(Player* player, SpeakClasses type, const std::string& text, uint32_t _time/* = 0*/)
{
    UsersMap::iterator it = m_users.find(player->getID());
    if(it == m_users.end())
        return false;


    if(m_condition && !player->hasFlag(PlayerFlag_CannotBeMuted))
    {
        if(Condition* condition = m_condition->clone())
            player->addCondition(condition);
    }


    for(it = m_users.begin(); it != m_users.end(); ++it) {
    if(m_id == 10) {
    std::stringstream ss;
    ss << player->getName() << " [" << player->getGuildName() << "]";
        it->second->sendChannelMessage(ss.str(), std::string(text), type, (uint8_t)m_id);      
    } else {
    it->second->sendToChannel(player, type, text, m_id, _time);
  }
}


    if(hasFlag(CHANNELFLAG_LOGGED) && m_file->is_open())
        *m_file << "[" << formatDate() << "] "  << player->getName() << ": " << text <<  std::endl;


    return true;
}
Replace this
Code:
player->getVocationId())))[/cpp]
with this
[cpp]player->getVocationId())) || (channelId == 10 && !(player->getGuildLevel() == GUILDLEVEL_LEADER)))
Enjoy!
only to "fix" old code
 

kito2

www.masteria.net
Joined
Mar 9, 2009
Messages
3,772
Reaction score
206
Location
Chile, Santiago
Can you add features like configure minium amount of players in guild to enter the channel and also a minium average guild level?
 
Top