stoneharry

Untitled

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