1. /*
  2. *╔═╦═╦═╦╦╦══╦═╦╗─╔╦══╗
  3. *║╦╣║║║║║╠╗╗║╦╣╚╦╝║══╣
  4. *║╩╣║║║║║╠╩╝║╩╬╗║╔╬══║
  5. *╚═╩╩═╩╩═╩══╩═╝╚═╝╚══╝
  6. * www.emudevs.com
  7. */
  8. enum GoldVals
  9. {
  10. GOLD_ONE = 10000,
  11. GOLD_THREE = 30000,
  12. GOLD_FIVE = 50000,
  13. GOLD_TEN = 100000,
  14. };
  15. class npc_gamble : public CreatureScript
  16. {
  17. public:
  18. npc_gamble() : CreatureScript("npc_gamble") { }
  19. bool OnGossipHello(Player* player, Creature* creature)
  20. {
  21. if (player->GetMoney() < GOLD_ONE)
  22. {
  23. player->GetSession()->SendNotification("You don't have enough gold!");
  24. return false;
  25. }
  26. player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, "I would like to gamble gold [1g]", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
  27. player->ADD_GOSSIP_ITEM(GOSSIP_ICON_DOT, "Nevermind", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2);
  28. return true;
  29. }
  30. bool OnGossipSelect(Player* player, Creature* creature, uint32 /*sender*/, uint32 actions)
  31. {
  32. player->PlayerTalkClass->ClearMenus();
  33. if (actions == GOSSIP_ACTION_INFO_DEF+1)
  34. {
  35. player->ModifyMoney(-GOLD_ONE);
  36. int32 moneyValue = 0;
  37. bool wonOrLost = false;
  38. switch(rand()%5)
  39. {
  40. case 0:
  41. moneyValue = GOLD_ONE;
  42. wonOrLost = false;
  43. break;
  44. case 1:
  45. moneyValue = GOLD_THREE;
  46. wonOrLost = false;
  47. break;
  48. case 2:
  49. moneyValue = GOLD_TEN;
  50. wonOrLost = true;
  51. break;
  52. case 3:
  53. moneyValue = GOLD_FIVE;
  54. wonOrLost = false;
  55. break;
  56. case 4:
  57. moneyValue = GOLD_ONE;
  58. wonOrLost = true;
  59. break;
  60. }
  61. if (wonOrLost)
  62. {
  63. player->ModifyMoney(moneyValue);
  64. ChatHandler(player->GetSession()).PSendSysMessage("You won!");
  65. }
  66. else
  67. {
  68. if (player->HasEnoughMoney(moneyValue))
  69. {
  70. player->ModifyMoney(-moneyValue);
  71. ChatHandler(player->GetSession()).PSendSysMessage("You lost %i gold!", moneyValue);
  72. }
  73. else
  74. ChatHandler(player->GetSession()).PSendSysMessage("You lost, but you don't have enough money to lose!");
  75. }
  76. player->CLOSE_GOSSIP_MENU();
  77. }
  78. else
  79. player->CLOSE_GOSSIP_MENU();
  80. return true;
  81. }
  82. };
  83. void AddSC_on_gamble()
  84. {
  85. new npc_gamble;
  86. }

EmuDevs - Gambler