Guest User

Untitled

a guest
Feb 28th, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.47 KB | None | 0 0
  1. stock StartLottery(range_min, range_max, lot_number, lot_fee, const lot_prize[64 + 1])
  2. {
  3. if(lottoData[isActive])
  4. return 0;
  5.  
  6. lottoData[isActive] = true, lottoData[rangeMin] = range_min, lottoData[rangeMax] = range_max,
  7. lottoData[lottoNumber] = lot_number, lottoData[entryFee] = lot_fee;
  8. strcat((lottoData[winPrize] = '\0', lottoData[winPrize]), lot_prize, (64 + 1));
  9. SendClientMessageToAll(-1, "{4169e1}--------------------------------------------------[ LOTTERY ]--------------------------------------------------");
  10. new string[MAX_STRING];
  11. format(string, sizeof(string), "{b0c4de}Prize:{4169e1} %s", lottoData[winPrize]);
  12. SendClientMessageToAll(-1, string);
  13. format(string, sizeof(string), "{b0c4de}Ticket Price:{4169e1} $%s",
  14. number_format(lottoData[entryFee]));
  15. SendClientMessageToAll(-1, string);
  16. format(string, sizeof(string), "{b0c4de}Use{4169e1} /lot <%s-%s>{b0c4de} in order to get a chance to win.",
  17. number_format(lottoData[rangeMin]), number_format(lottoData[rangeMax]));
  18. SendClientMessageToAll(-1, string);
  19. SendClientMessageToAll(-1, "{4169e1}--------------------------------------------------[ LOTTERY ]--------------------------------------------------");
  20.  
  21. UpdateLotteryTextDraw();
  22. TextDrawShowForAll(lottoTD);
  23. return 1;
  24. }
  25.  
  26. stock StopLottery(playerid)
  27. {
  28. if(!lottoData[isActive])
  29. return 0;
  30.  
  31.  
  32. SendClientMessageToAll(-1, "{4169e1}--------------------------------------------------[ LOTTERY ]--------------------------------------------------");
  33.  
  34. new string[MAX_STRING];
  35. format(string, sizeof(string), "{4169e1}%s{b0c4de} has stopped the ongoing lottery. The winning ticket was {4169e1}#%s",
  36. RPName(playerid), number_format(lottoData[lottoNumber]));
  37. SendClientMessageToAll(-1, string);
  38.  
  39. SendClientMessageToAll(-1, "{4169e1}--------------------------------------------------[ LOTTERY ]--------------------------------------------------");
  40.  
  41. lottoData[isActive] = false, lottoData[rangeMin] = 0, lottoData[rangeMax] = 0,
  42. lottoData[lottoNumber] = 0, lottoData[lottoEntries] = 0, lottoData[entryFee] = 0, lottoData[winPrize] = '\0';
  43.  
  44. TextDrawHideForAll(lottoTD);
  45. return 1;
  46. }
  47. // --
  48.  
  49. // Lottery commands
  50. COMMAND:startlottery(playerid, params[])
  51. {
  52. if(GetAdminLevel(playerid) < 10)
  53. return SendClientError(playerid, CANT_USE_CMD);
  54.  
  55. new
  56. range_min,
  57. range_max,
  58. lot_number,
  59. lot_fee,
  60. lot_prize[64 + 1];
  61.  
  62. if(sscanf(params, "dddds[65]", range_min, range_max, lot_number, lot_fee, lot_prize)) return SCP(playerid, "[Minimum] [Maximum] [WinningTicket] [Fee] [Prize(64 characters)]");
  63. else
  64. StartLottery(range_min, range_max, lot_number, lot_fee, lot_prize);
  65.  
  66. if(range_min > range_max)
  67. return SendClientError(playerid, "Minimum range can't be higher than maximum range!");
  68. if(range_min > lot_number || lot_number > range_max)
  69. return SendClientError(playerid, "Lottery number can't be higher or lower than minimum or maximum range.");
  70. if(!StartLottery(range_min, range_max, lot_number, lot_fee, lot_prize))
  71. return SendClientError(playerid, "There is already an ongoing lottery!");
  72.  
  73.  
  74. return 1;
  75.  
  76.  
  77. }
Add Comment
Please, Sign In to add comment