Advertisement
Guest User

Untitled

a guest
Dec 8th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.57 KB | None | 0 0
  1. #include <amxmodx>
  2.  
  3. #define CommunityName "Units-JUMP"
  4. #define ACCESS ADMIN_IMMUNITY
  5. #define AUTOTIME 300
  6. #define TopPlayers 3
  7.  
  8. native get_user_cash(index);
  9. native set_user_cash(index, amount);
  10.  
  11. new Timer, bool:bRandomStarted = false, Auto = AUTOTIME;
  12.  
  13. public plugin_init() {
  14. register_plugin("Random Cash", "v1.3", "koko&Edgeee")
  15.  
  16. register_clcmd("say /random", "RandomCash");
  17. register_clcmd("say /next", "NextRandom");
  18. register_clcmd("say /nextrandom", "NextRandom");
  19. set_task(1.0, "AutoRandom", 0,_,_, "b");
  20. set_task(220.0, "Knowing", 0,_,_, "b");
  21. }
  22.  
  23. public RandomCash(id)
  24. {
  25. if(!(get_user_flags(id) & ACCESS))
  26. return ColorChat(id, "^1You have ^4no access ^1to this command.");
  27. if(bRandomStarted)
  28. return ColorChat(id, "^1The random cash ^4is already ^1staretd.");
  29.  
  30. bRandomStarted = true;
  31.  
  32. Timer = 6;
  33. ColorChat(0, "^1%s ^4just started ^1the ^4random cash^1.", GetName(id));
  34.  
  35. set_task(1.0, "StartRandomCash", 0,_,_, "b");
  36.  
  37. return 1;
  38. }
  39.  
  40. public StartRandomCash()
  41. {
  42. Timer--;
  43. if(Timer > 0)
  44. {
  45. set_hudmessage(random_num(1, 255), random_num(1, 255), random_num(1, 255), 0.39, 0.21, 0, 6.0, 1.0)
  46. show_hudmessage(0, " Random Cash^nTime Left: %i seconds.", Timer)
  47.  
  48. new Spk[10];
  49. num_to_word(Timer, Spk, charsmax(Spk));
  50. client_cmd(0, "spk vox/%s", Spk);
  51. }
  52. else
  53. {
  54. new Winner = get_randomplayer();
  55. new RandomAmount = random_num(1, 5800);
  56.  
  57. set_user_cash(Winner, get_user_cash(Winner) + RandomAmount);
  58.  
  59. set_hudmessage(random_num(1, 255), random_num(1, 255), random_num(1, 255), 0.39, 0.21, 0, 6.0, 10.0)
  60. show_hudmessage(0, " Winner: %s!^nHe just won: %i cash!", GetName(Winner), RandomAmount)
  61.  
  62. ColorChat(0, "^1The Winner is ^4%s^1, and he won^4 %i cash^1. ", GetName(Winner), RandomAmount);
  63.  
  64. bRandomStarted = false;
  65.  
  66. remove_task(0);
  67.  
  68. Auto = AUTOTIME;
  69. set_task(1.0, "AutoRandom", 0,_,_, "b");
  70. }
  71. }
  72.  
  73. public AutoRandom()
  74. {
  75. new players[32], pnum;
  76. get_players(players, pnum, "ch");
  77.  
  78. if(pnum <= TopPlayers)
  79. return 1;
  80. Auto--;
  81. if(Auto == 0)
  82. {
  83. bRandomStarted = true;
  84.  
  85. Timer = 6;
  86. ColorChat(0, "^1The ^4random cash ^1has started.");
  87.  
  88. set_task(1.0, "StartRandomCash", 0,_,_, "b");
  89. }
  90. return 1;
  91. }
  92.  
  93. public NextRandom(id) {
  94. new players[32], pnum;
  95. get_players(players, pnum, "ch");
  96.  
  97. if(pnum <= TopPlayers)
  98. return ColorChat(id, "^1The ^4random cash ^1start when there is ^4more then %i ^1players.", TopPlayers);
  99. if(bRandomStarted)
  100. return ColorChat(id, "^1The ^4random cash ^1already started.");
  101. ColorChat(id, "^1The ^4random cash ^1will start in:^4 %i seconds^1.", Auto);
  102. return 0;
  103. }
  104.  
  105. public Knowing()
  106. ColorChat(0, "^1To see when the ^4next random cash ^1start, type ^4/next^1.");
  107.  
  108. stock get_randomplayer()
  109. {
  110. static players[32], pnum;
  111. get_players(players, pnum, "ch");
  112.  
  113. return players[random(pnum)];
  114. }
  115.  
  116. stock GetName(id)
  117. {
  118. static szName[33];
  119. get_user_name(id, szName, charsmax(szName));
  120. return szName;
  121. }
  122.  
  123. stock ColorChat(const id, const string[], {Float, Sql, Resul,_}:...) {
  124. new msg[191], players[32], count = 1
  125.  
  126. new Community[30];
  127. formatex(Community, charsmax(Community), "^3[%s] ", CommunityName);
  128.  
  129. static len
  130. len = formatex(msg, charsmax(msg), Community)
  131. vformat(msg[len], charsmax(msg) - len, string, 3)
  132.  
  133. if(id) players[0] = id
  134. else get_players(players,count,"ch")
  135.  
  136. for (new i = 0; i < count; i++)
  137. {
  138. if(is_user_connected(players[i]))
  139. {
  140. message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"),_, players[i])
  141. write_byte(players[i])
  142. write_string(msg)
  143. message_end()
  144. }
  145. }
  146. return 1;
  147. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement