I am trying thing to do with sort but I still don't understand how to use it.
PHP Code:
enum
{
PLAYER_ID = 0,
PLAYER_SCORE
}
//Testing
Player_Score[0] = 100
Player_Score[1] = 200
Player_Score[2] = 300
...
Player_Score[32] = 3300
...
//Begin Sorting
public SortKills()
{
new iCount = 0
for(new i=0; i < sizeof(Player_Score); i++)
{
Ranking[iCount][PLAYER_ID] = i
Ranking[iCount][PLAYER_SCORED] = Player_Score[i]
iCount++
}
SortCustom2D(Ranking , iCount, "SortKills_Sort")
}
public SortKills_Sort(iElem1[], iElem2[])
{
new iKills1 = iElem1[PLAYER_SCORED]
new iKills2 = iElem2[PLAYER_SCORED]
if(iKills1 > iKills2)
return -1
else if(iKills1 < iKills2)
return 1
return 0
}
After that, I make a test function
PHP Code:
public test_fuction(id)
{
new name[33][33]
for(new i=0; i<sizeof(name); i++)
{
if(is_user_connected(Ranking[i][PLAYER_ID]))
{
get_user_name(Ranking[i][PLAYER_ID], name[i], sizeof(name[]))
}
else
{
formatex(name[i], sizeof(name[]), "NONE")
}
}
client_print(id, print_chat, "Rank 1:%i || Rank 2:%i || Rank 3: %i", Ranking[0][PLAYER_SCORED], Ranking[1][PLAYER_SCORED], Ranking[2][PLAYER_SCORED])
client_print(id, print_chat, "Rank 1:%s || Rank 2:%s || Rank 3: %s", name[0], name[1], name[2])
}
But the score is all 0 and the name is all NONE
Please help
P/S: I did search but I still don't understand how to use it.
__________________