Jump to content

[HELP] Checking if a player is in a channel

Guest xeross155

Recommended Posts

I've been working on improving mangchat and recently tried to implement checking if the player is already in the autojoin channel. However the invite and check are executed before the player has joined any channels.

Currently I've added the autojoin function call to the bottom of "WorldSession::HandlePlayerLogin". and my autojoin code is as follows.

// this function should be called on player login WorldSession::HandlePlayerLogin
void IRCClient::AutoJoinChannel(Player *plr)
   if(ChannelMgr* cMgr = channelMgr(plr->GetTeam()))
    if(Channel *chn = cMgr->GetChannel(sIRC.ajchan,plr))

   // this will work if at least 1 player is logged in regrdless if he is on the channel or not
   // the first person that login empty server is the one with bad luck and wont be invited, 
   // if at least 1 player is online the player will be invited to the chanel

   std::string m_name = sIRC.ajchan;
   WorldPacket data;
   data.Initialize(SMSG_CHANNEL_NOTIFY, 1+m_name.size()+1);
   data << uint8(CHAT_INVITE_NOTICE);
   data << m_name.c_str();

   HashMapHolder<Player>::MapType& m = ObjectAccessor::Instance().GetPlayers();
   for(HashMapHolder<Player>::MapType::iterator itr = m.begin(); itr != m.end(); ++itr)
       if (itr->second && itr->second->GetSession()->GetPlayer() && itr->second->GetSession()->GetPlayer()->IsInWorld())
           data << uint64(itr->second->GetGUID());

So the check should work but it seems it gets executed before a player joins the channels like Local etc.

So does anyone know how to fix this help is very much appreciated and once it's working these changes will be released to the public.

Thank you for your time, Xeross

Link to comment
Share on other sites


  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use