Advertisement
Guest User

[Trinity] Buffer Item Crash on Destroy

a guest
Nov 3rd, 2013
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.38 KB | None | 0 0
  1. #include "ScriptPCH.h"
  2. #include "Chat.h"
  3. #include "GroupMgr.h"
  4. #include "Group.h"
  5.  
  6. uint32 auras[] = { 48074, 47440, 53307, 132, 48170, 23737, 48470, 43002, 26393, 48162 };
  7. uint32 ITEM_ID = 100004;
  8.  
  9. class Buffer_VIP : public ItemScript
  10. {
  11. public:
  12.     Buffer_VIP() : ItemScript("Buffer_VIP") { }
  13.  
  14.     bool OnUse(Player * player, Item * /*item*/, SpellCastTargets const& /*targets*/)
  15.     {
  16.         if (player->IsInFlight())
  17.         {
  18.             player->GetSession()->SendNotification("You cannot use this in Flight!");
  19.             return true;
  20.         }
  21.  
  22.         if(player->IsInCombat())
  23.         {
  24.             player->GetSession()->SendNotification("You can't use this buff while in combat!");
  25.             return false;
  26.         }
  27.  
  28.         if (player->HasStealthAura() || player->HasFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_FEIGN_DEATH) || player->isDead())
  29.         {
  30.             player->GetSession()->SendNotification("You cannot use this,you are dead!");
  31.             return true;
  32.         }
  33.  
  34.         if (Group* playerGroup = player->GetGroup())
  35.         {
  36.             if (playerGroup->isRaidGroup())
  37.             {
  38.                 Player* GroupMember;
  39.                 const Group::MemberSlotList members = playerGroup->GetMemberSlots();
  40.                 for (Group::member_citerator itr = members.begin(); itr!= members.end(); ++itr)
  41.                 {
  42.                     GroupMember = (Unit::GetPlayer(*player, itr->guid));
  43.                     for(int i = 0; i < 10; i++)
  44.                     {
  45.                         GroupMember->AddAura(auras[i], GroupMember);
  46.                         player->GetSession()->SendNotification("|cffff0000You have been buffed yourself and your group!");
  47.                         if(player->HasItemCount(ITEM_ID, 1))
  48.                         {
  49.                         player->DestroyItemCount(ITEM_ID, 1, true, false);
  50.                         }
  51.                         return false;
  52.                     }
  53.                 }
  54.             }
  55.         }
  56.         else
  57.         {
  58.             for(int i = 0; i < 10; i++)
  59.             {
  60.                 player->AddAura(auras[i], player);
  61.                 player->GetSession()->SendNotification("|cffff0000You have been buffed!");
  62.                         if(player->HasItemCount(ITEM_ID, 1))
  63.                         {
  64.                         player->DestroyItemCount(ITEM_ID, 1, true, false);
  65.                         }
  66.                 return false;
  67.             }
  68.         }
  69.     }
  70. };
  71.  
  72. void AddSC_Buffer_VIP()
  73. {
  74.     new Buffer_VIP;
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement