Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* C++ Roulette for Trinity Core
- Made by Crumpets
- Idea and LUA version by Crash45
- Error checking and fixed up by Rochet2 */
- class roulette_npc : public CreatureScript
- {
- public:
- roulette_npc() : CreatureScript("roulette_npc") { }
- bool OnGossipHello(Player * pPlayer, Creature * pCreature)
- {
- pPlayer->ADD_GOSSIP_ITEM(3, "I would like to play", GOSSIP_SENDER_MAIN, 0);
- pPlayer->ADD_GOSSIP_ITEM(1, "Nevermind", GOSSIP_SENDER_MAIN, 100);
- pPlayer->PlayerTalkClass->SendGossipMenu(141, pCreature->GetGUID()); //This can be any menu you like :)
- return true;
- }
- bool TryToSellItem(Player *pPlayer, Creature * pCreature,unsigned int rewardID)
- {
- pPlayer->CLOSE_GOSSIP_MENU();
- uint32 noSpaceForCount = 0;
- ItemPosCountVec dest;
- uint8 msg = pPlayer->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, rewardID, 1, &noSpaceForCount );
- unsigned int count = 1;
- if( msg != EQUIP_ERR_OK )
- count -= noSpaceForCount;
- if( count == 0 || dest.empty())
- {
- ChatHandler(pPlayer).PSendSysMessage(LANG_ITEM_CANNOT_CREATE, rewardID, noSpaceForCount );
- return false;
- }
- Item* item = pPlayer->StoreNewItem( dest, rewardID, true, Item::GenerateItemRandomPropertyId(rewardID));
- return true;
- }
- bool OnGossipSelect(Player * pPlayer, Creature * pCreature, uint32 sender, uint32 uiAction)
- {
- pPlayer->PlayerTalkClass->ClearMenus();
- if(uiAction == 0)
- {
- std::map<uint32, time_t> PlrCooldowns;
- {
- if(difftime (time(NULL), PlrCooldowns[pPlayer->GetGUIDLow()]) <= 180)
- {
- if (pPlayer->isInCombat())
- {
- pPlayer->GetSession()->SendNotification("You are in Combat!");
- }
- else
- {
- switch (urand(1, 1))
- {
- case 1:
- PlrCooldowns[pPlayer->GetGUIDLow()] = time(NULL);
- pCreature->MonsterSay("This option is on test, But look in your bag!", LANG_UNIVERSAL, NULL);
- return TryToSellItem(pPlayer,pCreature, 36942);
- break;
- }
- }
- OnGossipHello(pPlayer, pCreature);
- }
- else
- {
- pPlayer->CLOSE_GOSSIP_MENU();
- }
- return true;
- }
- }
- }
- };
- void AddSC_roulette_npc()
- {
- new roulette_npc();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement