13.08.2013, 14:20
Hello
I have a Top 5 player System,
It seems to work fine but as soon as someone /q's while they are on the list.
Their name goes to N/A and the score stays as it is when they /q.
Hopefully you guys can help me solve it:
I have a Top 5 player System,
It seems to work fine but as soon as someone /q's while they are on the list.
Their name goes to N/A and the score stays as it is when they /q.
Hopefully you guys can help me solve it:
pawn Код:
stock 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);
}
public Top5Update()
{
new
playerScores[MAX_PLAYERS][rankingEnum],
index
;
for(new i; i != MAX_PLAYERS; ++i)
{
if(Player[i][IsActive] == 1)
{
playerScores[index][player_Score] = Player[i][AliveTime];
playerScores[index][player_ID] = i;
index++;
GetPlayerHighestScores(playerScores, 0, index);
new score_Text[256] = "~n~";
for(new id; id < 5; ++id)
{
if(id < index)
{
format(score_Text, sizeof(score_Text), "%s~n~~b~%d. ~w~%s - ~r~%d", score_Text, id + 1, GetName(playerScores[id][player_ID]), playerScores[id][player_Score]);
}
else
format(score_Text, sizeof(score_Text), "%s~n~~b~%d. ~r~N/A", score_Text, id + 1);
}
new str[128];
format(str, 128, "Your Alive Time: %d Sec.", Player[i][AliveTime]);
TextDrawSetString(AliveTimeTD[i], str);
TextDrawShowForPlayer(i, AliveTimeTD[i]);
TextDrawSetString(TopPlayersList, score_Text);
TextDrawShowForPlayer(i, TopPlayers);
TextDrawShowForPlayer(i, TopPlayersBG);
TextDrawShowForPlayer(i, TopPlayersList);
}
}
return 1;
}