Top list stats [ REP + ]
#1

Hi guys,

i am just making my top list, which will be the list of players, which has the best stats of for example each category. This is example:

Most played time: player745 (525 hours)
Most wanted stars evaded: player444 (56 stars)
Most kills: player111 (200 kills)

I have my registration system done, i have my /stats command for every single player, to show his stats done, i just need a idea, how to make this one done.

Thanks guys, the one who will help me solve this problem, will earn REP+.
Reply
#2

pawn Код:
new toptime = 0;//creating a variable with 0 value
new topid = -1;//creating a variable with -1 value (as playerid can be 0 too so we are using -1)

for(new i=0; i < MAX_PLAYERS; i++)
{
    if(toptime < YourTimeStoringVariable[i])
    {
        toptime = YourTimeStoringVariable[i];
        topid = i;
    }
}
//the topid is the playerid with most time played (check if topid is not -1)
Here, untested.
Reply
#3

For what, we need to use "time" in top stats?

You just gave me code, for most played time. I want an tutorial, how to do it globally, for every single stat.
Reply
#4

For this you must use MySQL or SQLite

You must order the data in the query like this:

Код:
"SELECT `Name`,`time` FROM `player` ORDER BY `time` LIMIT 1"
Then you get the Name and the time from the player, who has the biggest value there

For more examples you can use ****** or try this page: http://www.w3schools.com/sql/sql_orderby.asp

Greekz
Reply
#5

pawn Код:
GetMostPlayedPlayer()
{
    new toptime = 0;//creating a variable with 0 value
    new topid = -1;//creating a variable with -1 value (as playerid can be 0 too so we are using -1)

    for(new i=0; i < MAX_PLAYERS; i++)//looping through all players
    {
        if(toptime < YourTimeStoringVariable[i])//comparing if player's time is more than toptime.
        {
            toptime = YourTimeStoringVariable[i];//if it is more set the toptime to the player's time so that in the next loop only players with more kills than already looped player will be counted.
            topid = i;//setting him the topid.
        }
    }
    return topid;//returning topid.
}
//the topid is the playerid with most time played.
I don't understnd what do you want but I explained it more. You can use it globally just replace YourTimeVariable with the variable in which player's time is stored. It will return -1 if no one found else it will return the playerid. You can use same code for detecting top killer, top scorer etc.

EDIT: Ooh! now I got it, my code will return the result from connected players only :P Thanks kaliber.
Reply
#6

Quote:
Originally Posted by De4dpOol
Посмотреть сообщение
[PAWN]I don't understnd what do you want but I explained it more. You can use it globally just replace YourTimeVariable with the variable in which player's time is stored. It will return -1 if no one found else it will return the playerid. You can use same code for detecting top killer, top scorer etc.
Dude, he want it from all players.

So if somebody who has the biggest value, is not connected then you're function giving a wrong result
Reply
#7

Quote:
Originally Posted by De4dpOol
Посмотреть сообщение
pawn Код:
GetMostPlayedPlayer()
{
    new toptime = 0;//creating a variable with 0 value
    new topid = -1;//creating a variable with -1 value (as playerid can be 0 too so we are using -1)

    for(new i=0; i < MAX_PLAYERS; i++)//looping through all players
    {
        if(toptime < YourTimeStoringVariable[i])//comparing if player's time is more than toptime.
        {
            toptime = YourTimeStoringVariable[i];//if it is more set the toptime to the player's time so that in the next loop only players with more kills than already looped player will be counted.
            topid = i;//setting him the topid.
        }
    }
    return topid;//returning topid.
}
//the topid is the playerid with most time played.
I don't understnd what do you want but I explained it more. You can use it globally just replace YourTimeVariable with the variable in which player's time is stored. It will return -1 if no one found else it will return the playerid. You can use same code for detecting top killer, top scorer etc.

EDIT: Ooh! now I got it, my code will return the result from connected players only :P Thanks kaliber.
Yes, but how about other stats? For example most killed players? You just showed me, the DONE example for time. But i dont wanted it like this, i wanted explanation for it, that i can make ALL stats showed in top.

Right now, i can just rewrite this script, and i wont understand anything, because it is specified on time, which has nothing to do, with for example "most killed players". So i need to get explained everything, that in the future, i can do it myself.


Kaliber: I dont have any webpage, to store this data in.
Reply
#8

You cannot do this with flat file systems. It's completely impractical.
Reply
#9

Quote:
Originally Posted by _GHT_MarK445
Посмотреть сообщение
Kaliber: I dont have any webpage, to store this data in.
You don't need any webpage..just a database


Quote:
Originally Posted by Vince
Посмотреть сообщение
You cannot do this with flat file systems. It's completely impractical.
Thats not true. For example with the file-plugin you can manage it

But it's very slow..so look at tutorials to save your data with MySQL
Reply
#10

Oh, so now i need to also learn mysql, oh gosh guys, do you think i am time machine?...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)