Scripts/Commands: Implemented .bg start and .bg stop commands.

This commit is contained in:
r4dish
2024-01-06 12:51:24 +02:00
committed by Shauren
parent 554fc8eee0
commit c2831bafde
7 changed files with 107 additions and 3 deletions

View File

@@ -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();
}

View File

@@ -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();