CMD:top(playerid, params[])
{
if(LoggedIn[playerid] == false) return SendClientMessage(playerid, COLOR_RED, "ERROR: You must be logged in.");
mysql_query(MySQL, "SELECT `User`, `Kills` FROM `UserData` ORDER BY `Kills` DESC LIMIT 5");
mysql_store_result();
new string[128], pName[24], pKills[5], query[256];
if(mysql_num_rows() != 0)
{
while(mysql_fetch_row_format(query, "|"))
{
mysql_fetch_field_row(pName, "User");
mysql_fetch_field_row(pKills, "Kills");
format(string, sizeof(string), "User: %s. Kills: %i", pName, pKills);
SendClientMessage(playerid, COLOR_RED, string);
}
}
mysql_free_result();
return 1;
}
CMD:top(playerid, params[])
{
if(LoggedIn[playerid] == false) return SendClientMessage(playerid, COLOR_RED, "ERROR: You must be logged in.");
mysql_query(MySQL, "SELECT `User`, `Kills` FROM `UserData` ORDER BY `Kills` DESC LIMIT 5");
mysql_store_result();
new string[128], pName[24], pKills[5];
if(mysql_num_rows() != 0)
{
while(mysql_retrieve_row())
{
mysql_fetch_field_row(pName, "User");
mysql_fetch_field_row(pKills, "Kills");
format(string, sizeof(string), "User: %s. Kills: %i", pName, pKills);
SendClientMessage(playerid, COLOR_RED, string);
}
}
mysql_free_result();
return 1;
}
Write always which version of mysql because this is weird mysql_query(MySQL,
|
CMD:top(playerid, params[])
{
if(LoggedIn[playerid] == false) return SendClientMessage(playerid, COLOR_RED, "ERROR: You must be logged in.");
new Cache:result = mysql_query(MySQL, "SELECT `User`, `Kills` FROM `UserData` ORDER BY `Kills` DESC LIMIT 5");
if((params[0] = cache_num_rows()))
{
new pName[24], pKills, string[128];
for(new i = 0; i < params[0]; i++)
{
cache_get_row(i, 0, pName);
pKills = cache_get_row_int(i, 1);
format(string, sizeof(string), "User: %s. Kills: %i", pName, pKills);
SendClientMessage(playerid, COLOR_RED, string);
}
}
cache_delete(result);
return 1;
}
Try with cache
pawn Код:
|