- /*
- *╔═╦═╦═╦╦╦══╦═╦╗─╔╦══╗
- *║╦╣║║║║║╠╗╗║╦╣╚╦╝║══╣
- *║╩╣║║║║║╠╩╝║╩╬╗║╔╬══║
- *╚═╩╩═╩╩═╩══╩═╝╚═╝╚══╝
- * www.emudevs.com
- */
- enum GoldVals
- {
- GOLD_ONE = 10000,
- GOLD_THREE = 30000,
- GOLD_FIVE = 50000,
- GOLD_TEN = 100000,
- };
- class npc_gamble : public CreatureScript
- {
- public:
- npc_gamble() : CreatureScript("npc_gamble") { }
- bool OnGossipHello(Player* player, Creature* creature)
- {
- if (player->GetMoney() < GOLD_ONE)
- {
- player->GetSession()->SendNotification("You don't have enough gold!");
- return false;
- }
- player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, "I would like to gamble gold [1g]", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
- player->ADD_GOSSIP_ITEM(GOSSIP_ICON_DOT, "Nevermind", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2);
- return true;
- }
- bool OnGossipSelect(Player* player, Creature* creature, uint32 /*sender*/, uint32 actions)
- {
- player->PlayerTalkClass->ClearMenus();
- if (actions == GOSSIP_ACTION_INFO_DEF+1)
- {
- player->ModifyMoney(-GOLD_ONE);
- int32 moneyValue = 0;
- bool wonOrLost = false;
- switch(rand()%5)
- {
- case 0:
- moneyValue = GOLD_ONE;
- wonOrLost = false;
- break;
- case 1:
- moneyValue = GOLD_THREE;
- wonOrLost = false;
- break;
- case 2:
- moneyValue = GOLD_TEN;
- wonOrLost = true;
- break;
- case 3:
- moneyValue = GOLD_FIVE;
- wonOrLost = false;
- break;
- case 4:
- moneyValue = GOLD_ONE;
- wonOrLost = true;
- break;
- }
- if (wonOrLost)
- {
- player->ModifyMoney(moneyValue);
- ChatHandler(player->GetSession()).PSendSysMessage("You won!");
- }
- else
- {
- if (player->HasEnoughMoney(moneyValue))
- {
- player->ModifyMoney(-moneyValue);
- ChatHandler(player->GetSession()).PSendSysMessage("You lost %i gold!", moneyValue);
- }
- else
- ChatHandler(player->GetSession()).PSendSysMessage("You lost, but you don't have enough money to lose!");
- }
- player->CLOSE_GOSSIP_MENU();
- }
- else
- player->CLOSE_GOSSIP_MENU();
- return true;
- }
- };
- void AddSC_on_gamble()
- {
- new npc_gamble;
- }
EmuDevs - Gambler