pawn Код:
new TopFive[MAX_PLAYER_NAME*5]; // lol this has no sence but well, I'll fix it myself later.
Is meant to be
pawn Код:
new TopFive[5][MAX_PLAYER_NAME];
For this, I'm going to make it into a variable for better use of space.
pawn Код:
stock GetHighestPoints
{
new HighestValue[5];//Makes the highest players varibale...
for(new i=0;i<MAX_PLAYERS();i++) //Goes through the 500 players in the variable
{
if(pInfo[i][points] > Variable[HighestValue[0]])
{
HighestValue[0] = i;
}
if(pInfo[i][points] > pInfo[HighestValue[1]][points] && HighestValue[0] != i)
{
HighestValue[1] = i;
}
if(pInfo[i][points] > pInfo[HighestValue[2]][points] && HighestValue[0] != i && HighestValue[1] != i)
{
HighestValue[2] = i;
}
if(pInfo[i][points] > pInfo[HighestValue[3]][points] && HighestValue[0] != i && HighestValue[1] != i && HighestValue[2] != i)
{
HighestValue[3] = i;
}
if(pInfo[i][points] > pInfo[HighestValue[4]][points] && HighestValue[0] != i && HighestValue[1] != i && HighestValue[2] != i && HighestValue[3] != i)
{
HighestValue[4] = i;
}
}
TopFive[0] = HighestValue[0];
TopFive[1] = HighestValue[1];
TopFive[2] = HighestValue[2];
TopFive[3] = HighestValue[3];
TopFive[4] = HighestValue[4];
}
This function returns the top 5 playerids, I'll show you the usage of this:
pawn Код:
new string[126], Pname[5][MAX_PLAYER_NAME];
GetPlayerName(TopFive[0], Pname[0], 24);
GetPlayerName(TopFive[1], Pname[1], 24);
GetPlayerName(TopFive[2], Pname[2], 24);
GetPlayerName(TopFive[3], Pname[3], 24);
GetPlayerName(TopFive[4], Pname[4], 24);
format(string, sizeof(string), "Top 5: 1.%s(%d), 2.%s(%d), 3.%s(%d), 4.%s(%d), 5.%s(%d)", Pname[0], TopFive[0], Pname[1], TopFive[1], Pname[2], TopFive[2], Pname[3], TopFive[3], Pname[4], TopFive[4]);
SendClientMessage(playerid, COLOR, string);
So in your case:
pawn Код:
new Pos[MAX_PLAYERS]; // let's guess I make a new variable for storing the result of the thing that get the position
public OnPlayerWinEvent(playerid)
{
GetHighestPoints
new string[126], Pname[5][MAX_PLAYER_NAME];
GetPlayerName(TopFive[0], Pname[0], 24);
GetPlayerName(TopFive[1], Pname[1], 24);
GetPlayerName(TopFive[2], Pname[2], 24);
GetPlayerName(TopFive[3], Pname[3], 24);
GetPlayerName(TopFive[4], Pname[4], 24);
format(string, sizeof(string), "Top 5: 1.%s(%d), 2.%s(%d), 3.%s(%d), 4.%s(%d), 5.%s(%d)" Pname[0], TopFive[0], Pname[1], TopFive[1], Pname[2], TopFive[2], Pname[3], TopFive[3], Pname[4], TopFive[4]);
SendClientMessage(playerid, COLOR, string);
PlayerInfo[playerid][points] ++;
format(string, sizeof(string), "You have won this event! now your at the position %d.", Pos[playerid]); //how to get his/her pos?
SendClientMessage(playerid, COLOR, string);
return 1;
}