Hi, could anyone help me with a piece of code for a RANK function?
For example, I have this top function:
PHP Code:
formatex(szTemp, charsmax(szTemp), "SELECT * FROM `%s` ORDER BY `score` DESC LIMIT 0,15", TABEL);
SQL_ThreadQuery(g_SqlTuple, "ZP_TOP", szTemp, szData, 1)
PHP Code:
public ZP_TOP( FailState, Handle:Query, Error[], Errcode, Data[], DataSize )
{
if(FailState == TQUERY_CONNECT_FAILED)
log_amx("Load - Could not connect to SQL database. [%d] %s", Errcode, Error)
else if(FailState == TQUERY_QUERY_FAILED)
log_amx("Load Query failed. [%d] %s", Errcode, Error)
new id; id = Data[0]
new to_get[15][64]
new rows1 = SQL_NumResults(Query)
new iScore[15]
if(SQL_MoreResults(Query))
{
for(new i = 0 ; i < rows1 ; i++)
{
SQL_ReadResult(Query, 1, to_get[i], 63)
iScore[i] = SQL_ReadResult(Query, 6)
SQL_NextRow(Query)
}
}
if(rows1 > 0)
{
new iLen=0;
iLen = format( g_Buffer[iLen], 2047, g_sTopStyle )
iLen += format( g_Buffer[iLen], 2047 - iLen, "<body bgcolor=#000000><table border=0 cellspacing=0 cellpadding=3px><tr><th class=p>#<td class=p><th>Player<th>Score" )
for(new i = 0 ; i < rows1 ; i++)
{
new rowColor[16];
if(i < 3)
{
if(i == 0) format(rowColor, sizeof(rowColor), "blue");
else if(i == 1) format(rowColor, sizeof(rowColor), "yellow");
else format(rowColor, sizeof(rowColor), "red");
}
else format(rowColor, sizeof(rowColor), "");
iLen += format(g_Buffer[iLen], 2047 - iLen, "<tr><td class=p>%d<td class=p><td class=%s>%s<td>%i<td>", i + 1, rowColor, to_get[i], iScore[i]);
}
show_motd(id, g_Buffer, "Top15 Zombie")
}
return 1
}
and I want to make one for RANK, and display:
"[AMXX] Your rank is m/n with a data1 b data2 c data3 d data4"
Where 'm' is the current rank of the player (or position in the DB, I'm not sure how it would come), 'n' is the total entries in the DB, and a, b, c, d are other integer values.