1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
|
/*
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU GPL v2 license: http://github.com/azerothcore/azerothcore-wotlk/LICENSE-GPL2
* Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.org/>
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
*/
/* ScriptData
Name: message_commandscript
%Complete: 100
Comment: All message related commands
Category: commandscripts
EndScriptData */
#include "ScriptMgr.h"
#include "Chat.h"
#include "ChannelMgr.h"
#include "Language.h"
#include "Player.h"
class message_commandscript : public CommandScript
{
public:
message_commandscript() : CommandScript("message_commandscript") { }
std::vector<ChatCommand> GetCommands() const override
{
static std::vector<ChatCommand> commandTable =
{
{ "nameannounce", SEC_GAMEMASTER, true, &HandleNameAnnounceCommand, "" },
{ "gmnameannounce", SEC_GAMEMASTER, true, &HandleGMNameAnnounceCommand, "" },
{ "announce", SEC_GAMEMASTER, true, &HandleAnnounceCommand, "" },
{ "gmannounce", SEC_GAMEMASTER, true, &HandleGMAnnounceCommand, "" },
{ "notify", SEC_GAMEMASTER, true, &HandleNotifyCommand, "" },
{ "gmnotify", SEC_GAMEMASTER, true, &HandleGMNotifyCommand, "" },
{ "whispers", SEC_GAMEMASTER, false, &HandleWhispersCommand, "" }
};
return commandTable;
}
static bool HandleNameAnnounceCommand(ChatHandler* handler, char const* args)
{
if (!*args)
return false;
std::string name("Console");
if (WorldSession* session = handler->GetSession())
name = session->GetPlayer()->GetName();
sWorld->SendWorldText(LANG_ANNOUNCE_COLOR, name.c_str(), args);
return true;
}
static bool HandleGMNameAnnounceCommand(ChatHandler* handler, char const* args)
{
if (!*args)
return false;
std::string name("Console");
if (WorldSession* session = handler->GetSession())
name = session->GetPlayer()->GetName();
sWorld->SendGMText(LANG_GM_ANNOUNCE_COLOR, name.c_str(), args);
return true;
}
// global announce
static bool HandleAnnounceCommand(ChatHandler* handler, char const* args)
{
if (!*args)
return false;
char buff[2048];
sprintf(buff, handler->GetTrinityString(LANG_SYSTEMMESSAGE), args);
sWorld->SendServerMessage(SERVER_MSG_STRING, buff);
return true;
}
// announce to logged in GMs
static bool HandleGMAnnounceCommand(ChatHandler* /*handler*/, char const* args)
{
if (!*args)
return false;
sWorld->SendGMText(LANG_GM_BROADCAST, args);
return true;
}
// notification player at the screen
static bool HandleNotifyCommand(ChatHandler* handler, char const* args)
{
if (!*args)
return false;
std::string str = handler->GetTrinityString(LANG_GLOBAL_NOTIFY);
str += args;
WorldPacket data(SMSG_NOTIFICATION, (str.size()+1));
data << str;
sWorld->SendGlobalMessage(&data);
return true;
}
// notification GM at the screen
static bool HandleGMNotifyCommand(ChatHandler* handler, char const* args)
{
if (!*args)
return false;
std::string str = handler->GetTrinityString(LANG_GM_NOTIFY);
str += args;
WorldPacket data(SMSG_NOTIFICATION, (str.size()+1));
data << str;
sWorld->SendGlobalGMMessage(&data);
return true;
}
// Enable\Dissable accept whispers (for GM)
static bool HandleWhispersCommand(ChatHandler* handler, char const* args)
{
if (!*args)
{
handler->PSendSysMessage(LANG_COMMAND_WHISPERACCEPTING, handler->GetSession()->GetPlayer()->isAcceptWhispers() ? handler->GetTrinityString(LANG_ON) : handler->GetTrinityString(LANG_OFF));
return true;
}
std::string argStr = (char*)args;
// whisper on
if (argStr == "on")
{
handler->GetSession()->GetPlayer()->SetAcceptWhispers(true);
handler->SendSysMessage(LANG_COMMAND_WHISPERON);
return true;
}
// whisper off
if (argStr == "off")
{
// Remove all players from the Gamemaster's whisper whitelist
handler->GetSession()->GetPlayer()->ClearWhisperWhiteList();
handler->GetSession()->GetPlayer()->SetAcceptWhispers(false);
handler->SendSysMessage(LANG_COMMAND_WHISPEROFF);
return true;
}
handler->SendSysMessage(LANG_USE_BOL);
handler->SetSentErrorMessage(true);
return false;
}
};
void AddSC_message_commandscript()
{
new message_commandscript();
}
|