Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "ScriptMgr.h"
- #include "ObjectMgr.h"
- #include "MapManager.h"
- #include "Chat.h"
- #include "Common.h"
- #include "Language.h"
- #include "CellImpl.h"
- #include "GridNotifiers.h"
- #include "Player.h"
- class recallCommand : public CommandScript
- {
- public:
- recallCommand() : CommandScript("recallCommand"){}
- ChatCommand* GetCommands() const
- {
- static ChatCommand recallCommandTable[] =
- {
- { "go", SEC_PLAYER, true, &HandleRecallGoCommand, "", NULL },
- { "set", SEC_PLAYER, false, &HandleRecallSetCommand, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
- };
- static ChatCommand commandTable[] =
- {
- { "hearth", SEC_PLAYER, true, NULL, "", recallCommandTable },
- { NULL, 0, false, NULL, "", NULL }
- };
- return commandTable;
- }
- static bool HandleRecallGoCommand(ChatHandler * handler, const char * args)
- {
- if (!*args)
- return false;
- Player* me = handler->GetSession()->GetPlayer();
- GameTele const* location = handler->extractGameTeleFromLink((char*)args);
- if (!location)
- {
- handler->SendSysMessage(LANG_COMMAND_TELE_NOTFOUND);
- handler->SetSentErrorMessage(true);
- return false;
- }
- if (me->IsInCombat())
- {
- handler->SendSysMessage(LANG_YOU_IN_COMBAT);
- handler->SetSentErrorMessage(true);
- return false;
- }
- MapEntry const* map = sMapStore.LookupEntry(location->mapId);
- if (!map || map->IsBattlegroundOrArena())
- {
- handler->SendSysMessage(LANG_CANNOT_TELE_TO_BG);
- handler->SetSentErrorMessage(true);
- return false;
- }
- if (me->IsInFlight())
- {
- me->GetMotionMaster()->MovementExpired();
- me->CleanupAfterTaxiFlight();
- }
- else
- me->CastSpell(me, 8690, 0);
- return true;
- }
- static bool HandleRecallSetCommand(ChatHandler* handler, const char* args)
- {
- Player* me = handler->GetSession()->GetPlayer();
- if (me->IsInCombat())
- {
- handler->SendSysMessage(LANG_YOU_IN_COMBAT);
- handler->SetSentErrorMessage(true);
- return false;
- }
- if (me->InBattleground())
- {
- me->GetSession()->SendNotification("You can't set your location in battleground.");
- handler->SetSentErrorMessage(true);
- return false;
- }
- else
- me->SetBindPoint(me->GetPositionX*(), me->GetPositionY*(), me->GetPositionZ*(), me->GetMapId*(), me->GetZoneId*());
- return true;
- }
- };
- void AddSC_recallcommand()
- {
- new recallCommand();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement