Hello.
I want to make a /rank cmd that shows in console first 10 people with the biggest points.
I am with another friend and he has 10 points i have 15, it shows me 2 times instead of both of us.
Code:
public test(id)
{
new string[300];
Data[0] = id;
format(string, charsmax(string), "SELECT * FROM `players` ORDER BY `Points` DESC LIMIT 10"), SQL_ThreadQuery(Handler, "GiveRankInformation", string, Data, 5);
return PLUGIN_HANDLED;
}
new PlayerName2[32], PlayerPoints[32];
public GiveRankInformation(FailState, Handle:Query, Error[], Errcode, Data[], DataSize)
{
new id = Data[0];
if(SQL_NumResults(Query) > 0)
{
id++;
SQL_ReadResult(Query, 1, PlayerName2[id], 32), PlayerPoints[id] = SQL_ReadResult(Query, 5);
new Players[32], iNum, id2;
get_players(Players, iNum, "ch");
for(new i = 0; i < id; i++)
{
id2 = Players[i];
client_print(id2, print_console, "%s %s - Points: %d - %d", TAG, PlayerName2[id], PlayerPoints[id], id);
}
}
return PLUGIN_HANDLED;
}