Advertisement
Guest User

Help Ruissan

a guest
Jul 18th, 2012
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.56 KB | None | 0 0
  1. /* C++ Roulette for Trinity Core
  2.    Made by Crumpets
  3.    Idea and LUA version by Crash45
  4.    Error checking and fixed up by Rochet2 */
  5.  
  6.  
  7. class roulette_npc : public CreatureScript
  8. {
  9. public:
  10.     roulette_npc() : CreatureScript("roulette_npc") { }
  11.  
  12.     bool OnGossipHello(Player * pPlayer, Creature * pCreature)
  13.     {
  14.         pPlayer->ADD_GOSSIP_ITEM(3, "I would like to play", GOSSIP_SENDER_MAIN, 0);
  15.         pPlayer->ADD_GOSSIP_ITEM(1, "Nevermind", GOSSIP_SENDER_MAIN, 100);
  16.        
  17.         pPlayer->PlayerTalkClass->SendGossipMenu(141, pCreature->GetGUID()); //This can be any menu you like :)
  18.         return true;
  19.     }
  20.    
  21.    
  22.  
  23.    
  24.     bool TryToSellItem(Player *pPlayer, Creature * pCreature,unsigned int rewardID)
  25.        
  26.                 {
  27.                         pPlayer->CLOSE_GOSSIP_MENU();
  28.  
  29.                         uint32 noSpaceForCount = 0;
  30.  
  31.                         ItemPosCountVec dest;
  32.                         uint8 msg = pPlayer->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, rewardID, 1, &noSpaceForCount );
  33.                  unsigned int count = 1;
  34.                         if( msg != EQUIP_ERR_OK )                                                          
  35.                                 count -= noSpaceForCount;
  36.  
  37.                         if( count == 0 || dest.empty())                                          
  38.                         {
  39.                                 ChatHandler(pPlayer).PSendSysMessage(LANG_ITEM_CANNOT_CREATE, rewardID, noSpaceForCount );
  40.                                 return false;
  41.                         }
  42.                         Item* item = pPlayer->StoreNewItem( dest, rewardID, true, Item::GenerateItemRandomPropertyId(rewardID));
  43.  
  44.                         return true;
  45.                 }
  46.  
  47.     bool OnGossipSelect(Player * pPlayer, Creature * pCreature, uint32 sender, uint32 uiAction)
  48.     {
  49.        
  50.         pPlayer->PlayerTalkClass->ClearMenus();
  51.         if(uiAction == 0)
  52.         {
  53.         std::map<uint32, time_t> PlrCooldowns;
  54.         {
  55.             if(difftime (time(NULL), PlrCooldowns[pPlayer->GetGUIDLow()]) <= 180)
  56.             {  
  57.             if (pPlayer->isInCombat())
  58.             {
  59.                 pPlayer->GetSession()->SendNotification("You are in Combat!");
  60.             }
  61.             else
  62.             {
  63.                 switch (urand(1, 1))
  64.                 {
  65.                 case 1:
  66.                     PlrCooldowns[pPlayer->GetGUIDLow()] = time(NULL);
  67.                     pCreature->MonsterSay("This option is on test, But look in your bag!", LANG_UNIVERSAL, NULL);
  68.                     return TryToSellItem(pPlayer,pCreature, 36942);
  69.                     break;
  70.                 }
  71.             }
  72.             OnGossipHello(pPlayer, pCreature);
  73.         }
  74.         else
  75.         {
  76.             pPlayer->CLOSE_GOSSIP_MENU();
  77.         }
  78.         return true;
  79.             }
  80.         }
  81.     }
  82.    
  83. };
  84. void AddSC_roulette_npc()
  85. {
  86.     new roulette_npc();
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement