Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "ScriptMgr.h"
- #include "Chat.h"
- class cmd_raid_warning : public CommandScript
- {
- public:
- cmd_raid_warning() : CommandScript("cmd_raid_warning") { }
- ChatCommand* GetCommands() const
- {
- static ChatCommand HelloWorldCommandTable[] =
- {
- { "raidwarning", SEC_PLAYER, true, &HandleRaidWarningCommand, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
- };
- return HelloWorldCommandTable;
- }
- static bool HandleRaidWarningCommand(ChatHandler* handler, const char* args)
- {
- // check args
- if (!*args)
- return false;
- // insert the player name and the message to the text
- char msg[256];
- 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)
- // Get string length for packet
- uint32 textLen = (uint32)strlen(msg) + 1;
- // Create the packet that SendWorldRaidWarning would have created (this is almost a direct copy paste of your original SendWorldRaidWarning function
- WorldPacket data(textLen + 40);
- data.Initialize(SMSG_MESSAGECHAT);
- data << uint8(CHAT_MSG_RAID_WARNING);
- data << uint32(LANG_UNIVERSAL);
- data << (uint64)0;
- data << (uint32)0;
- data << (uint64)0;
- data << textLen;
- data << msg;
- data << uint8(0);
- sWorld->SendGlobalMessage(&data); // send the packet
- return true;
- }
- };
- void AddSC_cmd_raid_warning()
- {
- new cmd_raid_warning();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement