Advertisement
Guest User

gamble

a guest
Aug 8th, 2012
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.93 KB | None | 0 0
  1. /*
  2. * WRITTEN BY BLUECRACK FROM HUNGARY!! (aka Bluerak)
  3. * This Program is FREE; So if you have this script, you didn't pay for it.
  4. * Thank you for using my scripts, do not forget to vote me and choose me for president.
  5. * Email: bluecrack@indamail.hu (Send me an email if you have some problems, or if you wanna talk with me)
  6. * All Rights Reserved.
  7. */
  8.  
  9. /*
  10. SDName: npc_gamble
  11. SDCategory: Maybe fun? or wtf
  12. SDComplete: Ofcourse 100%
  13. SDComment: Star Wars the best movie what i've ever seen...
  14. Special Thanks: George Lucas
  15. */
  16.  
  17. // How 2 set the chance:
  18. // if (roll >= 70) -- In this case the 70 is a percent number. Change it up if you want bigger chances and down to get lower chances.
  19.  
  20. /* The Holy Changelog:
  21. v 1.0 - The script is done so far
  22. v 1.1 - new uint32 givenmoney
  23. v 1.2 - The script is done
  24. v 1.3 - Fixed TYPOS
  25. */
  26.  
  27. class npc_gamble : public CreatureScript
  28. {
  29.     public:
  30.  
  31.         npc_gamble()
  32.             : CreatureScript("npc_gamble")
  33.         {
  34.         }
  35.        
  36.         uint32 roll;
  37.         uint32 givenmoney;
  38.  
  39.         bool OnGossipHello(Player * player, Creature * pCreature)
  40.         {
  41.             player->ADD_GOSSIP_ITEM(0, "ROLL THE DICE!", GOSSIP_SENDER_MAIN, 1);
  42.             return true;
  43.         }
  44.  
  45.         bool OnGossipSelect(Player* pPlayer, Creature* pCreature, uint32 /*uiSender*/, uint32 uiAction)
  46.         {
  47.             pPlayer->PlayerTalkClass->ClearMenus();
  48.  
  49.             switch (uiAction)
  50.             {
  51.             case 1:
  52.                 pPlayer->ADD_GOSSIP_ITEM(0, "Bet 10 gold(I don't want to lose so much)", GOSSIP_SENDER_MAIN, 100);
  53.                 pPlayer->ADD_GOSSIP_ITEM(0, "Bet 50 gold(I wanna win something)", GOSSIP_SENDER_MAIN, 200);
  54.                 pPlayer->ADD_GOSSIP_ITEM(0, "Bet 100 gold(I think I'm lucky!)", GOSSIP_SENDER_MAIN, 300);
  55.                 pPlayer->ADD_GOSSIP_ITEM(0, "Bet 500 gold(Let's play harder!)", GOSSIP_SENDER_MAIN, 400);
  56.                 pPlayer->ADD_GOSSIP_ITEM(0, "Bet 1000 gold(I'm ready to lose much! My men will pay back their loan soon!)", GOSSIP_SENDER_MAIN, 500);
  57.  
  58.  
  59.             case 100:
  60.                 /** 10 Gold Part **/
  61.                 if(pPlayer->GetMoney() >= 100000) // Maybe 10 gold but I'm not sure.
  62.                 {
  63.                     pCreature->MonsterWhisper("You can bet 10 gold, you have enough money", pPlayer->GetGUID(), false);
  64.                     pPlayer->ModifyMoney(-100000); // Deletes the money from the player
  65.                    
  66.                     givenmoney = 100000;
  67.                 roll = urand (1, 100); // Selects a random number between 1 and 100
  68.                 if (roll >= 70) // IF the roll is 70 or bigger the player gets his money
  69.                 {
  70.                     pPlayer->ModifyMoney(givenmoney * 2);
  71.                     pCreature->MonsterWhisper("Congrats You won!", pPlayer->GetGUID(), false);
  72.                 } else
  73.                     pCreature->MonsterWhisper("You failed!", pPlayer->GetGUID(), false);
  74.                 }
  75.                 /** 10 Gold Part ends **/
  76.  
  77.                             case 200:
  78.                 /** 50 Gold Part **/
  79.                 if(pPlayer->GetMoney() >= 500000) // Maybe 10 gold but I'm not sure.
  80.                 {
  81.                     pCreature->MonsterWhisper("You can bet 50 gold, you have enough money", pPlayer->GetGUID(), false);
  82.                     pPlayer->ModifyMoney(-500000); // Deletes the money from the player
  83.                             pCreature->MonsterTextEmote("The Dice is rolling... Get Ready!", 0, 0);
  84.                     givenmoney = 500000;
  85.                 roll = urand (1, 100); // Selects a random number between 1 and 100
  86.                 if (roll >= 70) // IF the roll is 70 or bigger the player gets his money
  87.                 {
  88.                     pPlayer->ModifyMoney(givenmoney * 2);
  89.                     pCreature->MonsterWhisper("Congrats You won!", pPlayer->GetGUID(), false);
  90.                 } else
  91.                     pCreature->MonsterWhisper("You failed!", pPlayer->GetGUID(), false);
  92.                 }
  93.                 /** 50 Gold Part ends **/
  94.  
  95.                             case 300:
  96.                 /** 100 Gold Part **/
  97.                 if(pPlayer->GetMoney() >= 1000000) // Maybe 10 gold but I'm not sure.
  98.                 {
  99.                     pCreature->MonsterWhisper("You can bet 100 gold, you have enough money", pPlayer->GetGUID(), false);
  100.                     pPlayer->ModifyMoney(-1000000); // Deletes the money from the player
  101.                             pCreature->MonsterTextEmote("The Dice is rolling... Get Ready!", 0, 0);
  102.                     givenmoney = 1000000;
  103.                 roll = urand (1, 100); // Selects a random number between 1 and 100
  104.                 if (roll >= 70) // IF the roll is 70 or bigger the player gets his money
  105.                 {
  106.                     pPlayer->ModifyMoney(givenmoney * 2);
  107.                     pCreature->MonsterWhisper("Congrats You won!", pPlayer->GetGUID(), false);
  108.                 } else
  109.                     pCreature->MonsterWhisper("You failed!", pPlayer->GetGUID(), false);
  110.                 }
  111.                 /** 100 Gold Part ends **/
  112.  
  113.                             case 400:
  114.                 /** 500 Gold Part **/
  115.                 if(pPlayer->GetMoney() >= 5000000) // Maybe 10 gold but I'm not sure.
  116.                 {
  117.                     pCreature->MonsterWhisper("You can bet 500 gold, you have enough money", pPlayer->GetGUID(), false);
  118.                     pPlayer->ModifyMoney(-5000000); // Deletes the money from the player
  119.                             pCreature->MonsterTextEmote("The Dice is rolling... Get Ready!", 0, 0);
  120.                     givenmoney = 5000000;
  121.                 roll = urand (1, 100); // Selects a random number between 1 and 100
  122.                 if (roll >= 70) // IF the roll is 70 or bigger the player gets his money
  123.                 {
  124.                     pPlayer->ModifyMoney(givenmoney * 2);
  125.                     pCreature->MonsterWhisper("Congrats You won!", pPlayer->GetGUID(), false);
  126.                 } else
  127.                     pCreature->MonsterWhisper("You failed!", pPlayer->GetGUID(), false);
  128.                 }
  129.                 /** 500 Gold Part ends **/
  130.  
  131.                             case 500:
  132.                 /** 1000 Gold Part **/
  133.                 if(pPlayer->GetMoney() >= 10000000) // Maybe 10 gold but I'm not sure.
  134.                 {
  135.                     pCreature->MonsterWhisper("You can bet 1000 gold, you have enough money", pPlayer->GetGUID(), false);
  136.                     pPlayer->ModifyMoney(-10000000); // Deletes the money from the player
  137.                             pCreature->MonsterTextEmote("The Dice is rolling... Get Ready!", 0, 0);
  138.                     givenmoney = 10000000;
  139.                 roll = urand (1, 100); // Selects a random number between 1 and 100
  140.                 if (roll >= 70) // IF the roll is 70 or bigger the player gets his money
  141.                 {
  142.                     pPlayer->ModifyMoney(givenmoney * 2);
  143.                     pCreature->MonsterWhisper("Congrats You won!", pPlayer->GetGUID(), false);
  144.                 } else
  145.                     pCreature->MonsterWhisper("You failed!", pPlayer->GetGUID(), false);
  146.                 }
  147.                 /** 1000 Gold Part ends **/
  148.  
  149.  
  150.  
  151.             }
  152.             return true;
  153.         }
  154. };
  155.  
  156.    
  157. void AddSC_npc_gamble()
  158. {
  159.     new npc_gamble();
  160. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement