Hi
I've been playing about for a bit trying to get another add-on for lapper, a bit like the standard
<?php
RegisterNodeAction( "SO1R" , 201 , DisplaySpeed,"" );
?>
except changed it slightly so that lapper saves your speed, and if you go faster next lap, then speed display text changes to green, and if you go slower, then it displays text in red.
<?php
CatchEvent OnLapperStart()
RegisterNodeAction( "SO2" , 77 , SpeedTrap1,"" );
RegisterNodeAction( "SO2" , 213 , SpeedTrap2,"" );
EndCatchEvent
Sub SpeedTrap2( $userName )
$userName = GetCurrentPlayerVar( "UserName" );
$car = GetCurrentPlayerVar("Car");
$track = getLapperVar("ShortTrackName");
$TopSpeed = ToMph( GetCurrentPlayerVar( "InstantSpeed" ));
IF ( $TopSpeed > GetStoredValue($userName . ",ST2_TopSpeed," . $track . "," . $car))
THEN
openPrivButton( "st2_text",1,16,20,5,3,4,80, langEngine( "%{main_st_faster}%" , $TopSpeed ) );
SetStoredValue( $userName . ",ST2_TopSpeed," . $track . "," . $car,$TopSpeed );
ELSE
openPrivButton( "st2_text",1,16,20,5,3,4,80, langEngine( "%{main_st_slower}%" ,$TopSpeed) );
ENDIF
EndSub
Lang "EN"
main_st_faster = "^0Radar Trap: ^2{0} mph";
main_st_slower = "^0Radar Trap: ^1{0} mph";
EndLang
?>
This bit of coding is working ok.
However, what I'm really wanting, is for the speed to show (in plain text colour), but also to show how much faster or slower (in green/red text) next to this.
For example;
Lap1
RadarTrap = 67.21mph
Lap2
RadarTrap = 68.31mph (
1.10mph)
Lap3
RadarTrap = 66.41mph
(0.80mph)
So then I tried (amongst other things)
<?php
Sub SpeedTrap1( $userName )
$userName = GetCurrentPlayerVar( "UserName" );
$car = GetCurrentPlayerVar("Car");
$track = getLapperVar("ShortTrackName");
$TopSpeed = ToMph( GetCurrentPlayerVar( "InstantSpeed" ));
$OldTopSpeed = GetUserStoredValue( $userName, "OldTopSpeed" );
$STdiff = $OldTopSpeed - $TopSpeed
IF ( $TopSpeed > GetStoredValue($userName . ",ST1_TopSpeed," . $track . "," . $car))
THEN
openPrivButton( "st1_text",1,16,20,5,3,4,80, langEngine( "%{main_st_faster}%" , $TopSpeed ));
SetStoredValue( $userName . ",ST1_TopSpeed," . $track . "," . $car,$TopSpeed );
SetUserStoredValue( $userName, "OldTopSpeed");
ELSE
openPrivButton( "st1_text",1,16,20,5,3,4,80, langEngine( "%{main_st_slower}%" ,$TopSpeed));
ENDIF
EndSub
?>
where I was going to put
$STdiff within the button at the end, like
<?php
openPrivButton( "st1_text",1,16,20,5,3,4,80, langEngine( "%{main_st_faster}%" , $TopSpeed,$STdiff ));
?>
and it would be this
$STdiff that would be put in brackets.
I can't get it to work. Keep getting error messages like
3/31/2011 8:36:48 PM -> Syntax error in cfg file "./speedtraps.lpr" at line #194
suspected error in order of the operators
Function 'speedtrap1' script aborted
This error is to do with the line: $STdiff = $OldTopSpeed - $TopSpeed
Where am I going wrong?