The online racing simulator
Log scrolling
Hello, how can I make the log system as in the image, I think I can print it to .txt and pull them while doing this, there is no problem here, but how can I make the scroll down system like on the side, until it can go forever
Attached images
adminlogsystem.jpg
This doesn't seems like a scroll bar as you would see in windows for example. I think it's just a manual trick, that shows certain number of lines of text. Pressing up and down button just itterates through the array, or some index.
Yes, I understand. I want to make a page the easy way. I mean I don't want to use IF for every page, maybe there is an easy way.
foreach etc.
Yes, you will have to use some sort of for loop, that goes through the text lines.
Yes, I think so too, but I wrote here because I don't have information about it.
Then your best bet is to wait for some lapper guru to comment.
i've created an example.
This example has not been tested.

I'm sure there are better ways to do paging within LFSLapper. I've using this type of paging for a really long time, because it just works Smile.

I've copied some code from my TimeAttack scripts to create this example.
The buttons may out of place, but i think you'll get the idea.

Just give this code a look and try to understand how it works.

Here is a part of the code, the rest can you find in the attachment.

Sub Paging($UserName)

$MaxNrOfResults = 40;
$BtnHgt = 61;
$BtnWdt = 70;
$Counter = 0;
$MaxResultsOnPage = 15;

#Close all buttons that contains "Page_"
#Just to prevent overlapping buttons with different button ID's (actually this shouldn't happen within this code)
CloseButtonRegex ($username, "Page_*");

$StartNrOfResult = (Getplayervar($username,"Page") * $MaxResultsOnPage) - $MaxResultsOnPage;

openPrivButton( "Page_Prev",$BtnWdt,$BtnHgt+10,15,4,5,-1,32, "^7Prev Page",PrevPage);
openPrivTextButton( "Page_Sel",$BtnWdt+15,$BtnHgt+10,10,4,5,32,"Select page 1 - 8","^7Page ".Getplayervar($UserName,"Page"),1,SelectPage);
openPrivButton( "Page_Next",$BtnWdt+25,$BtnHgt+10,15,4,5,-1,32, "^7Next Page",NextPage);

FOR( $i = 0; $i <= ToNum($MaxNrOfResults); $i = $i + 1)

#Show 15 results on screen
#Start result from number $StartNrOfResult
#It stops showing results when $counter hits the limit or reached MaxNumberofResult
IF(($i >= ToNum($StartNrOfResult))&&(ToNum($Counter) < $MaxResultsOnPage)) THEN

openPrivButton( "Page_Button_".$Counter,$BtnWdt,$BtnHgt,5,4,5,-1,16, "".$i);

#Increase the buttonheight by 4 for each button.
$BtnHgt = $BtnHgt + 4;
$Counter = $Counter + 1;
ENDIF

ENDFOR

EndSub

#User Clicked on Next Page Button
Sub NextPage($keyflags,$id)
$UserName = GetCurrentPlayerVar("UserName");
$CurrPage = Getplayervar($UserName,"Page");

#Increase pagenumber by 1. And call 'paging' sub
Setplayervar($UserName,"Page",$CurrPage + 1);
Paging($UserName);

EndSub

#User Clicked on Prev Page Button
Sub PrevPage($keyflags,$id)
$UserName = GetCurrentPlayerVar("UserName");
$CurrPage = Getplayervar($UserName,"Page");

# Reset Playervar when pagenumber is below 1
# Otherwise decrease pagenumber by 1.
# And call 'paging' sub

IF($CurrPage <= 1) THEN
Setplayervar($UserName,"Page",1);
ELSE
Setplayervar($UserName,"Page",$CurrPage - 1);
ENDIF

Paging($UserName);
EndSub

Attached files
pagingexample.txt - 3 KB - 67 views
Thank you for your help. However, I did not get the result I wanted when showing the data. Basically it works, but there is a problem when going too far back
Attached files
pagingexample.txt - 5.6 KB - 68 views
You have to put a limit such that $CurrPage is never negative (or less than 1) which ever is the starting value, it must not be less than starting value. But as I see, this limiter is already there, so there should be no problem. What kind of problem do you observe when pressing page back button?
There does not seem to be anything wrong with the code given by bass driver, but there is no code to pull what is written in .txt, so I tried to add it myself and I could not get the result I wanted.

In the code I made, I can pull the data and I can move forward, but sometimes there is a problem in a way I don't understand, I checked the ifs to avoid this problem and it seemed correct.
You have to debug your code to see where the problem is. Without posting what you have so far and what is inside of this txt file, it's impossible to help further.
I stated what I did in my message above
The text in the txt does not matter, even if you write a random text, it will perform the same function
up
Is there anyone who can help

FGED GREDG RDFGDR GSFDG