The online racing simulator
[Solved] Drift meter doesnt show scores
Got another problem , My drift meter does not show drift scores and l think the problem is i did not use "CatchEvent OnDriftScore( $userName )" and if l do lfs lapper crush.How can use "CatchEvent " in a sub or command section? and if there is another way to show drift scores can u please tell me.

Thank You.

EDIT: Moderator note: Create a new topic for each new question.
Please post the code you are working.

If you create a new Script ( New LPR file). you must use CatchEvent/EndCatchEvent for every Event.

To display driftscoring you have to use the OnDriftScore event first.
Because that event will execute everytime you ended a drift/slide.

After That you can call a Sub.

CatchEvent OnDriftScore($userName) # Player event
Driftscore($userName);
EndCatchEvent

Sub DriftScore($userName)
#Blaaaaah
EndSub

But as i said in the first line. Post your code, so we can help you.
Dont mind my "IF" will work on that later
Here is my code:

CatchEvent OnMSO( $userName, $text ) # Player event
$idxOfFirstSpace = indexOf( $text, " ");
IF( $idxOfFirstSpace == -1 ) THEN
$command = $text;
$argv = "";
ELSE
$command = subStr( $text,0,$idxOfFirstSpace );
$argv = trim( subStr( $text,$idxOfFirstSpace ) );
ENDIF

SWITCH( $command )
CASE "!twin":
IF (9 > 7 )
THEN

$me = GetCurrentPlayerVar("NickName");
$behind = GetPlayerVar( GetCurrentPlayerVar( "UNameBehind" ),"NickName" );
$front = GetPlayerVar( GetCurrentPlayerVar( "UNameBefore" ),"NickName" );

globalMsg( langEngine( "%{main_twin}%" , $me,$behind));

IF (9 >7)

THEN

$AngleVelocity = GetCurrentPlayerVar( "AngleVelocity" );
$DriftScore = (GetCurrentPlayerVar( "DriftScore" ) * 2);
$LastDriftScore = (GetCurrentPlayerVar( "LastDriftScore" ) *2);

openPrivButton( "circledrift_back",97,57,165,165,1,-1,0,"^1•"); # red background
openPrivButton( "circledrift_back1",100,60,159,159,1,-1,0,"^3•"); # yellow foreground
openPrivButton( "circledrift_thisdrift",169,126,20,5,1,-1,0,"^1This Drift"); # red
openPrivButton( "circledrift_lastdriftscore",169,128,20,12,1,-1,0,langEngine( "%{circledrift_score}%" , $LastDriftScore ) );
openPrivButton( "circledrift_lapscore",169,148,20,15,1,-1,0,langEngine( "%{circledrift_combo}%" , $DriftScore ) );
openPrivButton( "circledrift_maxscore",169,159,20,5,1,-1,0,"^0Lap Score"); # black

ELSE
privMsg( langEngine( "%{main_nonearcars}%" ) );

ENDIF


IF( $AngleVelocity < 0 )

THEN
$AngleVelocity = -$AngleVelocity ;

SetCurrentPlayerVar("Angle_Reverse",$AngleVelocity);

closePrivButton( "circledrift_anglerev&circledrift_angle");
openPrivButton( "circledrift_anglerev",169,136,20,17,1,-1,0,langEngine( "%{circledrift_anglerev}%" , GetCurrentPlayerVar( "Angle_Reverse")));

ELSE

closePrivButton( "circledrift_anglerev&circledrift_angle");
openPrivButton( "circledrift_angle",169,136,20,17,1,-1,0,langEngine( "%{circledrift_angle}%" , $AngleVelocity ));

ENDIF


IF (7 > 6)

THEN

openPrivButton( "circledrift_lastdriftscore",169,128,20,12,1,-1,0, "^10" );
openPrivButton( "circledrift_lapscore",169,148,20,15,1,-1,0,"^10" );

ELSE

privMsg( langEngine( "%{main_nonearcars}%" ) );

ENDIF

IF (GetCurrentPlayerVar( SessLaps ) <1)
THEN
openPrivButton( "circledrift_angle",164,137,30,14,1,-1,0,"^1> Scores not saved <%at% " );
openPrivButton( "circledrift_anglerev",164,137,30,14,1,-1,0," %at%^1> on your outlap <" );
ELSE
openPrivButton( "circledrift_angle",164,137,30,14,1,-1,0,"^1> Too slow <%at% " );
openPrivButton( "circledrift_anglerev",164,137,30,14,1,-1,0," %at%^1> lost scores <" );
ENDIF


ELSE
privMsg( langEngine( "%{main_nonearcars}%" ) );

ENDIF


ELSE
privMsg( langEngine( "%{main_nonearcars}%" ) );
ENDIF
BREAK;
ENDSWITCH
EndCatchEvent
-
(mgunig) DELETED by mgunig : Does not work
CatchEvent/EndCatchEvent doesnt seem to work if I put it at the begining of the script
Have you add the script in Includes/Addonsused.LPR?
Also check the errorfiles.
Yes,the script works but the only problem is it does not catch the drift scores.

See attached photo
Attached images
noscore.png
You're not using the CASE command properly. Its basically there as a command to do something (usually simple), such as output a button or start a sub-routine WHEN you type in the trigger word - in this case !twin.

Think of the !top command - once you type in !top, you get a list of the top best times.
It happens once. It normally does not update. If someone does a new faster time while you're looking at the top table, you have to type in !top again, for table to refresh.

Yours should have been something like

CASE "!twin":
openPrivButton( "twin_message",([i]dimensions here[/i]),"Twin Drift System now enabled" );
DoTwinSub();
BREAK;

so when you type !twin, lapper knows to then start the sub called DoTwinSub

as in

Sub DoTwinSub(blah, blah)
$me = GetCurrentPlayerVar("NickName");
$behind = GetPlayerVar( GetCurrentPlayerVar( "UNameBehind" ),"NickName" );
$front = GetPlayerVar( GetCurrentPlayerVar( "UNameBefore" ),"NickName" );

your code in here.....

EndSub

Why do you think you need the $me/$behind/$front variables?

Also. I don't understand the IF statements....
IF (9 > 7)
IF (7 > 6)

9 is always going to be more than 7 and 7 is always going to be more than 6.

What do the numbers indicate?

Now, if you meant
IF ($behind > $me) - or - IF ($behind < $me)
that would make more sense, although may not work, as lapper has already worked out the UNameBehind and UNameBefore users.

If I was making a twin drift system, then there would be 1 question; do i want to give users/admin option to switch twin system off/on, or would it be on all the time?

If an option to turn off/on, then you would have to start playing about with GlobalVars and a simple CASE command to get started - complicated subject. if you want to see it in action, look at Yisc[NL]'s pitboard lapper script for a GlobalVar that has "off" or "on" set.

In either case, all the code should be within the Event OnDriftScore( $userName ) section.

You can either use the section within the lfslapper.lpr file, or make your own add-on, in which case you would need to Catch the Event, as in CatchEvent OnDriftScore( $userName ).

If you went down the GlobalVars route, then you would need another IF-ENDIF section, which could be done various ways, as in,
IF enabled,
THEN...

- or -

IF not enabled
THEN use usual code,
ELSE use this code

....etc

====================

There are probably only a handful of people who use lapper that could make a twin drift system, and I'm not one of them. Not only that, all but 2 of these people don't actually give advice or put their code on the forum, and even if I could make a twin drift system, I wouldn't make it public.

This is a fairly good feature to have to 'sell' your server, and have people use your server rather than someone else's, so why give it away?
Hi Sinanju

Don't worry about
If (9 > 7)
If (7 > 6)
I only used that for testing, it does mean anything.

Will restart the script again and see how it goes,l only have 1 question ,is it possible to put CatchEvent onDriftScore under Sub and EndSub?

Thank you.
You can't put an Event under a sub, nor should you put a sub under an Event.

But you can call a sub from within an Event.

For an example, look at the OnConnectClose sub in the Event OnConnect - you'll see that the sub is called within the event (at end of a button - and works when you press that button), but the sub is outwith the Event itself (comes after EndEvent).

Before you start getting too involved in everthing, the very first thing you should be doing is seeing if you can get the driftscores of 2 drivers onto the screen at the same time.

Forget how things will look, angles, adding scores, who's in front/behind. Just try get 2 drivers $LastDriftScore to show on screen at same time.

You won't be able to do this with private buttons, and if you use global buttons, how does lapper know how to differentiate between the 2 drivers, and not get scores mixed up?

I suspect that you may have to look at using openButton AND getListOfPlayers AND the FOREACH loop.

Following bit of code is something that I amended slightly from code that Bass-Driver gave me for something drift related, and gives you an idea of what may be required...

CatchEvent OnDriftScore($userName) # Player event
$hgt = 50;
$Drivers = getListOfPlayers("N");
FOREACH( $Var IN $Drivers ) #For each player in the $drivers list
IF (GetPlayerVar($maVar["value"], "OnTrack") == 1)
THEN #IF player is on track , display his name and totaldriftscore
$hgt=$hgt+4; #Buttonheight + 4 (has to be used else your second driver will just be placed and overwrite 1st driver)
openButton($Var["value"],"driver_Ply_".$maVar["value"],3,$hgt,18,4,1,-1,96,"".Getplayervar($maVar["value"],"NickName"));
openButton($Var["value"],"driver_DScore_".$maVar["value"],21,$hgt,10,4,1,-1,32,"^3".Getplayervar($maVar["value"],"DriftScore"));
ENDIF
ENDFOREACH
EndCatchEvent

I will try that, I want to create twin drift meter first then l will work on scores ,right now l want it to diplay my score just to see if it is working.

Thank you Bro for your help XD,will ask if l have any problems.
This thread is closed

FGED GREDG RDFGDR GSFDG