TrinityCore
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
cs_bg.cpp
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#include "Battleground.h"
19#include "Chat.h"
20#include "Language.h"
21#include "Player.h"
22#include "RBAC.h"
23#include "ScriptMgr.h"
24
25using namespace Trinity::ChatCommands;
26
28{
29public:
30 bg_commandscript() : CommandScript("bg_commandscript") { }
31
33 {
34 static ChatCommandTable commandTable =
35 {
38 };
39 return commandTable;
40 }
41
42 static bool HandleBgStartCommand(ChatHandler* handler)
43 {
44 Battleground* bg = handler->GetPlayer()->GetBattleground();
45 if (!bg)
46 {
48 handler->SetSentErrorMessage(true);
49 return false;
50 }
51
52 bg->SetStartDelayTime(0);
53
54 return true;
55 }
56
57 static bool HandleBgStopCommand(ChatHandler* handler)
58 {
59 Battleground* bg = handler->GetPlayer()->GetBattleground();
60 if (!bg)
61 {
63 handler->SetSentErrorMessage(true);
64 return false;
65 }
66
67 bg->EndBattleground(0);
68
69 return true;
70 }
71};
72
74{
75 new bg_commandscript();
76}
@ LANG_COMMAND_BG_STOP_HELP
Definition: Language.h:451
@ LANG_COMMAND_BG_START_HELP
Definition: Language.h:450
@ LANG_COMMAND_NO_BATTLEGROUND_FOUND
Definition: Language.h:1091
Role Based Access Control related classes definition.
virtual void EndBattleground(uint32 winner)
void SetStartDelayTime(int Time)
Definition: Battleground.h:321
void SetSentErrorMessage(bool val)
Definition: Chat.h:126
Player * GetPlayer() const
Definition: Chat.cpp:34
virtual void SendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition: Chat.cpp:101
Battleground * GetBattleground() const
Definition: Player.cpp:23196
ChatCommandTable GetCommands() const override
Definition: cs_bg.cpp:32
static bool HandleBgStartCommand(ChatHandler *handler)
Definition: cs_bg.cpp:42
static bool HandleBgStopCommand(ChatHandler *handler)
Definition: cs_bg.cpp:57
void AddSC_bg_commandscript()
Definition: cs_bg.cpp:73
std::vector< ChatCommandBuilder > ChatCommandTable
Definition: ChatCommand.h:50
@ RBAC_PERM_COMMAND_BG_STOP
Definition: RBAC.h:750
@ RBAC_PERM_COMMAND_BG_START
Definition: RBAC.h:749