It's no big deal.
One way, which I've done, would be to set up a GlobalVar such as $driftmeter_on_off
Event OnLapperStart()
GlobalVar $driftmeter_on_off; # For turning driftmeter on and off
$driftmeter_on_off = "on"; # driftmeter option turned on, unless driver wants to switch off
EndEvent
So the driftmeter will show, unless offered the choice for it not to.
CASE "!drift":
OnClickDriftQuery(0,0);
BREAK;
So driver types
!drift and
Sub OnClickDriftQuery( $KeyFlags,$id )
openPrivButton( "dq_instruct",65,66,70,9,9,-1,32,"^6Do you wish to use the Drift Meter?" );
openPrivButton( "dq_instruct1",65,75,70,6,6,-1,32,"^8(Drifting Scoreboard Facility)" );
openPrivButton( "dq_driftyes",80,85,18,10,10,-1,32," Yes ",OnClickYesDrift );
openPrivButton( "dq_driftno",102,85,18,10,10,-1,32," No ",OnClickCloseDM );
EndSub
If they want
NO, then
Sub OnClickCloseDM( $KeyFlags,$id )
SetCurrentPlayerVar( "drift_on_off","off" ); # Set drift "off"
closeButtonRegex (GetCurrentPlayerVar("UserName"), "dq_*"); # close drift query buttons
closeButtonRegex (GetCurrentPlayerVar("UserName"), "drift_*"); # closedriftboard
EndSub
This closes the query buttons and sets your global variable to off.
If they want
YES, then
Sub OnClickYesDrift( $KeyFlags,$id )
SetCurrentPlayerVar( "drift_on_off","on" ); # Set drift "on"
closeButtonRegex (GetCurrentPlayerVar("UserName"), "dq_*"); # close drift query buttons
EndSub
The global variable is set to on, because the driver may have previously set to off previously while still on track.
So if Yes, when a driftscore is made (and even a BF1 in a race will make drifts if driver slides car), you first query if the drift scoreboard is on.
Event OnDriftScore( $userName ) # This is the section for displaying the Drift Meter
IF ( GetCurrentPlayerVar( "drift_on_off") == "on" )
THEN
> blah, deblah, deblah
ENDIF
EndEvent
Because you set global variable at very start to be on, and you query when a drift is done, and IF statement is true, then all drift scores will show. If player turned it off, then the IF statement will not be true, so nothing happens (shows).
You do this IF true query for every EVENT Ondrift, such as
Event OnGoodDrift( $userName ) # Player event
IF ( GetCurrentPlayerVar( "drift_on_off") == "on" )
THEN
> blah
ENDIF
EndEvent
or
Event OnDriftTooLow( $userName ) # Player event
IF ( GetCurrentPlayerVar( "drift_on_off") == "on" )
THEN
> blah
ENDIF
EndEvent
etc, etc.
Then all you have to do, is go through all the events where driver leaves track, such as pitting, spectating, leaving, etc, and turn buttons off (but not touch your global variable), and when they rejoin, turn buttons back on.
If driver leaves server, and returns, the global variable is set to on when they join, so they have to go through the process of turning off again.
I've done a big explanation here, as this global variable (with IF query) is a good way of doing stuff where you want things to show/not show. I've used this for my new Pace Notes add-on.
If driver goes through a Zone, which i've set up in RegisterZoneAction, then each zone sub has the IF on query. If not switched on, then driver doesn't see anything. Its as if the RegisterZoneAction is not there. But if it is on, then driver sees a Pace Note.
The global variable i've shown is great for easy things like the driftmeter (as detailed) and Pace Notes, and such. Where it gets difficult, is when you want to save the on/off settings, then you have to start dealing with set/get variables and values - have a look at Yisc's pitboard.lpr if you want to see how it's done properly.