Advertisement
carcar21

Untitled

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