Top Score is bug -
JaKe Elite - 24.08.2012
Hello,
i have problem with Top Score.
It mess up when the player reach to 5 players.
Note: This is edited version of RyDer's Top Score
pawn Код:
CMD:topscore(playerid, params[])
{
new
playerScores[MAX_PLAYERS][rankingEnum],
index,
str[256] = "Awesome™ GamerX© (0.3e) - Unlimited Stuntings Top 5 Score",
player_Name[20]
;
foreach(Player, i)
{
if(IsPlayerConnected(i) && !IsPlayerNPC(i))
{
playerScores[index][player_Score] = GetPlayerScore(i);
playerScores[index++][player_ID] = i;
}
}
GetPlayerHighestScores(playerScores, 0, index);
foreach(Player, i)
{
if(i < index)
{
GetPlayerName(playerScores[i][player_ID], player_Name, sizeof(player_Name));
format(str, sizeof(str), ""white"%s\n%d. %s - "yellow"%d"white"", str, i + 1, player_Name, playerScores[i][player_Score]);
}
else
format(str, sizeof(str), ""white"%s\n%d. "red"N/A"white"", str, i + 1);
}
SendClientMessage(playerid, COLOR_YELLOW, "*** Awesome™ GamerX© (0.3e) - Unlimited Stuntings - Top 5 Scores ***");
ShowPlayerDialog(playerid, TOP5SCORE, DIALOG_STYLE_MSGBOX, "[AGX] Top 5 Score:", str, "OK", "");
return 1;
}
GetPlayerHighestScores(array[][rankingEnum], left, right)
{
new
tempLeft = left,
tempRight = right,
pivot = array[(left + right) / 2][player_Score],
tempVar
;
while(tempLeft <= tempRight)
{
while(array[tempLeft][player_Score] > pivot) tempLeft++;
while(array[tempRight][player_Score] < pivot) tempRight--;
if(tempLeft <= tempRight)
{
tempVar = array[tempLeft][player_Score], array[tempLeft][player_Score] = array[tempRight][player_Score], array[tempRight][player_Score] = tempVar;
tempVar = array[tempLeft][player_ID], array[tempLeft][player_ID] = array[tempRight][player_ID], array[tempRight][player_ID] = tempVar;
tempLeft++, tempRight--;
}
}
if(left < tempRight) GetPlayerHighestScores(array, left, tempRight);
if(tempLeft < right) GetPlayerHighestScores(array, tempLeft, right);
}
Re: Top Score is bug -
JaKe Elite - 24.08.2012
Bump
Re: Top Score is bug -
Riddick94 - 24.08.2012
Bump can be only after 24hours.. by the way you said that in the other topic.
Check this.. i'm not sure.
pawn Код:
CMD:topscore(playerid, params[])
{
new
playerScores[MAX_PLAYERS][rankingEnum],
index = 0,
str[256] = "Awesome™ GamerX© (0.3e) - Unlimited Stuntings Top 5 Score",
player_Name[MAX_PLAYER_NAME]
;
foreach(Player, i)
{
playerScores[index][player_Score] = GetPlayerScore(i);
playerScores[index++][player_ID] = i;
GetPlayerHighestScores(playerScores, 0, index);
if(i < index)
{
GetPlayerName(playerScores[i][player_ID], player_Name, sizeof(player_Name));
format(str, sizeof(str), ""white"%s\n%d. %s - "yellow"%d"white"", str, i + 1, player_Name, playerScores[i][player_Score]);
}
else
{
format(str, sizeof(str), ""white"%s\n%d. "red"N/A"white"", str, i + 1);
}
}
SendClientMessage(playerid, COLOR_YELLOW, "*** Awesome™ GamerX© (0.3e) - Unlimited Stuntings - Top 5 Scores ***");
ShowPlayerDialog(playerid, TOP5SCORE, DIALOG_STYLE_MSGBOX, "[AGX] Top 5 Score:", str, "OK", "");
return 1;
}
GetPlayerHighestScores(array[][rankingEnum], left, right)
{
new
tempLeft = left,
tempRight = right,
pivot = array[(left + right) / 2][player_Score],
tempVar
;
while(tempLeft <= tempRight)
{
while(array[tempLeft][player_Score] > pivot) tempLeft++;
while(array[tempRight][player_Score] < pivot) tempRight--;
if(tempLeft <= tempRight)
{
tempVar = array[tempLeft][player_Score], array[tempLeft][player_Score] = array[tempRight][player_Score], array[tempRight][player_Score] = tempVar;
tempVar = array[tempLeft][player_ID], array[tempLeft][player_ID] = array[tempRight][player_ID], array[tempRight][player_ID] = tempVar;
tempLeft++, tempRight--;
}
}
if(left < tempRight) GetPlayerHighestScores(array, left, tempRight);
if(tempLeft < right) GetPlayerHighestScores(array, tempLeft, right);
}
You don't need to check NPC and if IsPlayerConnected because foreach doing it for you. And why are you using two loops when you can use only one?
Re: Top Score is bug -
JaKe Elite - 24.08.2012
Now when i /topscore.
it only show the rank 2.
display as
Re: Top Score is bug -
Riddick94 - 24.08.2012
pawn Код:
CMD:topscore(playerid, params[])
{
new
playerScores[MAX_PLAYERS][rankingEnum], count = 0, str[128], string[128],
player_Name[MAX_PLAYER_NAME]
;
foreach(Player, i)
{
playerScores[i][player_Score] = GetPlayerScore(i);
playerScores[i][player_ID] = i;
GetPlayerHighestScores(playerScores, 0, count);
count += 1;
if(i < count)
{
GetPlayerName(playerScores[i][player_ID], player_Name, sizeof(player_Name));
format(str, sizeof(str), ""white"%s\n%d. %s - "yellow"%d"white"", str, i + 1, player_Name, playerScores[i][player_Score]);
SendClientMessage(playerid, COLOR_YELLOW, "*** Awesome™ GamerX© (0.3e) - Unlimited Stuntings - Top 5 Scores ***");
format(string, sizeof(string), "%s", str);
ShowPlayerDialog(playerid, TOP5SCORE, DIALOG_STYLE_MSGBOX, "[AGX] Top 5 Score:", string, "OK", "");
}
else
{
format(str, sizeof(str), ""white"%s\n%d. "red"N/A"white"", str, i + 1);
}
}
return 1;
}
Re: Top Score is bug -
JaKe Elite - 24.08.2012
The dialog don't show up.
Re: Top Score is bug -
Riddick94 - 24.08.2012
Maybe because there's no players with this Top 5 rank? I don't know then..
Re: Top Score is bug -
JaKe Elite - 24.08.2012
I think you mess up something there.