orayon

Random winner

Jun 5th, 2020
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 0.93 KB | None | 0 0
  1. #include <amxmodx>
  2.  
  3. #define ADMIN_FLAG ADMIN_SLAY
  4.  
  5. native set_user_cash(id, amount)
  6. native get_user_cash(id)
  7.  
  8. new Prefix[] = "^3[^1Prefix^3]^1"
  9.  
  10. public plugin_init() register_clcmd("say /random", "cmdrandomwinner")
  11.  
  12. public cmdrandomwinner(id)
  13. {
  14.     if (!(get_user_flags(id) & ADMIN_FLAG))
  15.         return client_print(id, print_chat, "%s You have no access to that command!", Prefix)
  16.    
  17.     new Amount = random_num(1, 30000)
  18.     new winner = get_player()
  19.    
  20.     set_hudmessage(0, 212, 255, -1.0, 0.19, 0, 6.0, 12.0)
  21.     show_hudmessage(0, "Random winner has started.^nThe winner is %s^nAnd he won %i", GetName(winner), Amount)
  22.    
  23.     set_user_cash(winner, get_user_cash(winner) + Amount)
  24.    
  25.     return 1;
  26. }
  27.  
  28. stock get_player()
  29. {
  30.     new players[ 32 ], num;
  31.    
  32.     get_players( players, num, "ch" );
  33.    
  34.     return players[ random( num ) ];
  35. }
  36.  
  37. stock GetName( id )
  38. {
  39.     static szName[ 32 ];
  40.    
  41.     get_user_name( id, szName, charsmax( szName ) );
  42.    
  43.     return szName;
  44. }
Add Comment
Please, Sign In to add comment