How can I list up to X messages and split the messages between "pages" - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: How can I list up to X messages and split the messages between "pages" (
/showthread.php?tid=643960)
How can I list up to X messages and split the messages between "pages" -
EtayJ - 31.10.2017
PHP Code:
forward ListCreatedVehicles(playerid, page);
public ListCreatedVehicles(playerid, page)
{
if(page - 1 >= 0 && page - 1 < createdVehiclesCount) //Check if the page is within the array maximum index and minimum index (0)
{
new msg[128], color;
format(msg, sizeof(msg), "Listing created vehicles, page %i", page);
SendClientMessage(playerid, COLOR_WHITE, msg);
for(new i = (page - 1) * 5; i < createdVehiclesCount; i++) //i will always be equal to the number of pages minus one multiplied by five, so we can display the list to the player from the point of the page start
{
new Float:x, Float:y, Float:z, Float:distance;
distance = GetPlayerDistanceFromPoint(playerid, x, y, z);
color = COLOR_LIGHTGREY;
if((i + 1) % 2 == 0)
color = COLOR_WHITE;
format(msg, sizeof(msg), "ID: %i, Model: %i, Distance: %d", createdVehicles[i], GetVehicleModel(createdVehicles[i]), distance);
SendClientMessage(playerid, color, msg);
}
return 1;
}
return 0;
}
This is what I have been trying so far but it doesn't work, it lists all of the created vehicles in one message and I want it to list only 5 in each page.
Re: How can I list up to X messages and split the messages between "pages" -
Kane - 31.10.2017
http://forum.sa-mp.com/showpost.php?...5&postcount=12
Basically, something like:
PHP Code:
if(page == 1)
fulllist = "{FFFF00}Page 1\n";
else format(fulllist, sizeof(fulllist), "%s{FFFF00}<< Page %d\n", fulllist, page-1);
page--;
for(new i = page*MAX_PLOG_PER_PAGE; i < rows; i++)
{
count++;
if(count == MAX_PLOG_PER_PAGE + 1)
{
secondPage = true;
break;
}
else
{
cache_get_field_content(i, "log_detail", logStr, m_Handle, 256);
format(fulllist, sizeof(fulllist), "%s%s\n", fulllist, logStr);
}
}
if(secondPage)
format(fulllist, sizeof(fulllist), "%s{FFFF00}Page %d >>\n", fulllist, (page+1)+1);
Re: How can I list up to X messages and split the messages between "pages" -
EtayJ - 31.10.2017
That makes perfect sense, thank you!