Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. #include <sourcemod>
  2. #include <cstrike>
  3.  
  4. g_playerKills[65] = { 0, ... };
  5.  
  6. public Plugin myinfo = {
  7. name = "Best Player",
  8. author = "adma",
  9. description = ".",
  10. version = "1.0",
  11. url = ""
  12. };
  13.  
  14. public void OnPluginStart() {
  15. HookEvent("player_death", player_death);
  16. HookEvent("round_end", round_end);
  17. }
  18.  
  19. public void OnClientDisconnect(int client) {
  20. g_playerKills[client] = 0;
  21. }
  22.  
  23. public void player_death(Event event, const char[] name, bool dontBroadcast) {
  24. int attacker = GetClientOfUserId(event.GetInt("attacker"));
  25. int client = GetClientOfUserId(event.GetInt("userid"));
  26. if (attacker <= 0 || attacker == client) return;
  27. g_playerKills[client]++;
  28. }
  29.  
  30. public void round_end(Event event, const char[] name, bool dontBroadcast) {
  31. int max = -1, bestPlayer = -1;
  32. for (int i = 1; i <= MaxClients; ++i) {
  33. if (!IsClientInGame(i)) return;
  34. int contributionScore = CS_GetClientContributionScore(i);
  35. if (contributionScore > max) {
  36. max = contributionScore;
  37. bestPlayer = i;
  38. }
  39. }
  40.  
  41. char bestMessage[64];
  42. if (bestPlayer != -1) Format(bestMessage, sizeof(bestMessage), "The best player was %N", bestPlayer);
  43.  
  44. for (int i = 1; i <= MaxClients; ++i) {
  45. if (IsClientInGame(i) && !IsFakeClient(i)) {
  46. int contributionScore = CS_GetClientContributionScore(i);
  47. SetHudTextParams(-1.0, -1.0, 5.0, 255, 255, 255, 255);
  48. ShowHudText(i, -1, "%s\nYou killed %i players\nYour score is %i", bestMessage, g_playerKills[i], contributionScore);
  49. }
  50.  
  51. g_playerKills[i] = 0;
  52. }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement