19.09.2017, 13:09
PHP код:
new PageList[MAX_PLAYERS];
enum {
DIALOG_TEST
};
public OnPlayerConnect(playerid) {
PageList[playerid] = 0;
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) {
switch(dialogid) {
case DIALOG_TEST: {
if(!response) {
PageList[playerid]--;
if(PageList[playerid] < 0) {
PageList[playerid] = 0;
// Show the first page again or do whatever you want.
return 1;
}
}
else PageList[playerid]++;
format(Query, sizeof(Query), "SELECT `ip`, `time`, `loggedin` FROM `ips` WHERE `username` = '%s' ORDER BY datetime(unix) DESC LIMIT %i, 10", TARGET_NAME, ListPage[playerid] * 10);
// We're using x10 because you're showing only 10 rows per page. As you can see above we made it to increase the ListPage[playerid] variable + 1 whenever
// the player click button 1 (which in your case, Next button). 1 x 10 = 10, 2 x 10 = 20 and so on.
Result = db_query(Database, Query);
// Make sure to reset the ListPage[playerid] to 0 when there are no rows found and before showing the dialog in your command.
// ListPage[playerid] = 0;
}
}
return 0;
}
By the way, your code indentation is so horrible. There are many things you need to optimize.