[HELP]List top
#1

i have problem with top list when someone type /toplist there is just his name but he is not richest or best score! every player have same only his name!

Код:
CMD:toplist(playerid, params[])
{
	new string6[199];
	new string7[199];
	new string8[299];
	new string9[700];
    new name[MAX_PLAYER_NAME], player1, h, m, s;
    GetPlayerName(playerid, name, sizeof(name));
    TotalGameTime(playerid, h, m, s);
	format(string6, sizeof(string6), "{00c0ff}_______________________________________________________");
	format(string7, sizeof(string7), "{b5b6b5}Most Active player |{FFFFFF} %s | TimePlayed: [%d] hrs [%d] mins [%d]\n\n{b5b6b5}Most Rich player |{FFFFFF} %s | Cash: $%d",name, h, m, s, name, GetPlayerMoney(player1));
	format(string8, sizeof(string8), "{b5b6b5}Player with most Kills |{FFFFFF} %s | Kills: %d\n\n{b5b6b5}Player with most Score |{FFFFFF} %s | Score: %d",name, Float:PlayerInfo[player1][Kills], name, GetPlayerScore(player1));
	format(string9, sizeof(string9), "%s\n\n\n%s\n\n%s\n%s",string6, string7, string8);
	ShowPlayerDialog(playerid, 1, DIALOG_STYLE_MSGBOX, "{F81414}[RF]{FFFFFF}Top List", string9, "Close", "");
	return 1;
}
Reply
#2

BUMP!
Reply
#3

When you use playerid in your command, that will refer to the player that typed the command. So if player 4 uses /toplist, GetPlayerName(playerid, name, sizeof(name)); is getting the name of player 4. If you want the name of the "Most active player", "Player with most kills", ... you need to store these players somewhere.

Say you want to know the player with the most kills:
Код:
//Top of script
new PlayerKills[MAX_PLAYERS];

//OnPlayerDeath
PlayerKills[killerid]++;

//Toplist command
new MostKills = 0; //This is the largest number of kills
new PlayerMostKills = INVALID_PLAYER_ID; //This is the playerid that has the most kills
for(new otherplayerid = 0; otherplayerid < sizeof(PlayerKills); otherplayerid ++) {
    if(PlayerKills[otherplayerid] > MostKills) {
        MostKills = PlayerKills[otherplayerid];
        PlayerMostKills = otherplayerid;
    }
}
GetPlayerName(PlayerMostKills, name, sizeof(name)); //This is the name of the player with the most kills
This example shows only how to get the player with the most kills. Try to figure out the other things a player can be "best" at, with a similar approach.
Reply
#4

OK thanks but how do i insert this on /toplist cmd ?

this
Quote:

//Toplist command
new MostKills = 0; //This is the largest number of kills
new PlayerMostKills = INVALID_PLAYER_ID; //This is the playerid that has the most kills
for(new otherplayerid = 0; otherplayerid < sizeof(PlayerKills); otherplayerid ++) {
if(PlayerKills[otherplayerid] > MostKills) {
MostKills = PlayerKills[otherplayerid];
PlayerMostKills = otherplayerid;
}
}
GetPlayerName(PlayerMostKills, name, sizeof(name)); //This is the name of the player with the most kills

Reply
#5

What do you, mean? That is literally the code to get the player's name with the most kills.
name is the name of the player with the most kills. Use that variable in the format function like this:
Код:
format(string, sizeof(string), "Player with most kills: %s | Kills: %d", name, MostKills);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)