Advertisement
CheezPuff

Top Killer Hud v1.1

Jun 17th, 2019
369
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.72 KB | None | 0 0
  1. /*
  2.     The plugin constantly displays text at the top of the screen with the nickname of the best player.
  3.     The best player is the one who has the most frags at the moment.
  4.  
  5.     [v1.1] - Shows only non-live players on the server.
  6. */
  7.  
  8. #include <amxmodx>
  9.  
  10. #define PLUGIN "Top Killer"
  11. #define VERSION "1.0.0"
  12. #define AUTHOR "CheezPuff"
  13.  
  14. new const colors[] = {50, 200, 0} // rgb colors
  15. new const Float:FR_TASK = 1.9 // alert frequency
  16.  
  17. public plugin_init()
  18. {
  19.     register_plugin(PLUGIN, VERSION, AUTHOR);
  20.    
  21.     set_task(FR_TASK - 0.1, "task_hud_info", 0, _, _, "b")
  22. }
  23.  
  24. public task_hud_info()
  25. {
  26.     static player, text_best_player[192], name[32]
  27.    
  28.     player = get_best_player_now()
  29.    
  30.     if(is_user_connected(player))
  31.     {
  32.         get_user_name(player, name, charsmax(name));
  33.         formatex(text_best_player, charsmax(text_best_player), "%s %s [%d KILLS]", "BEST PLAYER:", name, get_user_frags(player))
  34.        
  35.         set_hudmessage(colors[0], colors[1], colors[2], -1.0, 0.15, 0, 0.0, FR_TASK, 0.0, 0.10, -1)
  36.        
  37.         new count, players[32]
  38.         get_players(players, count, "bch")
  39.  
  40.         for(new i = 0; i < count; i++)  
  41.         {  
  42.             show_hudmessage(players[i], text_best_player)
  43.         }
  44.     }
  45. }
  46.  
  47. public get_best_player_now()
  48. {
  49.     new best_frags, the_best_player
  50.    
  51.     new count, players[32]
  52.     get_players(players, count, "h") // not hltv
  53.    
  54.     for(new i = 0; i < count; i++)  
  55.     {
  56.         new frags = get_user_frags(players[i])
  57.        
  58.         if(frags <= 0) continue;
  59.        
  60.         if(frags > best_frags)
  61.         {
  62.             best_frags = frags
  63.             the_best_player = players[i]
  64.         }
  65.         // P.S. - if a pair of players has the same number of frags, that player will be the best.
  66.         // whose id will be lower. Basically this is the player who previously connected to the server.
  67.     }  
  68.    
  69.     return the_best_player;
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement