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