Top list stats [ REP + ] -
_GHT_MarK445 - 12.03.2015
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+.
Re: Top list stats [ REP + ] -
De4dpOol - 12.03.2015
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.
Re: Top list stats [ REP + ] -
_GHT_MarK445 - 12.03.2015
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.
AW: Top list stats [ REP + ] -
Kaliber - 12.03.2015
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
Re: Top list stats [ REP + ] -
De4dpOol - 12.03.2015
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.
AW: Re: Top list stats [ REP + ] -
Kaliber - 12.03.2015
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
Re: Top list stats [ REP + ] -
_GHT_MarK445 - 12.03.2015
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.
Re: Top list stats [ REP + ] -
Vince - 12.03.2015
You cannot do this with flat file systems. It's completely impractical.
AW: Re: Top list stats [ REP + ] -
Kaliber - 12.03.2015
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
Re: Top list stats [ REP + ] -
_GHT_MarK445 - 12.03.2015
Oh, so now i need to also learn mysql, oh gosh guys, do you think i am time machine?...