Advertisement
Easelm

Gossip Npc Summon Player's Group by QQrofl/Tommy

Apr 15th, 2012
280
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.28 KB | None | 0 0
  1. /*******************************************************************************************
  2. *              _   _                                      __   _                           *
  3. *              | \ | |   ___    _ __ ___    ___    ___    / _| | |_                        *
  4. *              |  \| |  / _ \  | '_ ` _ \  / __|  / _ \  | |_  | __|                       *
  5. *              | |\  | | (_) | | | | | | | \__ \ | (_) | |  _| | |_                        *
  6. *              |_| \_|  \___/  |_| |_| |_| |___/  \___/  |_|    \__|                       *
  7. *                               The policy of Nomsoftware states: Releasing our software   *
  8. *                               or any other files are protected. You cannot re-release    *
  9. *                               anywhere unless you were given permission.                 *
  10. *                           (C) Nomsoftware 2011-2012. All rights reserved.                *
  11. ********************************************************************************************/
  12.  
  13. #include "ScriptPCH.h"
  14. #include "Group.h"
  15.  
  16. class npc_summon_gossip : public CreatureScript
  17. {
  18.    public:
  19.        npc_summon_gossip() : CreatureScript("npc_summon_gossip") { }
  20.  
  21.        bool OnGossipHello(Player * player, Creature * creature)
  22.        {
  23.            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Summon Group", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
  24.            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Nevermind", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2);
  25.            player->SEND_GOSSIP_MENU(1, creature->GetGUID());
  26.            return true;
  27.        }
  28.  
  29.        bool OnGossipSelect(Player * player, Creature * creature, uint32 sender, uint32 actions)
  30.        {
  31.            if(sender == GOSSIP_SENDER_MAIN)
  32.            {
  33.                switch(actions)
  34.                {
  35.                   case GOSSIP_ACTION_INFO_DEF+1:
  36.                   {
  37.                        Group * group = player->GetGroup();
  38.                        if(!group) // If the player isn't in a group
  39.                        {
  40.                            player->MonsterWhisper("You aren't in a group!", player->GetGUID());
  41.                            player->PlayerTalkClass->SendCloseGossip(); // Closing the gossip menu
  42.                            return false;
  43.                        }
  44.  
  45.                        if(group->IsLeader(player->GetGUID())) // If the current player is this group's leader
  46.                        {
  47.                            for (GroupReference* itr = group->GetFirstMember(); itr != NULL; itr = itr->next())
  48.                            {
  49.                                Player * plr = itr->getSource();
  50.  
  51.                                if (!plr || !plr->GetSession())
  52.                                    continue;
  53.  
  54.                                if (plr->IsBeingTeleported()) // If is being teleported..
  55.                                    continue;
  56.  
  57.                                if (plr->isInFlight()) // Is the player in flight?
  58.                                {
  59.                                     plr->GetMotionMaster()->MovementExpired();
  60.                                     plr->CleanupAfterTaxiFlight();
  61.                                }
  62.                                else
  63.                                    plr->SaveRecallPosition();
  64.  
  65.                                plr->TeleportTo(player->GetMapId(), player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetOrientation());
  66.                            }
  67.                        }
  68.                        else
  69.                        {
  70.                            player->MonsterWhisper("You aren't the leader of this group!", player->GetGUID());
  71.                            player->PlayerTalkClass->SendCloseGossip();
  72.                        }
  73.                   }break;
  74.  
  75.                   case GOSSIP_ACTION_INFO_DEF+2:
  76.                       player->PlayerTalkClass->SendCloseGossip();
  77.                   break;
  78.                }
  79.            }
  80.            return true;
  81.        }
  82. };
  83.  
  84. void AddSC_summon_setup()
  85. {
  86.     new npc_summon_gossip;
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement