diff options
| author | r4dish <ovitnez@gmail.com> | 2024-01-06 12:51:24 +0200 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2024-01-06 23:43:59 +0100 |
| commit | c2831bafded61dcd417535a444c2dfbb454171bb (patch) | |
| tree | 2b48e27af6cbd5d7c99f974c7022f5047f3d995a /src/server/scripts/Commands | |
| parent | 554fc8eee0bcbb70acd012c04f6f02197c6d949c (diff) | |
Scripts/Commands: Implemented .bg start and .bg stop commands.
Diffstat (limited to 'src/server/scripts/Commands')
| -rw-r--r-- | src/server/scripts/Commands/cs_bg.cpp | 76 | ||||
| -rw-r--r-- | src/server/scripts/Commands/cs_script_loader.cpp | 2 |
2 files changed, 78 insertions, 0 deletions
diff --git a/src/server/scripts/Commands/cs_bg.cpp b/src/server/scripts/Commands/cs_bg.cpp new file mode 100644 index 00000000000..7751c124982 --- /dev/null +++ b/src/server/scripts/Commands/cs_bg.cpp @@ -0,0 +1,76 @@ +/* + * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include "Battleground.h" +#include "Chat.h" +#include "Language.h" +#include "Player.h" +#include "RBAC.h" +#include "ScriptMgr.h" + +using namespace Trinity::ChatCommands; + +class bg_commandscript : public CommandScript +{ +public: + bg_commandscript() : CommandScript("bg_commandscript") { } + + ChatCommandTable GetCommands() const override + { + static ChatCommandTable commandTable = + { + { "bg start", HandleBgStartCommand, LANG_COMMAND_BG_START_HELP, rbac::RBAC_PERM_COMMAND_BG_START, Console::No }, + { "bg stop", HandleBgStopCommand, LANG_COMMAND_BG_STOP_HELP, rbac::RBAC_PERM_COMMAND_BG_STOP, Console::No } + }; + return commandTable; + } + + static bool HandleBgStartCommand(ChatHandler* handler) + { + Battleground* bg = handler->GetPlayer()->GetBattleground(); + if (!bg) + { + handler->SendSysMessage(LANG_COMMAND_NO_BATTLEGROUND_FOUND); + handler->SetSentErrorMessage(true); + return false; + } + + bg->SetStartDelayTime(0); + + return true; + } + + static bool HandleBgStopCommand(ChatHandler* handler) + { + Battleground* bg = handler->GetPlayer()->GetBattleground(); + if (!bg) + { + handler->SendSysMessage(LANG_COMMAND_NO_BATTLEGROUND_FOUND); + handler->SetSentErrorMessage(true); + return false; + } + + bg->EndBattleground(0); + + return true; + } +}; + +void AddSC_bg_commandscript() +{ + new bg_commandscript(); +} diff --git a/src/server/scripts/Commands/cs_script_loader.cpp b/src/server/scripts/Commands/cs_script_loader.cpp index dd8fb48f22f..db22b83eeda 100644 --- a/src/server/scripts/Commands/cs_script_loader.cpp +++ b/src/server/scripts/Commands/cs_script_loader.cpp @@ -22,6 +22,7 @@ void AddSC_ahbot_commandscript(); void AddSC_arena_commandscript(); void AddSC_ban_commandscript(); void AddSC_bf_commandscript(); +void AddSC_bg_commandscript(); void AddSC_cast_commandscript(); void AddSC_character_commandscript(); void AddSC_cheat_commandscript(); @@ -67,6 +68,7 @@ void AddCommandsScripts() AddSC_arena_commandscript(); AddSC_ban_commandscript(); AddSC_bf_commandscript(); + AddSC_bg_commandscript(); AddSC_cast_commandscript(); AddSC_character_commandscript(); AddSC_cheat_commandscript(); |
