The online racing simulator
Thanks Yisc, still struggling. I'm trying to add a Users Admin Status to database so I can have BETA Testers testing PitBoard but can't work it out how to set a Users Details...

SetUserStoredValue($argv."Admin","0"); (That sets me only)

I know thats wrong but where do I put the $argv to set a UserName? So I type !Level UserName which sets Users Stored Value to Admin 0 meaning I can manually add testers.

Thanks in Advance
Andy
Quote from Andy King :Thanks Yisc, still struggling. I'm trying to add a Users Admin Status to database so I can have BETA Testers testing PitBoard but can't work it out how to set a Users Details...

SetUserStoredValue($argv."Admin","0"); (That sets me only)

I know thats wrong but where do I put the $argv to set a UserName? So I type !Level UserName which sets Users Stored Value to Admin 0 meaning I can manually add testers.

Thanks in Advance
Andy

The syntax you have used for SetUserStoredValue is wrong.
Should be like this: SetUserStoredValue( $argv, "Admin", 0 );

So, no dot after $argv but a comma.
Also a number should not be between quotes, as that would mean it would be stored as text instead of a numeric value.
Quote from Yisc[NL] :The syntax you have used for SetUserStoredValue is wrong.
Should be like this: SetUserStoredValue( $argv, "Admin", 0 );

So, no dot after $argv but a comma.
Also a number should not be between quotes, as that would mean it would be stored as text instead of a numeric value.

I was just writing a message to say I had solved it lol. While I have your attention how do I use more than one $argv so I can type !Admin Username Level

Thanks
Andy
You cannot use multiple arguments, but a way to work around that is to use a separating sign like | and then split the $argv into two values using SplitToArray

So if you would type: !admin yisc[nl]|0

Then use this to split the values: $splitted_values = SplitToArray ( $argv , "|" );

Then use this to store them: SetUserStoredValue( $splitted_values[0], "Admin", $splitted_values[1] );

Make sure that the splitting value isn't commonly used in usernames, otherwise bad things might happen.
But you can use nearly anything to separate and split them, so should be okay.
THANKYOU that works like a dream.

I had a Driver on my server earlier UserName "supranitrous" in FXR doing stupid speeds in silly time so banned him just to give you the heads up.

Andy
Hi Guys, can't work out what the error is....

EVENT OnPB($userName) # Player event
IF (NumToMSH(GetCurrentPlayerVar("LapTime")) <= NumToMSH($AS3_E)) THEN
cmdLFS("/msg ^7New PB by " . GetCurrentPlayerVar("NickName") . "^7 (" . GetCurrentPlayerVar("Car") . ") - " . NumToMSH(GetCurrentPlayerVar("LapTime")));
ENDIF
ENDEVENT

4/7/2019 1:35:23 AM -> Syntax error: in file ".\default\LFSLapper_1.lpr" at line #521
suspected error in order of the operators
Function 'onpb' script aborted

Line #521 is the IF Line and $AS3_E is a GlobalVar:

GlobalVar $AS3_E;
$AS3_E = MSHToNum("1.48.00");

Thanks in Advance
Andy
I have created the following file:


CatchEvent OnLapperStart()
OnLapperStart_PB();
EndCatchEvent

CatchEvent OnPB( $userName )
OnPB_announce();
EndCatchEvent

Sub OnLapperStart_PB()
### Declare global variable(s) ###
GlobalVar $AS3_E;
### End ###

### Give global variable(s) a value to start with ###
$AS3_E = MSHToNum("1.48.00");
### End ###

writeline ( "DEBUG1: " . $AS3_E );
EndSub

Sub OnPB_announce()
writeline ( "DEBUG2: " . GetCurrentPlayerVar( "LapTime" ) );
writeline ( "DEBUG3: " . NumToMSH( $AS3_E ) );

IF ( NumToMSH( GetCurrentPlayerVar( "LapTime" ) ) <= NumToMSH( $AS3_E ) )
THEN
cmdLFS("/msg ^7New PB by " . GetCurrentPlayerVar("NickName") . "^7 (" . GetCurrentPlayerVar("Car") . ") - " . NumToMSH(GetCurrentPlayerVar("LapTime")));
ENDIF
EndSub

When Lapper is (re)started, this is shown on the console: DEBUG1: 108000
When I drive a PB, this is shown on the console:

DEBUG2: 106080
DEBUG3: 1.48.00

I don't understand why you convert the globalvar from MSHToNum (value shown in DEBUG1) and then convert it from NumToMSH (value shown in DEBUG3) when you are comparing it with the laptime driven (value shown in DEBUG2) that is also converted to NumToMSH.

Most important lesson in this, is to check what value is returned by Lapper (like I did with adding these DEBUG lines) and only convert them if really needed.

The correct script should be like this in my opinion:


CatchEvent OnLapperStart()
OnLapperStart_PB();
EndCatchEvent

CatchEvent OnPB( $userName )
OnPB_announce();
EndCatchEvent

Sub OnLapperStart_PB()
### Declare global variable(s) ###
GlobalVar $AS3_E;
### End ###

### Give global variable(s) a value to start with ###
$AS3_E = "1.48.00";
### End ###

writeline ( "DEBUG1: " . $AS3_E );
EndSub

Sub OnPB_announce()
writeline ( "DEBUG2: " . GetCurrentPlayerVar( "LapTime" ) );
writeline ( "DEBUG3: " . MSHToNum( $AS3_E ) );

IF ( GetCurrentPlayerVar( "LapTime" ) <= MSHToNum( $AS3_E ) )
THEN
cmdLFS( "/msg ^7New PB by " . GetCurrentPlayerVar("NickName") . "^7 (" . GetCurrentPlayerVar("Car") . ") - " . NumToMSH(GetCurrentPlayerVar("LapTime")));
ENDIF
EndSub

Quote from Yisc[NL] :I don't understand why you convert the globalvar from MSHToNum (value shown in DEBUG1) and then convert it from NumToMSH (value shown in DEBUG3) when you are comparing it with the laptime driven (value shown in DEBUG2) that is also converted to NumToMSH.

Hi Yisc, these scripts are very old when I was basically in the very early learning stages and I am trying to sort this type of mistake out which will help Lapper run faster. Thanks for your FULL answer its appeciated.

Andy
Hi Guys, I have extracted my Database into EXCEL is their a formula I can use to convert PBLapTime 101750 NumToMSH as in 1:41:75?

Answer: Divide by 86400000 and format m:ss.00

Andy
Hi Guys,

QUESTION: Is it possible to "openPrivTextButton" with text carried through so when text box opens in LFS its already populated with for example "/spec" so only userName is needed to be typed? Looked in changes and docs but can't find anything.

Andy
That's not possible.
Quote from LakynVonLegendaus :That's not possible.

Thank You

Hi Guys, found another thing that won't work and cannot see whats wrong with it...

cmdLFS("/msg ^7ADMIN: " . GetPlayerVar($argv, "NickName") . " ^6READ MESSAGE BELOW...");

Andy
Quote from Andy King :Hi Guys, found another thing that won't work and cannot see whats wrong with it...

cmdLFS("/msg ^7ADMIN: " . GetPlayerVar($argv, "NickName") . " ^6READ MESSAGE BELOW...");

Andy

What kind of error do you get?
What happens before this command is executed?
Try to debug every step along the way, like:

- does the script reach the place where cmdLFS should be executed
- does $argv have a value
- if $argv has a value, does this give a value: GetPlayerVar($argv, "NickName")

Being able to write code is one of the skills needed to build scripts, but being able to debug your code is as equally important.

All of this said with respect and trying to educate you and/or other viewers.
Quote from Yisc[NL] :All of this said with respect and trying to educate you and/or other viewers.

Hi Yisc, totally understood and I forgot to say sorry. The cmd is working just not displaying NickName in sentence sorry. argv is username typed by me !Read John Doe

Andy
Hi Guys, I'm sorry but the stupid thing and all the others are now working again AAARRRGGGHHH lol SORRY

Andy
Quote from Andy King :Hi Guys,

QUESTION: Is it possible to "openPrivTextButton" with text carried through so when text box opens in LFS its already populated with for example "/spec" so only userName is needed to be typed? Looked in changes and docs but can't find anything.

Andy

Long while ago, I made a "Race Control Manager", which included section for messages, penalties, flags, etc.



Is the bit I've done with penalties what you're looking for?
Hi Guys, I'm having issues with StoredValueDbs so can someone confirm where the following variables should be stored in my Lapper.lpr file......

$AdminFile = "./Text_Files/Admin_1.txt"; # Name of the file containing admin lfsname player
$StoredValueDbs = "Databases/Racing_Data"; # Name of the database in which additional values are stored
$TrackInfoFile = "trackInfo.cfg"; # Path to the TrackInfoFile used to compare splits
$TCPmode = true; # Connection to LFS in UDP mode or TCP mode
$EnableRegisterWeb = false; # When set to "true" your LFS Server is displayed on the FRH Team website

Thanks in Advance

Andy
Check the original LFSLapper.lpr file? Looking
Quote from sinanju :Long while ago, I made a "Race Control Manager", which included section for messages, penalties, flags, etc.



Is the bit I've done with penalties what you're looking for?

Yes very interested in seeing a copy of this Race Manager Sinanju

Andy
Quote from LakynVonLegendaus :Check the original LFSLapper.lpr file? Looking

Hi I did that first and its not in any Event so puzzled me and I have an issue with things not writing to the StoredValueDbs so was questioning it.

Andy
Race Control Manager - HERE

As far as I'm aware, anything you want stored in a lapper database that isn't the top times or top drift scores, are ALL stored in the storedvalue.dbs when you use something like "SetCurrentPlayerVar".

All that does, is make another field that the database saves under your username, with the var name you saved it as.

I'm not sure that you can create another database.
Are you actually looking for stuff manually? Smile Any text editor can search for keywords for you. Usually Ctrl+F.

What you are looking for is in the original LFSLapper.lpr file of Lapper v7.0.6.3 at line 171. It's not inside of any event because these vars need to be checked immediately after Lapper starts/reloads, not when something triggers an event.
Quote from LakynVonLegendaus :Are you actually looking for stuff manually? Smile Any text editor can search for keywords for you. Usually Ctrl+F.

What you are looking for is in the original LFSLapper.lpr file of Lapper v7.0.6.3 at line 171. It's not inside of any event because these vars need to be checked immediately after Lapper starts/reloads, not when something triggers an event.

Yes I saw that but both myself and Yisc cannot work out why a script that works fine for him will not add data to my database so we are fault finding why my database is being ignored by certain scripts but fine with others when theirs no logical reason we can see.

Andy
Hi Guys, all of a sudden about 4 hours ago I'm getting the errors below lots on the server being used anyone else got Pubstat issues?

Error on retreiving pubstat Pst info
Error on retreiving pubstat info

Andy
Hi Guys, can someone help me with how to add u username to a text.txt file with each added on a separate line as tried for hours with no joy.

Andy

FGED GREDG RDFGDR GSFDG