Next and back button for dialogs. - Stefhan - 2020-03-24
I have been trying to add a next/back button?to this dialog for every 10 results. So far, I haven't managed to do it, hence I reverted the code back to the version without that.
Can anyone help me figure this out? There's really no good guide on this.
Code: ? ? ? ?case E_WARP_DIALOG_EXTS:
? ? ? ?{
? ? ? ? ? ?new warpstr[2000];
? ? ? ? ? ?format(warpstr, sizeof warpstr, INLINE[COLOR_SPOPT]"ID\t" INLINE[COLOR_SPOPT]"Name\n");
? ? ? ? ? ?for(new i = 0; i < MAX_WARPS; i)
? ? ? ? ? ?{
? ? ? ? ? ? ? ?if(!g_WarpsInfo[i][E_WARP_EXISTS])
? ? ? ? ? ? ? ? ? ?continue;
? ? ? ? ? ? ? ?if(g_WarpsInfo[i][E_WARP_CATEGORY] != 1) // 1 is the category ID for exteriors
? ? ? ? ? ? ? ? ? ?continue;
? ? ? ? ? ? ? ?else
? ? ? ? ? ? ? ? ? ?format(warpstr, sizeof(warpstr), "%s" INLINE[COLOR_OPTION] "#%d\t" INLINE[COLOR_OPTION] "%s\t\n", warpstr, i, g_WarpsInfo[i][E_WARP_NAME]);
? ? ? ? ? ?}
? ? ? ? ? ?inline DialogResponse_2(_playerid, dialogid, response, listitem, inputtext[])
? ? ? ? ? ?{
? ? ? ? ? ? ? ?#pragma unused dialogid, listitem
? ? ? ? ? ? ? ?if(!response)
? ? ? ? ? ? ? ?{
? ? ? ? ? ? ? ? ? ?WARPS_TeleportList(_playerid, E_WARP_DIALOG_MAIN);
? ? ? ? ? ? ? ?}
? ? ? ? ? ? ? ?if(response)
? ? ? ? ? ? ? ?{
? ? ? ? ? ? ? ? ? ?new str[256], warp_id;
? ? ? ? ? ? ? ? ? ?sscanf(inputtext[1],"d",warp_id);
? ? ? ? ? ? ? ? ? ?DelayedTeleport(playerid, g_TeleportDelay, g_WarpsInfo[warp_id][E_WARP_POS][0], g_WarpsInfo[warp_id][E_WARP_POS][1], g_WarpsInfo[warp_id][E_WARP_POS][2]\
? ? ? ? ? ? ? ? ? ?,?g_WarpsInfo[warp_id][E_WARP_POS][3], g_WarpsInfo[warp_id][E_WARP_WORLD], g_WarpsInfo[warp_id][E_WARP_INT]);
? ? ? ? ? ? ? ? ? ?format(str, sizeof(str), "%s %s(%d) has warped to %s(%d).", ReturnStaffLevel(playerid), ReturnICName(playerid), playerid, g_WarpsInfo[warp_id][E_WARP_NAME], warp_id);
? ? ? ? ? ? ? ? ? ?ABroadCast(COLOR[COLOR_SADMIN], str, 1);
? ? ? ? ? ? ? ?}
? ? ? ? ? ?}
? ? ? ? ? ?Dialog_ShowCallback(playerid, using inline DialogResponse_2, DIALOG_STYLE_TABLIST_HEADERS, INLINE[COLOR_HEADER] "Exterior Warps", warpstr, "Teleport", "Return");
? ? ? ?}
RE: Next and back button for dialogs. - akosd127 - 2020-03-25
Check this FS (Line: 1532-1553)
https://www.solidfiles.com/v/az4R38dkpjqna
RE: Next and back button for dialogs. - Stefhan - 2020-03-25
This is how far I got. (Note that the code below is from a different system, not warps, but spawns. Tho the code is?the same except for the variables.)
ID 0 isn't on the list anymore. The next page button acts as the teleport of ID 0 lol.. How do I proceed from here? I didn't add functionality to "next page" yet because I don't know how to fix the bug I just described and how to proceed.
Code: ? ? ? ?case E_SPAWN_DIALOG_LIST:
? ? ? ?{
? ? ? ? ? ?g_DialogPage[playerid] = 1;
? ? ? ? ? ?new title[128], spawnstr[2000], SpawnName[MAX_SPAWNS_NAME_SIZE], pages = GetPageCount(MAX_RESULTS, MAX_SPAWNS), count = ((MAX_RESULTS * g_DialogPage[playerid]) - MAX_RESULTS), bool:nextpage = false;
? ? ? ? ? ?format(spawnstr, sizeof spawnstr, INLINE[COLOR_SPOPT]"ID\t" INLINE[COLOR_SPOPT]"Location\n");
? ? ? ? ? ?for(new i = count; i < MAX_SPAWNS; i)
? ? ? ? ? ?{
? ? ? ? ? ? ? ?if(!g_SpawnsInfo[i][E_SPAWN_EXISTS])
? ? ? ? ? ? ? ? ? ?continue;
? ? ? ? ? ? ? ?else
? ? ? ? ? ? ? ?{
? ? ? ? ? ? ? ? ? ?count ;
? ? ? ? ? ? ? ? ? ?if(count <= MAX_RESULTS * g_DialogPage[playerid])
? ? ? ? ? ? ? ? ? ?{
? ? ? ? ? ? ? ? ? ? ? ?GetPickup3DLocation(g_SpawnsInfo[count][E_SPAWN_POS][0], g_SpawnsInfo[count][E_SPAWN_POS][1], g_SpawnsInfo[count][E_SPAWN_POS][2], SpawnName, MAX_SPAWNS_NAME_SIZE);
? ? ? ? ? ? ? ? ? ? ? ?format(spawnstr, sizeof(spawnstr), "%s" INLINE[COLOR_OPTION] "#%d\t" INLINE[COLOR_OPTION] "%s\t\n", spawnstr, count, SpawnName);
? ? ? ? ? ? ? ? ? ?}
? ? ? ? ? ? ? ? ? ?if(count > MAX_RESULTS * g_DialogPage[playerid])
? ? ? ? ? ? ? ? ? ?{
? ? ? ? ? ? ? ? ? ? ? ?nextpage = true;
? ? ? ? ? ? ? ? ? ? ? ?break;
? ? ? ? ? ? ? ? ? ?}
? ? ? ? ? ? ? ?}
? ? ? ? ? ?}
? ? ? ? ? ?if(nextpage == true)
? ? ? ? ? ?{
? ? ? ? ? ? ? ?if(g_DialogPage[playerid] == 1)
? ? ? ? ? ? ? ? ? ?format(spawnstr, sizeof(spawnstr), "%s" INLINE[COLOR_SPOPT] "Next page", spawnstr);
? ? ? ? ? ? ? ?else if(g_DialogPage[playerid] == pages)
? ? ? ? ? ? ? ? ? ?format(spawnstr, sizeof(spawnstr), "%s" INLINE[COLOR_SPOPT] "Previous page", spawnstr);
? ? ? ? ? ? ? ?else if(g_DialogPage[playerid] > 1)
? ? ? ? ? ? ? ? ? ?format(spawnstr, sizeof(spawnstr), "%s" INLINE[COLOR_SPOPT] "Next page\nPrevious page", spawnstr);
? ? ? ? ? ?}
? ? ? ? ? ?format(title, sizeof title, INLINE[COLOR_HEADER]"Spawnpoints (Page %d of %d)", g_DialogPage[playerid], pages);
? ? ? ? ? ?inline DialogResponse_2(_playerid, dialogid, response, listitem, inputtext[])
? ? ? ? ? ?{
? ? ? ? ? ? ? ?#pragma unused dialogid, listitem
? ? ? ? ? ? ? ?if(!response)
? ? ? ? ? ? ? ?{
? ? ? ? ? ? ? ? ? ?g_DialogPage[playerid] = 0;
? ? ? ? ? ? ? ? ? ?SPAWNS_TeleportList(_playerid, E_SPAWN_DIALOG_MAIN);
? ? ? ? ? ? ? ? ? ?return 1;
? ? ? ? ? ? ? ?}
? ? ? ? ? ? ? ?if(response)
? ? ? ? ? ? ? ?{
? ? ? ? ? ? ? ? ? ?if(g_AccountInfo[playerid][E_ACCOUNT_ADMIN_LEVEL] >= ADMIN_LEAD)
? ? ? ? ? ? ? ? ? ?{
? ? ? ? ? ? ? ? ? ? ? ?new str[256], spawn_id;
? ? ? ? ? ? ? ? ? ? ? ?sscanf(inputtext[1],"d",spawn_id);
? ? ? ? ? ? ? ? ? ? ? ?DelayedTeleport(playerid, g_TeleportDelay, g_SpawnsInfo[spawn_id][E_SPAWN_POS][0], g_SpawnsInfo[spawn_id][E_SPAWN_POS][1], g_SpawnsInfo[spawn_id][E_SPAWN_POS][2] 0.5, g_SpawnsInfo[spawn_id][E_SPAWN_POS][3], 0, 0);
? ? ? ? ? ? ? ? ? ? ? ?GetPickup3DLocation(g_SpawnsInfo[spawn_id][E_SPAWN_POS][0], g_SpawnsInfo[spawn_id][E_SPAWN_POS][1], g_SpawnsInfo[spawn_id][E_SPAWN_POS][2], SpawnName, MAX_SPAWNS_NAME_SIZE);
? ? ? ? ? ? ? ? ? ? ? ?format(str, sizeof(str), "%s %s(%d) has warped to a spawnpoint in %s(%d).", ReturnStaffLevel(playerid), ReturnICName(playerid), playerid, SpawnName, spawn_id);
? ? ? ? ? ? ? ? ? ? ? ?ABroadCast(COLOR[COLOR_SADMIN], str, 1);
? ? ? ? ? ? ? ? ? ?}
? ? ? ? ? ? ? ? ? ?else return SendClientMessage(playerid,COLOR[COLOR_ERROR],AMSG_NO_ACCESS_TO_USE);
? ? ? ? ? ? ? ?}
? ? ? ? ? ?}
? ? ? ? ? ?Dialog_ShowCallback(playerid, using inline DialogResponse_2, DIALOG_STYLE_TABLIST_HEADERS, title, spawnstr, "Select", "Return");
? ? ? ?}
RE: Next and back button for dialogs. - Stefhan - 2020-03-25
Fixed it by using this script as a reference:
Code: // [ DEVELOPMENT GAMEMODE ]
// INCLUDES:
#include <a_samp>
#include <sscanf2>
#include <zcmd>
// DEFINES:
// GENERAL:
#define MAX_RESULTS 20
#define TOTAL_VEHICLES 212
// FUNCTIONS:
#define GetPageCount(%0,%1) floatround(%1 / %0, floatround_floor) 1
// DIALOGS:
#define DIALOG_OK 500
#define DIALOG_VEHICLE_LIST 501
// ARRAYS AND ENUMERATORS:
static const stock aVehicles[TOTAL_VEHICLES][] =
{
? ?{"Landstalker"},
? ?{"Bravura"},
? ?{"Buffalo"},
? ?{"Linerunner"},
? ?{"Perrenial"},
? ?{"Sentinel"},
? ?{"Dumper"},
? ?{"Firetruck"},
? ?{"Trashmaster"},
? ?{"Stretch"},
? ?{"Manana"},
? ?{"Infernus"},
? ?{"Voodoo"},
? ?{"Pony"},
? ?{"Mule"},
? ?{"Cheetah"},
? ?{"Ambulance"},
? ?{"Leviathan"},
? ?{"Moonbeam"},
? ?{"Esperanto"},
? ?{"Taxi"},
? ?{"Washington"},
? ?{"Bobcat"},
? ?{"Mr Whoopee"},
? ?{"BF Injection"},
? ?{"Hunter"},
? ?{"Premier"},
? ?{"Enforcer"},
? ?{"Securicar"},
? ?{"Banshee"},
? ?{"Predator"},
? ?{"Bus"},
? ?{"Rhino"},
? ?{"Barracks"},
? ?{"Hotknife"},
? ?{"Trailer 1"},
? ?{"Previon"},
? ?{"Coach"},
? ?{"Cabbie"},
? ?{"Stallion"},
? ?{"Rumpo"},
? ?{"RC Bandit"},
? ?{"Romero"},
? ?{"Packer"},
? ?{"Monster"},
? ?{"Admiral"},
? ?{"Squalo"},
? ?{"Seasparrow"},
? ?{"Pizzaboy"},
? ?{"Tram"},
? ?{"Trailer 2"},
? ?{"Turismo"},
? ?{"Speeder"},
? ?{"Reefer"},
? ?{"Tropic"},
? ?{"Flatbed"},
? ?{"Yankee"},
? ?{"Caddy"},
? ?{"Solair"},
? ?{"Berkley's RC Van"},
? ?{"Skimmer"},
? ?{"PCJ-600"},
? ?{"Faggio"},
? ?{"Freeway"},
? ?{"RC Baron"},
? ?{"RC Raider"},
? ?{"Glendale"},
? ?{"Oceanic"},
? ?{"Sanchez"},
? ?{"Sparrow"},
? ?{"Patriot"},
? ?{"Quad"},
? ?{"Coastguard"},
? ?{"Dinghy"},
? ?{"Hermes"},
? ?{"Sabre"},
? ?{"Rustler"},
? ?{"ZR-350"},
? ?{"Walton"},
? ?{"Regina"},
? ?{"Comet"},
? ?{"BMX"},
? ?{"Burrito"},
? ?{"Camper"},
? ?{"Marquis"},
? ?{"Baggage"},
? ?{"Dozer"},
? ?{"Maverick"},
? ?{"News Chopper"},
? ?{"Rancher"},
? ?{"FBI Rancher"},
? ?{"Virgo"},
? ?{"Greenwood"},
? ?{"Jetmax"},
? ?{"Hotring"},
? ?{"Sandking"},
? ?{"Blista Compact"},
? ?{"Police Maverick"},
? ?{"Boxville"},
? ?{"Benson"},
? ?{"Mesa"},
? ?{"RC Goblin"},
? ?{"Hotring Racer A"},
? ?{"Hotring Racer B"},
? ?{"Bloodring Banger"},
? ?{"Rancher"},
? ?{"Super GT"},
? ?{"Elegant"},
? ?{"Journey"},
? ?{"Bike"},
? ?{"Mountain Bike"},
? ?{"Beagle"},
? ?{"Cropdust"},
? ?{"Stunt"},
? ?{"Tanker"},
? ?{"Roadtrain"},
? ?{"Nebula"},
? ?{"Majestic"},
? ?{"Buccaneer"},
? ?{"Shamal"},
? ?{"Hydra"},
? ?{"FCR-900"},
? ?{"NRG-500"},
? ?{"HPV1000"},
? ?{"Cement Truck"},
? ?{"Tow Truck"},
? ?{"Fortune"},
? ?{"Cadrona"},
? ?{"FBI Truck"},
? ?{"Willard"},
? ?{"Forklift"},
? ?{"Tractor"},
? ?{"Combine"},
? ?{"Feltzer"},
? ?{"Remington"},
? ?{"Slamvan"},
? ?{"Blade"},
? ?{"Freight"},
? ?{"Streak"},
? ?{"Vortex"},
? ?{"Vincent"},
? ?{"Bullet"},
? ?{"Clover"},
? ?{"Sadler"},
? ?{"Firetruck LA"},
? ?{"Hustler"},
? ?{"Intruder"},
? ?{"Primo"},
? ?{"Cargobob"},
? ?{"Tampa"},
? ?{"Sunrise"},
? ?{"Merit"},
? ?{"Utility"},
? ?{"Nevada"},
? ?{"Yosemite"},
? ?{"Windsor"},
? ?{"Monster A"},
? ?{"Monster B"},
? ?{"Uranus"},
? ?{"Jester"},
? ?{"Sultan"},
? ?{"Stratum"},
? ?{"Elegy"},
? ?{"Raindance"},
? ?{"RC Tiger"},
? ?{"Flash"},
? ?{"Tahoma"},
? ?{"Savanna"},
? ?{"Bandito"},
? ?{"Freight Flat"},
? ?{"Streak Carriage"},
? ?{"Kart"},
? ?{"Mower"},
? ?{"Duneride"},
? ?{"Sweeper"},
? ?{"Broadway"},
? ?{"Tornado"},
? ?{"AT-400"},
? ?{"DFT-30"},
? ?{"Huntley"},
? ?{"Stafford"},
? ?{"BF-400"},
? ?{"Newsvan"},
? ?{"Tug"},
? ?{"Trailer 3"},
? ?{"Emperor"},
? ?{"Wayfarer"},
? ?{"Euros"},
? ?{"Hotdog"},
? ?{"Club"},
? ?{"Freight Carriage"},
? ?{"Trailer 3"},
? ?{"Andromada"},
? ?{"Dodo"},
? ?{"RC Cam"},
? ?{"Launch"},
? ?{"LSPD Police Car"},
? ?{"SFPD Police Car"},
? ?{"LVPD Police Car"},
? ?{"Police Ranger"},
? ?{"Picador"},
? ?{"SWAT Van"},
? ?{"Alpha"},
? ?{"Phoenix"},
? ?{"Glendale"},
? ?{"Sadler"},
? ?{"Luggage Trailer A"},
? ?{"Luggage Trailer B"},
? ?{"Stair Trailer"},
? ?{"Boxville"},
? ?{"Farm Plow"},
? ?{"Utility Trailer"}
};
// VARIABLES:
new pLastPage[MAX_PLAYERS];
// MAIN:
main()
{
? ?print("Development Mode: vehicle_list.amx");
}
// CALLBACKS:
public OnGameModeInit()
{
? ?return 1;
}
public OnGameModeExit()
{
? ?return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
? ?switch(dialogid)
? ?{
? ? ? ?case DIALOG_OK: return 1;
? ? ? ?case DIALOG_VEHICLE_LIST:
? ? ? ?{
? ? ? ? ? ?if(!response) return 1;
? ? ? ? ? ?else if(response)
? ? ? ? ? ?{
? ? ? ? ? ? ? ?pLastPage[playerid] ;
? ? ? ? ? ? ? ?ShowVehicleList(playerid);
? ? ? ? ? ?}
? ? ? ?}
? ?}
? ?return 1;
}
// COMMANDS:
CMD:vehiclelist(playerid, params[])
{
? ?pLastPage[playerid] = 1;
? ?ShowVehicleList(playerid);
? ?return 1;
}
// FUNCTIONS:
stock ShowVehicleList(playerid)
{
? ?new title[128], string[300], pages = GetPageCount(MAX_RESULTS, TOTAL_VEHICLES), resultcount = ((MAX_RESULTS * pLastPage[playerid]) - MAX_RESULTS), bool:nextpage = false;
? ?strcat(string, "ID\tName");
? ?for(new i = resultcount; i < TOTAL_VEHICLES; i )
? ?{
? ? ? ?resultcount ;
? ? ? ?if(resultcount <= MAX_RESULTS * pLastPage[playerid])
? ? ? ?{
? ? ? ? ? ?format(string, sizeof(string), "%s\n%d\t%s", string, resultcount, aVehicles[i]);
? ? ? ?}
? ? ? ?if(resultcount > MAX_RESULTS * pLastPage[playerid])
? ? ? ?{
? ? ? ? ? ?nextpage = true;
? ? ? ? ? ?break;
? ? ? ?}
? ?}
? ?format(title, sizeof(title), "{FFFF00}Vehicles - Page %d of %d", pLastPage[playerid], pages);
? ?if(nextpage) return ShowPlayerDialog(playerid, DIALOG_VEHICLE_LIST, DIALOG_STYLE_TABLIST_HEADERS, title, string, "Next", "Close");
? ?return ShowPlayerDialog(playerid, DIALOG_OK, DIALOG_STYLE_TABLIST_HEADERS, title, string, "Close", "");
}
RE: Next and back button for dialogs. - akosd127 - 2020-03-26
I do this for you
https://www.solidfiles.com/v/GvnLV8mxKB3Vn
load filterscript
and type to chat /dialog
|