Advertisement
Emulation

Untitled

Sep 24th, 2013
458
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.74 KB | None | 0 0
  1. /*####################################
  2. #                                    #
  3. #                                    #
  4. #     Made By Emulation              #
  5. ######################################  */
  6.  
  7. #include "ScriptMgr.h"
  8. #include "ObjectMgr.h"
  9. #include "MapManager.h"
  10. #include "Chat.h"
  11. #include "Common.h"
  12. #include "Language.h"
  13. #include "CellImpl.h"
  14. #include "GridNotifiers.h"
  15.  
  16. class recallCommand : public CommandScript
  17. {
  18. public:
  19.     recallCommand() : CommandScript("recallCommand"){}
  20.    
  21.     ChatCommand* GetCommands() const
  22.     {
  23.         static ChatCommand recallCommandTable[] =
  24.        
  25.         {
  26.                 { "go",     SEC_PLAYER,     true, &HandleRecallGoCommand,       "", NULL },
  27.                 { "set",    SEC_PLAYER,     false, &HandleRecallSetCommand      "", NULL },
  28.                
  29.                 { NULL,     0,              false, NULL,                        "", NULL }
  30.         };
  31.        
  32.         static ChatCommand commandTable[] =
  33.         {
  34.             ( "hearth",     SEC_PLAYER,     true, NULL,         "", recallCommandTable},
  35.             { NULL,     0,              false, NULL,                        "", NULL }
  36.         };
  37.     return commandTable;
  38.     }
  39.    
  40.     static bool HandlerecallCommand(ChatHandler* handler, const char* args)
  41.     {
  42.          Player* me = handler->GetSession()->GetPlayer();
  43.          return true;
  44.         if(!player)
  45.             return false;
  46.     }
  47.    
  48.     static bool HandleRecallGoCommand(ChatHandler * handler, const char * args)
  49.     {
  50.         if(!*args)
  51.             return false;
  52.            
  53.             Player* me = handler->GetSession()->GetPlayer();
  54.             GameTele const* location = handler->extractGameTeleFromLink((char*)args);
  55.            
  56.             if(!location)
  57.             {
  58.                 hander->SendSysMessage(LAND_COMMAND_TELE_NOTFOUND);
  59.                 handler->SetSentErrorMessage(true);
  60.                 return false;
  61.             }
  62.             if(me->isInCombat())
  63.             {
  64.                 handler->SendSysMessage(LANG_YOU_IN_COMBAT);
  65.                 handler->SetSentErrorMessage(true);
  66.                 return false;
  67.             }
  68.             MapEntry const* map = sMapStore.LookypEntry(tele->mapId);
  69.             if(!map || map->IsBattlegroundOrArena())
  70.             {
  71.                 handler->SendSysMessage(LANG_CANNOT_TELE_TO_BG);
  72.                 handler->SetSentErrorMessage(true);
  73.                 return false;
  74.             }
  75.            
  76.             if(me->isInFlight())
  77.             {
  78.                 me->GetMotionMaster()->MovementExpired();
  79.                 me->CleanupAfterTaxiFlight();
  80.             }
  81.             else
  82.                 me->CastSpell(me, 8690, 0);
  83.                 return true;
  84.             }
  85.  
  86.    
  87.     static bool HandleRecallSetCommand(ChatHandler* handler, const char* args)
  88.     {
  89.         Player* me = handler->GetSession()->GetPlayer();
  90.         if(me->isInCombat())
  91.         {
  92.             me->GetSession()->SendNotification("You can't set your location while in combat.");
  93.             return false;
  94.         }
  95.         if(me->IsBattleGroundOrArena())
  96.         {
  97.             me->GetSession()->SendNotification("You can't set your location in an arena or battleground.");
  98.             return false;
  99.         }
  100.         else
  101.        
  102.         me->SetBindPoint(me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), me->GetMapId(), me->GetZoneId());
  103.         return true;   
  104.     }
  105.        
  106. };
  107.  
  108. void AddSC_recallcommand()
  109. {
  110.     new recallCommand();
  111. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement