Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sourcemod>
- #include <cstrike>
- g_playerKills[65] = { 0, ... };
- public Plugin myinfo = {
- name = "Best Player",
- author = "adma",
- description = ".",
- version = "1.0",
- url = ""
- };
- public void OnPluginStart() {
- HookEvent("player_death", player_death);
- HookEvent("round_end", round_end);
- }
- public void OnClientDisconnect(int client) {
- g_playerKills[client] = 0;
- }
- public void player_death(Event event, const char[] name, bool dontBroadcast) {
- int attacker = GetClientOfUserId(event.GetInt("attacker"));
- int client = GetClientOfUserId(event.GetInt("userid"));
- if (attacker <= 0 || attacker == client) return;
- g_playerKills[client]++;
- }
- public void round_end(Event event, const char[] name, bool dontBroadcast) {
- int max = -1, bestPlayer = -1;
- for (int i = 1; i <= MaxClients; ++i) {
- if (!IsClientInGame(i)) return;
- int contributionScore = CS_GetClientContributionScore(i);
- if (contributionScore > max) {
- max = contributionScore;
- bestPlayer = i;
- }
- }
- char bestMessage[64];
- if (bestPlayer != -1) Format(bestMessage, sizeof(bestMessage), "The best player was %N", bestPlayer);
- for (int i = 1; i <= MaxClients; ++i) {
- if (IsClientInGame(i) && !IsFakeClient(i)) {
- int contributionScore = CS_GetClientContributionScore(i);
- SetHudTextParams(-1.0, -1.0, 5.0, 255, 255, 255, 255);
- ShowHudText(i, -1, "%s\nYou killed %i players\nYour score is %i", bestMessage, g_playerKills[i], contributionScore);
- }
- g_playerKills[i] = 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement