Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Honor Gamble script Created by yvoms 5-11-2014
- This is just a very simple gamble script where an user inputs an amount of honor and has chance on doubling the amount.
- */
- #pragma warning(disable:4146)
- #define HONOR 43308
- class gamble_npc : public CreatureScript
- {
- public:
- gamble_npc() : CreatureScript("gamble_npc") { }
- bool OnGossipHello(Player * player, Creature * creature)
- {
- player->ADD_GOSSIP_ITEM_EXTENDED(3, "I want to play!", GOSSIP_SENDER_MAIN, HONOR, "Insert amount of Honor", 0, true);
- player->ADD_GOSSIP_ITEM(3, "How does this Game work?", GOSSIP_SENDER_MAIN, 0);
- player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
- return true;
- }
- bool OnGossipSelect(Player * player, Creature * creature, uint32 sender, uint32 uiAction)
- {
- player->PlayerTalkClass->ClearMenus();
- if(uiAction == 0)
- {
- // Check this later on
- player->ADD_GOSSIP_ITEM(7, "Back..", GOSSIP_SENDER_MAIN, 1);
- player->SEND_GOSSIP_MENU(123432, creature->GetGUID());
- }
- else if(uiAction == 1)
- {
- OnGossipHello(player, creature);
- }
- else if(uiAction == 2)
- {
- player->CLOSE_GOSSIP_MENU();
- }
- return true;
- }
- bool OnGossipSelectCode(Player* player, Creature* creature, uint32 sender, uint32 uiAction, const char* code)
- {
- player->PlayerTalkClass->ClearMenus();
- uint32 amount = 0;
- amount = uint32(atol(code));
- if(amount < 1 || !player->HasItemCount(uiAction, amount, false))
- {
- player->GetSession()->SendNotification("Invalid amount inserted");
- }
- else
- {
- if(urand(1,2) == 1)
- {
- GiveItemAmount(player, uiAction, amount);
- }
- else
- {
- player->DestroyItemCount(uiAction, amount, true);
- }
- }
- OnGossipSelect(player, creature, sender, 0);
- return true;
- }
- // You CAN ignore this whole thing.
- bool GiveItemAmount(Player * player, uint32 itemEntry, uint32 amount)
- {
- if (amount < 0)
- {
- player->DestroyItemCount(itemEntry, -amount, true, false);
- return true;
- }
- if (amount == 0)
- amount = 1;
- uint32 noSpaceForCount = 0;
- ItemPosCountVec dest;
- uint8 msg = player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, itemEntry, amount, &noSpaceForCount);
- if (msg != EQUIP_ERR_OK)
- amount -= noSpaceForCount;
- if (amount == 0 || dest.empty())
- return false;
- Item* item = player->StoreNewItem(dest, itemEntry, true, Item::GenerateItemRandomPropertyId(itemEntry));
- return true;
- }
- };
- void AddSC_gamble_npc()
- {
- new gamble_npc();
- }
Advertisement
Add Comment
Please, Sign In to add comment