Advertisement
stoneharry

Untitled

Apr 18th, 2014
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.03 KB | None | 0 0
  1. void WorldSession::SendAddonMessage(Player* player, std::string message, uint32 packet)
  2. {
  3.     // Debug
  4.     TC_LOG_INFO("server.debug", "[DEBUG] Sending : %s", message);
  5.  
  6.     uint32 splitLength = 240;
  7.     uint32 splits = ceil(message.length() / splitLength);
  8.     uint32 counter = 1;
  9.     for (uint32 i = 0; i < message.length(); i += splitLength)
  10.     {
  11.         std::stringstream send;
  12.         send << std::setfill('0') << std::setw(3) << packet;
  13.         send << std::setw(2) << counter;
  14.         send << splits;
  15.         send << message.substr(splitLength * counter);
  16.         counter = counter + 1;
  17.  
  18.         TC_LOG_INFO("server.debug", "[DEBUG] Sending Formatted:\n\t%s", send.str().c_str());
  19.  
  20.         WorldPacket* data = new WorldPacket();
  21.         uint32 messageLength = message.length + 1;
  22.         data->Initialize(SMSG_MESSAGECHAT, 100);
  23.         *data << (uint8)CHAT_MSG_SYSTEM;
  24.         *data << LANG_ADDON;
  25.         *data << player->GetGUID();
  26.         *data << uint32(0);
  27.         *data << player->GetGUID();
  28.         *data << messageLength;
  29.         *data << send.str().c_str();
  30.         *data << uint8(0);
  31.         player->GetSession()->SendPacket(data);
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement