Results 1 to 3 of 3

Thread: [cod2] Player scores

  1. #1
    Private
    Join Date
    Feb 2018
    Posts
    28
    Thanks
    12
    Thanked 17 Times in 16 Posts

    [cod2] Player scores

    Hello have problem with sorting player by kills and deahts

    Click image for larger version. 

Name:	Untitled.png 
Views:	14 
Size:	1.9 KB 
ID:	1601

    https://killtube.org/showthread.php?...est-player-map

    PHP Code:
    PlayerList(page)
    {
        if(
    page == 1)
        {

            
    self.playerlist_page 1;
            
    self.selected_player = -1;

            
    self.player_Stats_page_1 = [];
            
    self.player_Stats_page_1[0] = [];
            
    self.player_Stats_page_1[1] = [];
            
    self.player_Stats_page_1[2] = [];
            
    self.player_Stats_page_1[3] = [];
            
    self.player_Stats_page_1[4] = [];
            
    self.player_Stats_page_1[5] = [];
            
    self.player_Stats_page_1[6] = [];
            
    self.player_Stats_page_1[7] = [];
            
    self.player_Stats_page_1[8] = [];
            
    self.player_Stats_page_1[9] = [];
            
    self.player_Stats_page_1[10] = [];
            
    self.player_Stats_page_1[11] = [];
            
    self.player_Stats_page_1[12] = [];
            
    self.player_Stats_page_1[13] = [];
            
    self.player_Stats_page_1[15] = [];

            
    player_num 0;
            
    players getEntArray("player""classname");
            array = [];
            for (
    016i++)
            {
                
    player players];

                if (! 
    isDefined(player.pers["team"]) || player.pers["team"] == "spectator")
                    continue;

                if(
    == 17)
                    break;

                array[ array.
    size ] = players];
            }

            array = 
    sortPlayerList(array);


            for (
    0self.player_Stats_page_1.sizei++)
            {
                if (
    isDefined(array[ ])) {
                    
    self.player_Stats_page_1]["player"]    = array[ ];
                    
    self.player_Stats_page_1]["name"]        = array[ ].name;
                    
    self.player_Stats_page_1]["kills"]        = array[ ].score;
                    
    self.player_Stats_page_1]["deaths"]        = array[ ].deaths;
                }
            }
        }
        
    str_names "";
        
    str_kills "";
        
    str_deaths "";
        for (
    0self.player_Stats_page_1.sizei++)
        {
            if(
    isDefined(self.player_Stats_page_1]["name"])) {
                
    str_names str_names+""+self.player_Stats_page_1]["name"]+"\n";
                
    str_kills str_kills+""+self.player_Stats_page_1]["kills"]+"\n";
                
    str_deaths str_deaths+""+self.player_Stats_page_1]["deaths"]+"\n";
            }
        }
        
    self setclientcvar("s_players"str_names);
        
    self setclientcvar("s_players_k"str_kills);
        
    self setclientcvar("s_players_d"str_deaths);
    }

    sortPlayerList(array) 

        
    str = array; 
        for (
    0str.size 1i++) 
        { 
            for (
    1str.sizej++) 
            { 
                if (
    str].score str].score
                { 
                    var = 
    str]; 
                    
    str] = str]; 
                    
    str] = var; 
                } 
            } 
        } 

        return 
    str


  2. The Following User Says Thank You to buLLeT_ For This Useful Post:

    kung foo man (14th May 2019)

  3. #2
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,592
    Thanks
    17
    Thanked 937 Times in 583 Posts
    Try this (untested)

    PHP Code:
    sortPlayers(players)
    {
        
    newPlayers = [];
        for(
    0players.sizei++)
        {
            for(
    0newPlayers.sizej++)
            {
                if(
    newPlayers[j].score players[i].score || (newPlayers[j].score == players[i].score && newPlayers[j].deaths players[i].deaths))
                    break;
            }
            for(
    newPlayers.size>= jk--)
                
    newPlayers[k] = newPlayers[1];
            
    newPlayers[j] = players[i];
        }
        return 
    newPlayers;

    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

    Sending me a private message makes me want to help you LESS.

  4. The Following 2 Users Say Thank You to IzNoGoD For This Useful Post:

    buLLeT_ (14th May 2019),kung foo man (14th May 2019)

  5. #3
    Private
    Join Date
    Feb 2018
    Posts
    28
    Thanks
    12
    Thanked 17 Times in 16 Posts
    It works
    Thanks for help

  6. The Following User Says Thank You to buLLeT_ For This Useful Post:

    kung foo man (15th May 2019)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •