The online racing simulator
How to get specific Top Times and specific Top Drifts in lapper from V7.046 on?
When I was using V6 lapper, I had Top Time and Drift Score tables, where you could press a button and get information depending on the button.

For instance, press 'UF1' in Laptime table, and you got only the top UF1 times.
Press '19-36' button in same table, and you got list of the top 19 to 36 times.



Press 'XRT' in the drift table, and you got only got a list of the XRT drift scores.
Press '73 - 90' button in drift table, and you got list of the top 73 to 90 times.



The code for this was very simple;

<?php 
    openPrivButton
"car_UF1button",58,20,8,5,2,-1,16,"^2UF1",Click_UF1 );
?>


<?php 
    Sub Click_UF1
$KeyFlags,$id )
    
# my code
    
End Sub
?>


"# my code", depending on use, would have been

<?php 
    top 
(UF1)    # top times for UF1 only
    
top (19_36)  # top 19 to 36 times for all cars
    
drf (XRT)    # top drift scores for XRT only
    
drf (19_36)  # top drift scores from position 19 to 36
?>

But in an early V7, top and drf, which used to be hardcoded into lapper, were removed.

Because of this, my simple code no longer works, and I'm not sure what has replaced it.

What do I use now?

For instance, looking in the DOCS folder, I see that Usertop table is now editable. // usertop.lpr
$list = getlisttopuser( $value,$flagdesc,$flagNear,$filter ); #Get List from stored database
!usertop command in LFSLapper.lpr

However, I can't see a description for what ( $value,$flagdesc,$flagNear,$filter )is,
and !usertop is
DoMyUserTop( $GetStoredValue,DESC,FALSE,$Filter);
where this equates to database value, descending value, display toplist, start position.

Is there something simple (like I had), or do I have to set up some sort of array system for each and every button?

Or would it be better if top() and drf() were reinstated?
Attached images
Drift table.png
Top table.png
** Best answer **
@sinanju

I created usertop.lpr and drifttop.lpr, instead of
drf() / drfnear() / top()/ topnear()

.

The code you see in those scripts is basically 90% of the code that was in the sourcecode before. But now you have much more freedom to edit the buttons etc.

And yes it is more difficult to work with.

Here are some examples, how it was before and how it is now. Correct me if i'm wrong, i haven't use these functions for a very long time. Smile

top(UF1) = DoMyUserTop( UF1,DESC,FALSE,1);
top(19_36) = DoMyUserTop( "",DESC,FALSE,19);



<?php 
neartop
()    = DoMyUserTopUF1,DESC,TRUE,1);
drf(XRT)     = DoMyDriftTopXRT,FALSE,FALSE);
drf(19_36)   = DoMyDriftTop19,FALSE,FALSE);
drfnear(XRT) = DoMyDriftTop(XRT,FALSE,TRUE);
?>

Quote from Yisc[NL :I made toptable a long time ago (2015) for you, which works in V7 of Lapper and could be good starting point to create what you want: https://www.lfs.net/forum/post/1883455#post1883455

Yes, and I still use it ...



... although I changed it slightly (size and reversed car list).

I also used your code as base for doing a Drift Points table for the driver that clicks the "your Drift Points per Car type" button ...



Although I have an understanding of what arrays in lapper are doing, I don't really want to use them for something like the buttons that I'm trying to set up, although would be easy enough I suppose to copy/paste an array for every button and then change car type, etc.

But thanks for the response. Thumbs up

As you can see, I also changed your Pitboard code (a lot) as the only info I want, is what you see in the image. I had to remove a lot of code, but I sort of got it working - Last and Best sectors not always doing what I expect, but, heh ho Smile
Attached images
Top times per car type.png
Your drift points.png
Quote from Bass-Driver :@sinanju
I created usertop.lpr and drifttop.lpr, instead of
drf() / drfnear() / top()/ topnear()

.
The code you see in those scripts ....

Thanks for that.

The code you've supplied makes more sense now, and I can try it out for my buttons.

Thanks.
OK, after trying for a number of hours, I can give you the results of my testing (on V7.080) ...

Drift Scores:
DoMyDriftTop( XRT,FALSE,FALSE ); - This works
DoMyDriftTop( 19,FALSE,FALSE ); - This works

They're the only 2 commands I need for my drift buttons so no further tests on drifts.

Top Times:
Nothing I've tried works. Best I can do, is get an empty table ...



(and yes, I do have a UF1 time in my normal top list!)

So. I have a button set up ...

<?php 
openPrivButton
"car_UF1button",58,156,8,5,2,-1,16,"^2UF1",Click_UF1 );
?>

Then a sub ...

<?php 
Sub Click_UF1
$KeyFlags,$id )
  
closeButtonRegex (GetCurrentPlayerVar("UserName"), "SinanjuTop_*"); # close TOP List
    
DoMyUserTopUF1,DESC,FALSE,);
#    Where - UF1 = Storedvalue / DESC or ASC: Sort values descending or ascending /
#    FALSE = Display toplist ('TRUE' = go to your position) / Filter: 1 = start at position 1
EndSub
?>


Result: This does open table (ie "List of: UF1") but does not populate the table with details - nor does it produce an error in the log file

<?php 
Sub Click_UF1
()
  
closeButtonRegex (GetCurrentPlayerVar("UserName"), "SinanjuTop_*"); # close TOP List
    
DoMyUserTopUF1,DESC,FALSE,) ;
EndSub
?>


Result: This does nothing, but does throw up a "Syntax error: Incorrect number of arguments at line #181 in function 'click_uf1' script aborted" error

<?php 
Sub Click_UF1
UF1,DESC,FALSE,)
 
closeButtonRegex (GetCurrentPlayerVar("UserName"), "SinanjuTop_*"); # close TOP List
    
DoMyUserTop();
EndSub
?>


Result: This does nothing, but does throw up a "Syntax error: Incorrect number of arguments at line #188 in function 'click_uf1' script aborted" error

<?php 
Sub Click_UF1
UF1,DESC,FALSE,)
  
closeButtonRegex (GetCurrentPlayerVar("UserName"), "SinanjuTop_*"); # close TOP List
    
DoMyUserTop(UF1,DESC,FALSE,1);
EndSub
?>


Result: This does nothing, but does throw up a "Syntax error: Incorrect number of arguments at line #195 in function 'click_uf1' script aborted" error

<?php 
Sub Click_UF1
$KeyFlags,$id )
  
closeButtonRegex (GetCurrentPlayerVar("UserName"), "SinanjuTop_*"); # close TOP List
    
DoMyUserTopUF1,DESC,TRUE,);
EndSub
?>


Result: This does open table (ie "List of: UF1") but does not populate the table with details - nor does it produce an error in the log file

Also tried same subs but changing DESC to ASC (decending to ascending), but same results.

Then I thought that maybe the problem might be that if the UF1 isn't top of the times, then it should be blank, so

<?php 
Sub Click_UF1
$KeyFlags,$id )
  
closeButtonRegex (GetCurrentPlayerVar("UserName"), "SinanjuTop_*"); # close TOP List
    
DoMyUserTopUF1,DESC,FALSE,"" );
EndSub
?>


Result: Empty list

Anyone advise on where I'm going wrong?
Attached images
Empty Table.png
Could you try to use the quotes ( "" ) for the car argument?
Same for the Sort ( DESC or ASC ) argument

It is possible that it doesnt detect a string for one of those two, so it sees 3 of the 4 arguments in the DoMyUserTop() function.

DoMyUserTop( "UF1",DESC,FALSE,"" );

DoMyUserTop( "UF1","DESC",FALSE,"" );

If thats true, than its odd that it works for the DoMyDriftTop() function, maybe there is some difference in the sourcecode.
I tried putting quotes round some of the arguments, but best I could get was empty list.
I've been working for a while on doing panels with buttons for Drift Points, which seem to work fine, so haven't spent much time on my Tops stuff.
I've been trying out all these top buttons on an old tops add-on script, so that might be the issue.
Anyway, likely not be able to look at this again till mid next week, but thanks for everything so far.
Just had a vague thought - I'm not using standard Top Table, so maybe I need to use CatchSub. I'll try remember to check that out.
Never used or heard of CatchSub.
But i'll test the TopTable myself when i have time.
It's weird, you do not get any results in the toptable. And you are the first one when reported this issue. Since we released the new TopTable methode in version 7.0.4.7.
I did some testing using Lapper 7.0.4.10 (which is my operational version) and get the same results as sinanju.
Either the list is empty, or you get an error about missing argument or you get a huge error when using this: DoMyUserTop( "XFG","DESC","FALSE",1 );

The error being:

Lapper Instance 127.0.0.1/29994 abort!

Input string was not in a correct format.
mscorlib
at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
at System.Int32.Parse(String s)
at LFSLapper.LFSClient.getlisttopuser(unionVal val, ArrayList args)
at GLScript.GLApp.parseBackcall(SetOfVars GVAR, SetOfVars LVAR, unionVal val, ArrayList args)
at GLScript.Parseur.getval(SetOfVars GVAR, SetOfVars LVAR, executeParsedFunction BC)
at GLScript.Parseur.getval(SetOfVars GVAR, SetOfVars LVAR, executeParsedFunction BC)
at GLScript.GLApp.retrieveEvalVar(String funcName, TokenParse tkparse, TokenBuffer currTokenBuffer, SetOfVars GVAR, SetOfVars LVAR, Boolean breakFunc, Char& breakCar)
at GLScript.GLApp.privExecuteTokensPart(Int32 level, String funcName, SetOfVars GCAR, SetOfVars LVAR, Boolean breakable, Boolean inSwitchCase, Int32 start, Int32 end)
at GLScript.GLApp.privExecuteFunction(String funcName, String[] argsVals)
at GLScript.GLApp.parseBackcall(SetOfVars GVAR, SetOfVars LVAR, unionVal val, ArrayList args)
at GLScript.Parseur.getval(SetOfVars GVAR, SetOfVars LVAR, executeParsedFunction BC)
at GLScript.GLApp.retrieveEvalVar(String funcName, TokenParse tkparse, TokenBuffer currTokenBuffer, SetOfVars GVAR, SetOfVars LVAR, Boolean breakFunc, Char& breakCar)
at GLScript.GLApp.privExecuteTokensPart(Int32 level, String funcName, SetOfVars GCAR, SetOfVars LVAR, Boolean breakable, Boolean inSwitchCase, Int32 start, Int32 end)
at GLScript.GLApp.privExecuteTokensPart(Int32 level, String funcName, SetOfVars GCAR, SetOfVars LVAR, Boolean breakable, Boolean inSwitchCase, Int32 start, Int32 end)
at GLScript.GLApp.privExecuteFunction(String funcName, String[] argsVals)
at GLScript.GLApp.executeFunction(String funcName, String[] argsVals)
at Configurator.lexConfigurator.executeFunction(String funcName, infoPlayer pcurrInfoPlayer, String[] par)
at LFSLapper.LFSClient.managePacket(MSO mso)
at LFSLapper.LFSClient.Loop(Connect insimConnection)
at LFSLapper.LFSClient.doloop()
at LapperInstances.LapperInstance.doConnection()
Void StringToNumber(System.String, System.Globalization.NumberStyles, NumberBuffer ByRef, System.Globalization.NumberFormatInfo, Boolean)
Closing Instance...
Found this in info.tops.lpr, one of the CIF modules. So instead of creating a new script for the toplist i added the code in the Tops CIF module. Couldnt find this change in the changelog. So mistake on my end , again Frown .



<?php 
$list 
GetListTop$TopCarList$flagQual$flagNear );

    
# GetListTop is hard coded for 24 results, so we go through the first 18 , because we have no more space
    
FOR( $i 0$i 18$i $i 1)
        
# Only show the line if it has a valid username
        
IF ( $list[$i,"UserName"] != ""THEN
            
IF( ToLower$currUName ) == ToLower$list[$i,"UserName"] ) ) THEN
                $bStyle 
ISB_LIGHT;
            ELSE
                
$bStyle ISB_DARK;
            ENDIF
            
$topOrigT $topOrigT $topRowHeight;    # Go down to the next printable row

            
openPrivButton ($DialogPrefix "toppos_" $i,$topOrigL,$topOrigT,10,$topRowHeight,1,-1,$bStyle"^7" $list[$i,"Pos"]);
            
openPrivButton ($DialogPrefix "topcar_" $i,$topOrigL+10,$topOrigT,10,$topRowHeight,1,-1,$bStyle"^7" $list[$i,"CName"]);
            
openPrivButton ($DialogPrefix "topnick_" $i,$topOrigL+20,$topOrigT,35,$topRowHeight,1,-1,ISB_LEFT $bStyle"^7" $list[$i,"NickName"]);
            IF (
$list[$i,"PbLapTime"] > 3599000THEN
                $colpb 
= ((3600000 $list[$i,"PbLapTime"]) / 10) . "/" .  GetConfigVar"LapTimeUsedForPb" ) + langEngine"%{built_lapsdone}%" );
                
$colpos "-";
            ELSE
                
$colpb NumToMSH$list[$i,"PbLapTime"] );
            ENDIF
            
openPrivButton ($DialogPrefix "toppb_" $i,$topOrigL+55,$topOrigT,15,$topRowHeight,1,-1,$bStyle"^7" $colpb);
            
$colsplit "";
            FOR( 
$k 0$k 3$k $k +)
                
$SplitTime $list[$i,"SplitTime".$k];
                IF (
$SplitTime != 0THEN
                    
IF ( $colsplit != "" THEN
                        $colsplit 
$colsplit "/" NumToMSH($SplitTime);
                    ELSE
                        
$colsplit NumToMSH($SplitTime);
                    ENDIF
                ENDIF
            ENDFOR
            
openPrivButton ($DialogPrefix "topsplits_" $i,$topOrigL+70,$topOrigT,28,$topRowHeight,1,-1,$bStyle"^7" $colsplit);

        ENDIF

    ENDFOR
?>



$list = getlisttop( "UF1", FALSE,FALSE ); #TopList of racetimes
$list = getlisttopuser("StoredValue",DESC,FALSE,"1" ); #TopList for stored values.
$list = getlisttopdrift("XRT",FALSE,FALSE ); #TopList of Driftscores.

Ah, now it makes sense again.
What we have been trying should be used to make a top ranking of stored values and is not about times.
I should have known and read better.
Thanks for clearing this up.
The name of the function is just confusing. I should have named it better. This was/is a brainfart deluxe moment.
my apologies.

Maybe a seperate script whould be better, instead of digging into the CIF modules and get confused by the code around it.
Me, I'm still confused!

Anyway, I'll give you my code, that tried to use the $list arguments, but failed.

Code is based on the CIF module, and this version can be run from the CASE command (I know!!) !newtops.

This is what the table looks like, but the buttons at bottom of list (except Close) don't work.

(These are the buttons I've been experimenting on)



Do I need to put an array in for each button?

Would it be better if the old top command was reinstated?
Attached images
New Top Times.png
Attached files
temp_tops.txt - 9.2 KB - 151 views
So, for a test, I've used a lot of the FOR - ENDFOR code within the script I'm using as the base for the XRT button.

Used this, as car of choice for drifting, so I've got more times for this, than other cars.

When I click the XRT button, I get ...



Sub that needs to be added to my script is attached.

I could use this code for each of the CAR buttons, just a case of copy and paste whole sub, then find and replace the car type.

Or maybe, likely harder for me, is some sort of IF function, as in something like ...

IF
car = UF1 # this line likely won't work, but not sure what I could use (NOT cname, I'm sure)
THEN
UFI = $UF1

ELSE
IF
car = XRT
THEN
XRT = $XRT

$UF1 = GetListTop( "UF1", FALSE,FALSE );
$XRT = GetListTop( "XRT", FALSE,FALSE );
etc
Attached images
XRT.png
Attached files
Sub XRTTops.txt - 2.7 KB - 125 views
To me it looks a very complicated script, while you should try to use the same code for several cases. To accomplish this, use the name of the button that has been pressed and extract the carname from that buttonname.
Have a go with this.
There's plenty of room for further improvements and I might have broken some things in the process of changing the code as well.
But now you can press the car button and it will display the data for that car.
I have also stopped closing all the buttons again and again.
Now only the buttons are closed that are displaying data.
Attached files
temp_tops.txt - 9.5 KB - 126 views
Trying to rush things out is always a bad idea.
So while having a shower I came to the conclusion that the script that I just uploaded, has some flaws:

- setting a globalvar for a selection only a player has to see, really bad idea
- going from Sub 'SelectCar' back to Sub 'DoSinrsTops', not needed

So here's an adjusted one with the globalvar gone and being replaced with a SetCurrentPlayerVar and the call back to Sub 'DoSinrsTops' being removed from Sub 'SelectCar'.

If you want to, you could merge the code from Sub 'DrawButtons' into Sub 'SelectCar' but I like it to be two seperate subs as it's easier to read and you might want to use Sub 'DrawButtons' from some other point in the script.
Attached files
temp_tops.txt - 9.4 KB - 168 views
Thanks Yisc[NL].
Played around with your code and got it working as I wanted for my top table.

FGED GREDG RDFGDR GSFDG