mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-26 23:26:23 +00:00
87 lines
2.7 KiB
C++
87 lines
2.7 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/>
|
|
*/
|
|
|
|
/* ScriptData
|
|
Name: achievement_commandscript
|
|
%Complete: 100
|
|
Comment: All achievement related commands
|
|
Category: commandscripts
|
|
EndScriptData */
|
|
|
|
#include "Chat.h"
|
|
#include "Language.h"
|
|
#include "Player.h"
|
|
#include "ScriptMgr.h"
|
|
|
|
class achievement_commandscript : public CommandScript
|
|
{
|
|
public:
|
|
achievement_commandscript() : CommandScript("achievement_commandscript") { }
|
|
|
|
ChatCommand* GetCommands() const
|
|
{
|
|
static ChatCommand achievementCommandTable[] =
|
|
{
|
|
{ "add", SEC_ADMINISTRATOR, false, &HandleAchievementAddCommand, "", NULL },
|
|
{ "checkall", SEC_ADMINISTRATOR, false, &HandleAchievementCheckAllCommand, "", NULL },
|
|
{ NULL, 0, false, NULL, "", NULL }
|
|
};
|
|
static ChatCommand commandTable[] =
|
|
{
|
|
{ "achievement", SEC_ADMINISTRATOR, false, NULL, "", achievementCommandTable },
|
|
{ NULL, 0, false, NULL, "", NULL }
|
|
};
|
|
return commandTable;
|
|
}
|
|
|
|
static bool HandleAchievementAddCommand(ChatHandler* handler, char const* args)
|
|
{
|
|
if (!*args)
|
|
return false;
|
|
|
|
uint32 achievementId = atoi((char*)args);
|
|
if (!achievementId)
|
|
{
|
|
if (char* id = handler->extractKeyFromLink((char*)args, "Hachievement"))
|
|
achievementId = atoi(id);
|
|
if (!achievementId)
|
|
return false;
|
|
}
|
|
|
|
Player* target = handler->getSelectedPlayer();
|
|
if (!target)
|
|
{
|
|
handler->SendSysMessage(LANG_NO_CHAR_SELECTED);
|
|
handler->SetSentErrorMessage(true);
|
|
return false;
|
|
}
|
|
|
|
if (AchievementEntry const* achievementEntry = sAchievementStore.LookupEntry(achievementId))
|
|
target->CompletedAchievement(achievementEntry);
|
|
|
|
return true;
|
|
}
|
|
|
|
static bool HandleAchievementCheckAllCommand(ChatHandler* handler, char const* args)
|
|
{
|
|
Player* target = handler->getSelectedPlayer();
|
|
if (!target)
|
|
{
|
|
handler->SendSysMessage(LANG_NO_CHAR_SELECTED);
|
|
handler->SetSentErrorMessage(true);
|
|
return false;
|
|
}
|
|
|
|
target->CheckAllAchievementCriteria();
|
|
return true;
|
|
}
|
|
};
|
|
|
|
void AddSC_achievement_commandscript()
|
|
{
|
|
new achievement_commandscript();
|
|
}
|