12.03.2015, 09:35
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.
EDIT: Ooh! now I got it, my code will return the result from connected players only :P Thanks kaliber.