mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2025-11-29 17:38:24 +08:00
125 lines
4.1 KiB
C++
125 lines
4.1 KiB
C++
/*
|
|
* 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/>
|
|
*/
|
|
|
|
#include "ScriptMgr.h"
|
|
#include "Chat.h"
|
|
#include "Language.h"
|
|
#include "LFGMgr.h"
|
|
#include "Group.h"
|
|
#include "Player.h"
|
|
|
|
void GetPlayerInfo(ChatHandler* handler, Player* player)
|
|
{
|
|
if (!player)
|
|
return;
|
|
|
|
uint64 guid = player->GetGUID();
|
|
lfg::LfgDungeonSet dungeons = sLFGMgr->GetSelectedDungeons(guid);
|
|
|
|
/*std::string const& state = lfg::GetStateString(sLFGMgr->GetState(guid));
|
|
handler->PSendSysMessage(LANG_LFG_PLAYER_INFO, player->GetName().c_str(),
|
|
state.c_str(), uint8(dungeons.size()), lfg::ConcatenateDungeons(dungeons).c_str(),
|
|
lfg::GetRolesString(sLFGMgr->GetRoles(guid)).c_str(), sLFGMgr->GetComment(guid).c_str());*/
|
|
}
|
|
|
|
class lfg_commandscript : public CommandScript
|
|
{
|
|
public:
|
|
lfg_commandscript() : CommandScript("lfg_commandscript") { }
|
|
|
|
std::vector<ChatCommand> GetCommands() const override
|
|
{
|
|
static std::vector<ChatCommand> lfgCommandTable =
|
|
{
|
|
{ "player", SEC_GAMEMASTER, false, &HandleLfgPlayerInfoCommand, "" },
|
|
{ "group", SEC_GAMEMASTER, false, &HandleLfgGroupInfoCommand, "" },
|
|
{ "queue", SEC_GAMEMASTER, false, &HandleLfgQueueInfoCommand, "" },
|
|
{ "clean", SEC_ADMINISTRATOR, false, &HandleLfgCleanCommand, "" },
|
|
{ "options", SEC_ADMINISTRATOR, false, &HandleLfgOptionsCommand, "" },
|
|
{ NULL, SEC_PLAYER, false, NULL, "" }
|
|
};
|
|
|
|
static std::vector<ChatCommand> commandTable =
|
|
{
|
|
{ "lfg", SEC_GAMEMASTER, false, NULL, "", lfgCommandTable },
|
|
{ NULL, SEC_PLAYER, false, NULL, "" }
|
|
};
|
|
return commandTable;
|
|
}
|
|
|
|
static bool HandleLfgPlayerInfoCommand(ChatHandler* handler, char const* args)
|
|
{
|
|
Player* target = NULL;
|
|
std::string playerName;
|
|
if (!handler->extractPlayerTarget((char*)args, &target, NULL, &playerName))
|
|
return false;
|
|
|
|
GetPlayerInfo(handler, target);
|
|
return true;
|
|
}
|
|
|
|
static bool HandleLfgGroupInfoCommand(ChatHandler* handler, char const* args)
|
|
{
|
|
Player* target = NULL;
|
|
std::string playerName;
|
|
if (!handler->extractPlayerTarget((char*)args, &target, NULL, &playerName))
|
|
return false;
|
|
|
|
Group* grp = target->GetGroup();
|
|
if (!grp)
|
|
{
|
|
handler->PSendSysMessage(LANG_LFG_NOT_IN_GROUP, playerName.c_str());
|
|
return true;
|
|
}
|
|
/*
|
|
uint64 guid = grp->GetGUID();
|
|
std::string const& state = lfg::GetStateString(sLFGMgr->GetState(guid));
|
|
handler->PSendSysMessage(LANG_LFG_GROUP_INFO, grp->isLFGGroup(),
|
|
state.c_str(), sLFGMgr->GetDungeon(guid));
|
|
|
|
for (GroupReference* itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
|
|
GetPlayerInfo(handler, itr->GetSource());
|
|
*/
|
|
return true;
|
|
}
|
|
|
|
static bool HandleLfgOptionsCommand(ChatHandler* handler, char const* args)
|
|
{
|
|
int32 options = -1;
|
|
if (char* str = strtok((char*)args, " "))
|
|
{
|
|
int32 tmp = atoi(str);
|
|
if (tmp > -1)
|
|
options = tmp;
|
|
}
|
|
|
|
if (options != -1)
|
|
{
|
|
sLFGMgr->SetOptions(options);
|
|
handler->PSendSysMessage(LANG_LFG_OPTIONS_CHANGED);
|
|
}
|
|
handler->PSendSysMessage(LANG_LFG_OPTIONS, sLFGMgr->GetOptions());
|
|
return true;
|
|
}
|
|
|
|
static bool HandleLfgQueueInfoCommand(ChatHandler* handler, char const* args)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
static bool HandleLfgCleanCommand(ChatHandler* handler, char const* /*args*/)
|
|
{
|
|
handler->PSendSysMessage(LANG_LFG_CLEAN);
|
|
sLFGMgr->Clean();
|
|
return true;
|
|
}
|
|
};
|
|
|
|
void AddSC_lfg_commandscript()
|
|
{
|
|
new lfg_commandscript();
|
|
}
|