Top list stats [ REP + ]
#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


Messages In This Thread
Top list stats [ REP + ] - by _GHT_MarK445 - 12.03.2015, 08:48
Re: Top list stats [ REP + ] - by De4dpOol - 12.03.2015, 09:00
Re: Top list stats [ REP + ] - by _GHT_MarK445 - 12.03.2015, 09:19
AW: Top list stats [ REP + ] - by Kaliber - 12.03.2015, 09:35
Re: Top list stats [ REP + ] - by De4dpOol - 12.03.2015, 09:35
AW: Re: Top list stats [ REP + ] - by Kaliber - 12.03.2015, 09:37
Re: Top list stats [ REP + ] - by _GHT_MarK445 - 12.03.2015, 09:52
Re: Top list stats [ REP + ] - by Vince - 12.03.2015, 10:05
AW: Re: Top list stats [ REP + ] - by Kaliber - 12.03.2015, 10:09
Re: Top list stats [ REP + ] - by _GHT_MarK445 - 12.03.2015, 10:25

Forum Jump:


Users browsing this thread: 2 Guest(s)