Advertisement
Rochet2

RW

Aug 5th, 2012
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.75 KB | None | 0 0
  1. #include "ScriptMgr.h"
  2. #include "Chat.h"
  3.  
  4. class cmd_raid_warning : public CommandScript
  5. {
  6. public:
  7.     cmd_raid_warning() : CommandScript("cmd_raid_warning") { }
  8.  
  9.     ChatCommand* GetCommands() const
  10.     {
  11.         static ChatCommand HelloWorldCommandTable[] =
  12.         {
  13.             { "raidwarning",    SEC_PLAYER,         true,   &HandleRaidWarningCommand,        "", NULL },
  14.             { NULL,             0,                  false,  NULL,                            "", NULL }
  15.         };
  16.         return HelloWorldCommandTable;
  17.     }
  18.  
  19.     static bool HandleRaidWarningCommand(ChatHandler* handler, const char* args)
  20.     {
  21.         // check args
  22.         if (!*args)
  23.             return false;
  24.  
  25.         // insert the player name and the message to the text
  26.         char msg[256]; 
  27.         sprintf(msg, "[Tag] %s says: %s", handler->GetSession()->GetPlayerName(), args); // First %s is the player name and second %s is the message. Feel free to edit. (GetPlayerName() gets the player name and args is the message)
  28.  
  29.         // Get string length for packet
  30.         uint32 textLen = (uint32)strlen(msg) + 1;
  31.  
  32.         // Create the packet that SendWorldRaidWarning would have created (this is almost a direct copy paste of your original SendWorldRaidWarning function
  33.         WorldPacket data(textLen + 40);
  34.  
  35.         data.Initialize(SMSG_MESSAGECHAT);
  36.         data << uint8(CHAT_MSG_RAID_WARNING);
  37.         data << uint32(LANG_UNIVERSAL);
  38.  
  39.         data << (uint64)0;
  40.         data << (uint32)0;
  41.         data << (uint64)0;
  42.  
  43.         data << textLen;
  44.         data << msg;
  45.         data << uint8(0);
  46.  
  47.         sWorld->SendGlobalMessage(&data); // send the packet
  48.         return true;
  49.     }
  50. };
  51.  
  52. void AddSC_cmd_raid_warning()
  53. {
  54.     new cmd_raid_warning();
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement