09.03.2013, 11:40
(
Последний раз редактировалось Black Wolf; 09.03.2013 в 14:06.
)
Solved.
new query[128];
new page = 0;
mysql_format(dbhandle, query, "SELECT t0.user, t0.Kills FROM `playerinfo` t0 ORDER BY t0.Kills DESC LIMIT %d, 100", 20*page);
Use threaded queries, please.
pawn Код:
|
new query[90];
new page = 0;
if(page < 0) page = -page;
format(query, sizeof query, "SELECT t0.user, t0.Kills FROM `playerinfo` t0 ORDER BY t0.Kills DESC LIMIT %d, 100", 20*page);
#define MaxPages (10)
#define DIALOG_TOPKILLS (1000)
//(...)
CMD:top(pid, params[]) {
BuildTop(0);
return 1;
}
//(...)
stock BuildTop(page) {
new query[96], msg[512];
if(page < 0) page = -page;
if(page > MaxPages) page = MaxPages;
format(query, sizeof query, "SELECT t0.user, t0.Kills FROM `playerinfo` t0 ORDER BY t0.Kills DESC LIMIT %d, 100", 20*page);
//Process the query, and load variables into msg
ShowPlayerDialog(pid, DIALOG_TOPKILLS + page, DIALOG_STYLE_MSGBOX, "Top killers", msg, "Next", "Close");
return 1;
}
//(...)
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) {
if(response && dialogid >= DIALOG_TOPKILLS && dialogid < DIALOG_TOPKILLS + MaxPages) {
BuildTop(dialogid - DIALOG_TOPKILLS + 1);
}
return 1;
}
CMD:top20(playerid, params[])
{
new
iUser[23],
iKills[12],
iStr[521],
idx
;
mysql_query("SELECT `user`, `Kills` FROM `playerinfo` ORDER BY `Kills` DESC LIMIT 20");
mysql_store_result();
if (mysql_num_rows() != 0)
{
while (mysql_retrive_row())
{
mysql_fetch_field_row(iUser, "user");
mysql_fetch_field_row(iKills, "Kills");
format(iStr, sizeof(iStr), "%s%i) %s with %i kills.\n", iStr, idx, iUser, iKills);
idx ++;
}
ShowPlayerDialog(playerid, 123, DIALOG_STYLE_LIST, "Top 20 kills", iStr, "OK", "Cancel");
}
mysql_free_result();
return 1;
}
Note: Not tested
pawn Код:
|