Raised This Month: $ Target: $400
 0% 

How to find out the first player in score tab?


Post New Thread Reply   
 
Thread Tools Display Modes
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 08-05-2018 , 16:35   Re: How to find out the first player in score tab?
Reply With Quote #11

The next step is using the SortCustom1D function.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
LemoNSK
Member
Join Date: Jul 2018
Location: Criminal Underworld
Old 08-06-2018 , 01:56   Re: How to find out the first player in score tab?
Reply With Quote #12

Quote:
Originally Posted by OciXCrom View Post
The next step is using the SortCustom1D function.
So I need an array to sort for the function - that will be players I think. And sort function, so am I supposed to do my own sort function? or what
LemoNSK is offline
Airkish
AlliedModders Donor
Join Date: Apr 2016
Location: Lithuania
Old 08-06-2018 , 02:57   Re: How to find out the first player in score tab?
Reply With Quote #13

Only for kills:

PHP Code:
GetTopKiller(iTeam// 1 : Terrorist - 2 : Counter-Terrorists
{
    new 
iPlayers[32], iPlayersnum;

    
get_players(iPlayersiPlayersnum"e"iTeam == "TERRORIST" "CT")
    
SortCustom1D(iPlayersiPlayersnum"SortByKills")

    return 
iPlayers[0]
}

public 
SortByKills(elem1elem2
{
    if ( 
g_iEnemiesKilled[elem1] > g_iEnemiesKilled[elem2] ) {
        return -
1;
    }
    else {
        return 
1;
    }

You need to track kills with deathmsg event.
You also should track deaths in case player's have same amount of kills and then sort by deaths.
Airkish is offline
shauli
Member
Join Date: Jun 2018
Old 08-06-2018 , 06:27   Re: How to find out the first player in score tab?
Reply With Quote #14

Quote:
Originally Posted by LemoNSK View Post
This is what I have.. Can't move from here.. So I have actually how many players there are on the server in each team, I thought of making some loop through them so I could find the players with most kills. But it makes no sense to me, there must be some command.
That's *exactly* what you should do. Make a for loop and find the player with the most frags.
There's no point in using sort if you only want to get one result/highest result. It's excessive.
shauli is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 08-06-2018 , 08:16   Re: How to find out the first player in score tab?
Reply With Quote #15

Quote:
Originally Posted by shauli View Post
That's *exactly* what you should do. Make a for loop and find the player with the most frags.
That's exactly what sorting means.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
shauli
Member
Join Date: Jun 2018
Old 08-06-2018 , 08:22   Re: How to find out the first player in score tab?
Reply With Quote #16

Quote:
Originally Posted by OciXCrom View Post
That's exactly what sorting means.
No. He should make a for loop and save in a variable the player with the most frags (index & value), not to sort the whole array. SortCustom1D will compare each entry with all of the other different entries, instead of just comparing the entry with the 'best' entry and continue to the next one if it's lower.

Last edited by shauli; 08-06-2018 at 08:22.
shauli is offline
LemoNSK
Member
Join Date: Jul 2018
Location: Criminal Underworld
Old 08-09-2018 , 03:13   Re: How to find out the first player in score tab?
Reply With Quote #17

Quote:
Originally Posted by Airkish View Post
Only for kills:

PHP Code:
GetTopKiller(iTeam// 1 : Terrorist - 2 : Counter-Terrorists
{
    new 
iPlayers[32], iPlayersnum;

    
get_players(iPlayersiPlayersnum"e"iTeam == "TERRORIST" "CT")
    
SortCustom1D(iPlayersiPlayersnum"SortByKills")

    return 
iPlayers[0]
}

public 
SortByKills(elem1elem2
{
    if ( 
g_iEnemiesKilled[elem1] > g_iEnemiesKilled[elem2] ) {
        return -
1;
    }
    else {
        return 
1;
    }

You need to track kills with deathmsg event.
You also should track deaths in case player's have same amount of kills and then sort by deaths.
Thank, I'm gonna try this.. Thank you all for learning me something new
LemoNSK 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 20:43.


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