Advertisement
Hirsw0w

Untitled

Nov 30th, 2014
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.50 KB | None | 0 0
  1. // This is a comment
  2. // uncomment the line below if you want to write a filterscript
  3. //#define FILTERSCRIPT
  4.  
  5. #include <a_samp>
  6.  
  7. #define MAX_NUMBER 50
  8.  
  9. #define SendClientMessage SCM
  10. #define SendClientMessageToAll SCMTA
  11.  
  12. #define LottoOff !LottoNumbers[0]
  13. #define LottoOn LottoNumbers[0]
  14.  
  15. new LottoNumbers[MAX_NUMBER+1];
  16.  
  17. new string[48];
  18.  
  19. new LottoPrize;
  20.  
  21. new LottoTimer;
  22.  
  23. public OnPlayerCommandText(playerid, cmdtext[])
  24. {
  25. new cmd[15],num,idx;
  26. cmd = strtok(cmdtext,idx);
  27. num = strval(strtok(cmdtext,idx));
  28. if (strcmp("/startlotto", cmd, true)) {
  29. if(LottoOn) return SCM(playerid,-1,"The lotto is active already");
  30. else if(!IsPlayerAdmin(playerid)) return SCM(playerid, -1,"you don't have rcon access");
  31. else if(num <= 0) return SCM(playerid,-1,"please write win prize ( /startlotto < prize > )");
  32. for(new i=1;i < 51;i++) LottoNumbers[i] = -1;
  33.  
  34. LottoNumbers[0] = 1;
  35. LottoPrize = num;
  36. SCMTA(-1,"lotto is active please register with the command : /lotto < number >");
  37. LottoTimer = SetTimer("EndLotto",30000,false);
  38. return 1;
  39. }
  40. else if(strcmp("/stoplotto", cmdtext,true)) {
  41. if(LottoOff) return SCM(playerid, -1,"The lotto is Off already");
  42. else if(!IsPlayerAdmin(playerid)) return SCM(playerid, -1,"you don't have rcon access");
  43.  
  44. LottoNumbers[0] = 0;
  45. KillTimer(LottoTimer);
  46. return SCMTA(-1,"The admin is stopped the lotto");
  47. }
  48. else if(strcmp("/lotto", cmd,true)) {
  49. if(LottoOff) return SCM(playerid, -1,"The lotto is Off already");
  50.  
  51. format(string,48,"/lotto < 1-%d >",MAX_NUMBER);
  52. if(num <= 1) return SCM(playerid,-1,string);
  53.  
  54. new lotto = GetPVarInt("lotto");
  55.  
  56. if(LottoNumbers[lotto] == playerid) return SCM(playerid,-1,"you already registered");
  57.  
  58. LottoNumbers[num] = playerid;
  59. SetPvarInt("lotto",num);
  60. return SCM(playerid,-1,"you registerd to the lotto");
  61. }
  62. return 0;
  63. }
  64.  
  65. forward EndLotto();
  66. public EndLotto() {
  67. new winner = random(50)+1;
  68.  
  69. GivePlayerMoney(LottoNumbers[winner],LottoPrize);
  70. LottoNumbers[0] = 0;
  71. return SCMTA("for the lotto has a winner... ");
  72. }
  73.  
  74. strtok(const string[], &index)
  75. {
  76. new length = strlen(string);
  77. while ((index < length) && (string[index] <= ' '))
  78. {
  79. index++;
  80. }
  81.  
  82. new offset = index;
  83. new result[20];
  84. while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
  85. {
  86. result[index - offset] = string[index];
  87. index++;
  88. }
  89. result[index - offset] = EOS;
  90. return result;
  91. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement