NOTE: This code is for Lapper version 5.844, with the supplied Patch file applied
Hi all,
As a follow on from the Custom Penalties thread, here is the code to add penalties for racers who use Car Resets. This comprises a patch to the stock 5.844 source, along with the code below to be added at the bottom of the LFSLapper.lpr file.
The reasoning behind this patch is that we wanted to ensure that someone who used car resets during a race did not get an unfair advantage by having new tyres, damage repair etc over a racer who has run a clean race but who may be suffering from wear and tear of the tyres or car.
To that end, the code will allocate a Drive Through penalty when a reset is used during a race, but this is substituted with a 30 second time penalty on the last lap of a race as a Drive Through on the last lap is automatic disqualification.
The code also allows for different penalties if the racer uses the reset option too many times (the $MaxCarResets parameter in the LFSLapper.lpr file) where you can /spec them or whatever by changing the lfsCmd in the OnMaxCarResets Event.
To use the attached Patch file, you will either need to use TortoiseSVN and apply it, or just go through the source manually, as it's all pretty self explanatory.
Hi all,
As a follow on from the Custom Penalties thread, here is the code to add penalties for racers who use Car Resets. This comprises a patch to the stock 5.844 source, along with the code below to be added at the bottom of the LFSLapper.lpr file.
The reasoning behind this patch is that we wanted to ensure that someone who used car resets during a race did not get an unfair advantage by having new tyres, damage repair etc over a racer who has run a clean race but who may be suffering from wear and tear of the tyres or car.
To that end, the code will allocate a Drive Through penalty when a reset is used during a race, but this is substituted with a 30 second time penalty on the last lap of a race as a Drive Through on the last lap is automatic disqualification.
The code also allows for different penalties if the racer uses the reset option too many times (the $MaxCarResets parameter in the LFSLapper.lpr file) where you can /spec them or whatever by changing the lfsCmd in the OnMaxCarResets Event.
To use the attached Patch file, you will either need to use TortoiseSVN and apply it, or just go through the source manually, as it's all pretty self explanatory.
# *** PUT THIS IN YOUR LFSLapper.lpr file ***
############################
#Actions to do on Car Reset#
############################
$MaxCarResets = 6; # Set to a positive number to limit number of race resets
Event OnMaxCarResets() # Spectate if player has used car reset more than the max
globalMsg( langEngine( "%{main_maxreset}%" , GetCurrentPlayerVar( "NickName" ) ) );
cmdLFS( "/spec " . GetCurrentPlayerVar( "Username" ) );
EndEvent
Event OnCarReset() # Do something when the car resets
globalMsg( langEngine( "%{main_oncarreset}%", GetCurrentPlayerVar( "NickName" ) ) );
IF( $ConfVar["MaxCarResets"] > 0 )
THEN
openPrivButton( "carres_warn",50,60,100,15,5,4,16, langEngine( "%{main_specwarn}%" ) );
openPrivButton( "carres_msg1",50,75,100,10,5,4,16,langEngine( "%{main_resetrest}%",($ConfVar["MaxCarResets"] - (GetCurrentPlayerVar( "NumCarResets" )+1))));
privdelayedcommand( 4, ApplyCarResetPenalty);
ELSE
privdelayedcommand( 1, ApplyCarResetPenalty);
ENDIF
EndEvent
Sub ApplyCarResetPenalty()
IF( getLapperVar( "RaceLapsLeft" ) <= 1 )
THEN
IF( (GetCurrentPlayerVar( "penaltynew") < 5))
THEN
cmdLFS( "/p_30 " . GetCurrentPlayerVar( "Username" ) );
ENDIF
ELSE
IF( (GetCurrentPlayerVar( "penaltynew") < 1))
THEN
cmdLFS( "/p_dt " . GetCurrentPlayerVar( "Username" ) );
ENDIF
ENDIF
EndSub