Raised This Month: $32 Target: $400
 8% 

[REQUEST] TOP Players in HUD


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
jedyny
Member
Join Date: Aug 2016
Old 11-06-2019 , 18:34   [REQUEST] TOP Players in HUD
Reply With Quote #1

Hello,

I need a plugin that would show TOP 3 players with most kills in HUD using ShowHudText.

It would look like this:

Player1 Kills: 15
Player2 Kills: 12
Player2 Kills: 10

Thanks in advance!
jedyny is offline
Ilusion9
Veteran Member
Join Date: Jun 2018
Location: Romania
Old 11-07-2019 , 13:19   Re: [REQUEST] TOP Players in HUD
Reply With Quote #2

PHP Code:

#include <sourcemod>
#include <sdktools>
#include <cstrike>

#pragma newdecls required

int g_ClientKills[MAXPLAYERS 1];

public 
void OnPluginStart()
{
    
HookEvent("player_death"Event_PlayerDeath);
    
    
CreateTimer(1.0Timer_DisplayTopKills_TIMER_REPEAT);
}

public 
Action Timer_DisplayTopKills(any data)
{
    
DisplayTopKills();
}

public 
void OnClientConnected(int client)
{
    
g_ClientKills[client] = 0;
}

public 
void Event_PlayerDeath(Event event, const char[] namebool dontBroadcast)
{
    
int attacker GetClientOfUserId(event.GetInt("attacker"));
    
int client GetClientOfUserId(event.GetInt("userid"));

    if (
attacker && attacker != client)
    {
        
g_ClientKills[attacker]++;
        
DisplayTopKills();
    }
}

void DisplayTopKills()
{
    
int numclients[MAXPLAYERS 1];
    
    for (
int i 1<= MaxClientsi++)
    {
        if (
IsClientInGame(i))
        {
            
clients[num] = i;
            
num++;
        }
    }
    
    if (
num)
    {
        
SortCustom1D(clientsnumsortKills);
        
        
char buffer[256];
        
Format(buffersizeof(buffer), "1.%N - %d kills\n"clients[0], g_ClientKills[clients[0]]);
        
        if (
num 1)
        {
            
Format(buffersizeof(buffer), "%s2.%N - %d kills\n"bufferclients[1], g_ClientKills[clients[1]]);
        }
        
        if (
num 2)
        {
            
Format(buffersizeof(buffer), "%s3.%N - %d kills"bufferclients[2], g_ClientKills[clients[2]]);
        }
        
        
PrintHintTextToAll(buffer);
    }
}

int sortKills(int elem1int elem2, const int[] array, Handle hndl)
{
    if (
g_ClientKills[elem1] > g_ClientKills[elem2])
    {
        return -
1;
    }
    
    else if (
g_ClientKills[elem1] < g_ClientKills[elem2])
    {
        return 
1;
    }
    
    return 
0;

__________________

Last edited by Ilusion9; 11-08-2019 at 06:03.
Ilusion9 is offline
jedyny
Member
Join Date: Aug 2016
Old 11-07-2019 , 17:19   Re: [REQUEST] TOP Players in HUD
Reply With Quote #3

Works perfectly. Thank you!

Just one more thing - I would like to add player position so it would look like this:

1. Player1 Kills X
2. Player2 Kills X

How can I do that?
jedyny is offline
Ilusion9
Veteran Member
Join Date: Jun 2018
Location: Romania
Old 11-08-2019 , 05:59   Re: [REQUEST] TOP Players in HUD
Reply With Quote #4

Quote:
Originally Posted by jedyny View Post
Works perfectly. Thank you!

Just one more thing - I would like to add player position so it would look like this:

1. Player1 Kills X
2. Player2 Kills X

How can I do that?
Done, check my previous post again.
__________________
Ilusion9 is offline
jedyny
Member
Join Date: Aug 2016
Old 11-08-2019 , 10:52   Re: [REQUEST] TOP Players in HUD
Reply With Quote #5

Thank you
jedyny is offline
XHUNTERX
Senior Member
Join Date: Aug 2019
Location: World
Old 11-17-2019 , 22:02   Re: [REQUEST] TOP Players in HUD
Reply With Quote #6

Quote:
warning 203: symbol is never used: "hndl"
Quote:
warning 203: symbol is never used: "array"
help pls ?
XHUNTERX is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 02:49.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode