Top5 Players bugs -
Stefand - 11.08.2013
Hey Fellas,
I use Ryders Top 5 Script,
But I noticed the score keeps updating correctly, but the name doesnt.
pawn Код:
public Top5Update()
{
new
playerScores[MAX_PLAYERS][rankingEnum],
index
;
for(new i; i != MAX_PLAYERS; ++i)
{
if(IsPlayerConnectedEx(i) && !IsPlayerNPC(i))
{
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(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;
}
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);
}
Hope you can help
Re: Top5 Players bugs -
dEcooR - 11.08.2013
Whats your SetTimer?
Re: Top5 Players bugs -
Stefand - 11.08.2013
it is called in the OneSecondPublic, which runs every one second
Re: Top5 Players bugs -
dEcooR - 11.08.2013
Hmm idk dude wheres the problem look at his code again maybe u did somethin wrong
Re: Top5 Players bugs -
Stefand - 11.08.2013
I looked over it 100times.. I dont understand it.
Re: Top5 Players bugs -
-Prodigy- - 11.08.2013
Try the following to get the name:
pawn Код:
GetName(playerScores[id][player_ID])
Re: Top5 Players bugs -
Stefand - 11.08.2013
I tried, it kept returning the top player name, 5 times the same name
Re: Top5 Players bugs -
-Prodigy- - 11.08.2013
Try making 2 loops, instead of having the loop to get top 5 inside the main loop.
Re: Top5 Players bugs -
Stefand - 11.08.2013
What do you mean exacly?
Re: Top5 Players bugs -
-Prodigy- - 11.08.2013
Try the following:
pawn Код:
public Top5Update()
{
new
playerScores[MAX_PLAYERS][rankingEnum],
index
;
new str[128];
for(new i; i != MAX_PLAYERS; ++i)
{
if(IsPlayerConnectedEx(i) && !IsPlayerNPC(i))
{
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)
{
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]);
format(str, 128, "Your Alive Time: %d Sec.", Player[id][AliveTime]);
TextDrawSetString(AliveTimeTD[id], str);
TextDrawShowForAllAll(AliveTimeTD[id]);
}
TextDrawSetString(TopPlayersList, score_Text);
TextDrawShowForAll(TopPlayers);//Player(i, TopPlayers);
TextDrawShowForAll(TopPlayersBG);//Player(i, TopPlayersBG);
TextDrawShowForAll(TopPlayersList);//Player(i, TopPlayersList);
return 1;
}
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);
}
Since you are showing the Textdraws to everyone, I've changed it to ShowForAll instead.