Greetings
I am setting up an open drifting server.
I want to restrict visitors' cars with the following requirements:
- Allowed Vehicle Types: `Touring_Car`, `Saloon_Car`, `GT`
- Tyre Compounds: Front and rear must both be `Super`
Any vehicle types or tyre compounds that do not meet the above conditions will result in the player being moved to spectators and shown a text window instructing them to change their car and tyre compound to an allowed one.
Question:
1. What command in Lapper can be used to check the joining player's vehicle type?
There was some API -thread, but that i did not understant, how to change it to work for me.
Under here is part from that code where car classes are numbered.
public enum Class
{
Object, //0: Object
Touring_Car, //1: Touring car
Saloon_Car, //2: Saloon car
Buggy, //3: Buggy
Formula, //4: Formula
GT, //5: GT
Kart, //6: Kart
Bike, //7: Bike
Van, //8: Van
Truck, //9: Truck
Formula_1, //10: Formula 1
Formula_SAE //11: Formula SAE
};
Under here are my lapper lines.
Haven't yet had time to test it (, because when you have children and want to have oranges you get bananas).
##############################
# Allowed cars on the server #
##############################
# Vehicle Class
#0: Object
#1: Touring car
#2: Saloon car
#3: Buggy
#4: Formula
#5: GT
#6: Kart
#7: Bike
#8: Van
#9: Truck
#10: Formula 1
#11: Formula SAE
#################################
Event OnNewPlayerJoin( $userName )
$modinfo = getmoddedcarinfo($userName);
IF (($modinfo == "OBJECT" ) || ($modinfo == "BUGGY" ) || ($modinfo == "FORMULA" ) || ($modinfo == "KART" ) || ($modinfo == "BIKE" ) || ($modinfo == "VAN" ) || ($modinfo == "TRUCK" ) || ($modinfo == "FORMULA 1" ) || ($modinfo == "FORMULA SAE" )
THEN
cmdLFS( "/spec " . GetCurrentPlayerVar("UserName") );
openPrivButton( "classspec",50,35,100,15,5,15,32, "^7You have been moved to spectators because your ^1car ^7does not meet the server ^1requirements.");
openPrivButton( "classchange",50,50,100,15,5,15,32, "^7Allowed vehicles ^7on the server are ^3Saloon, Touring Car, or GT" );
ENDIF
EndEvent
Change $modinfo to $modinfo["class"]
So in your case:
<?php ##IF the player does not meet the required vehicleclass. IF(($modinfo["class"] != "GT" ) && ($modinfo["class"] != "Saloon_Car") && ($modinfo["class"] != "Touring_Car")) THEN
cmdLFS( "/spec " . GetCurrentPlayerVar("UserName") ); openPrivButton( "classspec",50,35,100,15,5,15,32, "^7You have been moved to spectators because your ^1car ^7does not meet the server ^1requirements."); openPrivButton( "classchange",50,50,100,15,5,15,32, "^7Allowed vehicles ^7on the server are ^3Saloon, Touring Car, or GT" );
ENDIF ?>
List of correct names of vehicleclasses Object, //0: Object Touring_Car, //1: Touring car Saloon_Car, //2: Saloon car Buggy, //3: Buggy Formula, //4: Formula GT, //5: GT Kart, //6: Kart Bike, //7: Bike Van, //8: Van Truck, //9: Truck Formula_1, //10: Formula 1 Formula_SAE //11: Formula SAE
Made the changes.
I still need to exclude front-wheel drive cars. Is there a query for the drivetrain?
is it something like
$modinfo["drive"] = getmoddedcarinfo($userName);
... and then the same if-then logic can be applied in the same way.
## Allowed Drivetrains on the server
## Drivetrain: Rear Wheel Drive [RWD] or Four wheel drive AWD
## List of Drivetrains
## No_drive, //0: No_drive
## Rear_wheel_drive, //1: RWD
## Front_wheel_drive, //2: FWD
## Four_wheel_drive, //3: AWD
Code:
----
Event OnNewPlayerJoin( $userName )
## Allowed tyres on the server
## Tyre types: Super or Normal
## List of Tyre types
## Slick_R1, //0: R1
## Slick_R2, //1: R2
## Slick_R3, //2: R3
## Slick_R4, //3: R4
## Road_super, //4: Super
## Road_normal, //5: Normal
## Hybrid, //6: Hybrid
## Knobbly, //7: Knobbly
$OTFR = GetCurrentPlayerVar( "OldTyreFrontRight" ); # Vanha Rengas etu oikea
$OTRR = GetCurrentPlayerVar( "OldTyreRearRight" ); # Vanha Rengas taka oikea
$TFR = GetCurrentPlayerVar( "TyreFrontRight" ); # Rengas etu oikea
$TRR = GetCurrentPlayerVar( "TyreRearRight" ); # Rengas taka oikea
$FWAdj = GetCurrentPlayerVar( "FrontWheelsAdj" ); # Etu rengas säätö?
$RWAdj = GetCurrentPlayerVar( "RearWheelsAdj" ); # Taka rengas säätö?
IF (($OTRR != "TYRE_ROAD_SUPER" ) && ($OTFR != "TYRE_ROAD_SUPER" ) && ($TRR != "TYRE_ROAD_SUPER" ) && ($TFR != "TYRE_ROAD_SUPER" ) && ($OTRR != "TYRE_ROAD_NORMAL" ) && ($OTFR != "TYRE_ROAD_NORMAL" ) && ($TRR != "TYRE_ROAD_NORMAL" ) && ($TFR != "TYRE_ROAD_NORMAL" ))
THEN
cmdLFS( "/spec " . GetCurrentPlayerVar("UserName") );
openPrivButton( "tyrespec",50,35,100,15,5,15,32, "^7You have been moved to spectators because your ^1disallowed ^7tyres");
openPrivButton( "tyrechange",50,50,100,15,5,15,32, "^7Please change your tyres to ^3Normal ^7or ^3Super" );
# openPrivButton( "tyrechange",50,50,100,15,5,15,32, "^7Please change rear ^7and front ^7tyres to ^3Super" );
ENDIF
## Allowed cars on the server
## Vehicle class: saloon, touring car or GT
## List of correct names of vehicleclasses
## Object, //0: Object
## Touring_Car, //1: Touring car
## Saloon_Car, //2: Saloon car
## Buggy, //3: Buggy
## Formula, //4: Formula
## GT, //5: GT
## Kart, //6: Kart
## Bike, //7: Bike
## Van, //8: Van
## Truck, //9: Truck
## Formula_1, //10: Formula 1
## Formula_SAE //11: Formula SAE
$modinfo["class"] = getmoddedcarinfo($userName);
IF(($modinfo["class"] != "GT" ) && ($modinfo["class"] != "Saloon_Car") && ($modinfo["class"] != "Touring_Car"))
THEN
cmdLFS( "/spec " . GetCurrentPlayerVar("UserName") );
openPrivButton( "classspec",50,35,100,15,5,15,32, "^7You have been moved to spectators because your ^1car ^7does not meet the server ^1requirements.");
openPrivButton( "classchange",50,50,100,15,5,15,32, "^7Allowed vehicles ^7on the server are ^3Saloon, Touring Car, or GT" );
ENDIF
EndEvent
The list of variables you can use with $modinfo = GetModInfo($userName);
list of variables: status,id,name,descriptionshort,description,userid,username,wip publishedat,numdownloads,currusage,rating,numratings,staffpick tweakmod,version,lastdownloadedat,class,ev icecc,icenumcylinders,icelayout,evredLine,drive,shifttype power,maxpowerrpm,mass,bhp,powerweightratio,bhpton,fueltanksize
To get info about the Drivetrain is $modinfo["drive"] or $modinfo["drivetrains"]
Let me know if you get any information out of it. Because i might see a small typo in the sourcecode.
public enum Class { Object, //0: Object Touring_Car, //1: Touring car Saloon_Car, //2: Saloon car Buggy, //3: Buggy Formula, //4: Formula GT, //5: GT Kart, //6: Kart Bike, //7: Bike Van, //8: Van Truck, //9: Truck Formula_1, //10: Formula 1 Formula_SAE //11: Formula SAE };
public enum iceLayout { Inline, //0: inline Flat, //1: flat V //2: V Shape };
Greetings.
I am using LFS 0.7F and LFSLapper V7.0.9.6
I got this lapper code as an heritance from friend of mine whom has been developing drifting ai.
I went and registered my lapper to get modinfo command working, (https://www.lfs.net/account/api).
I did not figured how to get lapper to go pack in folder tree.
Location of secret key file: C:\LFS\LFSLapper\bin\default\includes\myInc.lpr
Location of my lapper file: C:\LFS\LFSLapper\bin\servut\OPEN_drifting_server.lpr
So i just added these lines on start of my lapper.
$RestAPIClientID = "GoGetYourOwn";
$RestAPIClientSecret = "L9VeryLongGiprishMyCode8x";
Old lapper code mostly works (tyre stuff), but i do not get modinfo"class" and drivetrain -querys move player to spectator when driving FWD VAN.
Here is the code
----
#############################################################################
# You are free to choose any car on the server, as long as it meets the following requirements:#
# - Vehicle class: saloon, touring car or GT #
# - Drivetrain: Rear Wheel Drive [RWD], All_Wheel_Drive [AWD] or Four_wheel_drive [4WD]
# - TYRES #
# * Super #
# * Normal #
# * Hybrid #
#############################################################################
## Allowed tyres on the server
## Tyre types: Super or Normal or Hybrid
## List of Tyre types
## Slick_R1, //0: R1
## Slick_R2, //1: R2
## Slick_R3, //2: R3
## Slick_R4, //3: R4
## Road_super, //4: Super
## Road_normal, //5: Normal
## Hybrid, //6: Hybrid
## Knobbly, //7: Knobbly
Event OnNewPlayerJoin( $userName )
$OTFR = GetCurrentPlayerVar( "OldTyreFrontRight" ); # Vanha Rengas etu oikea
$OTRR = GetCurrentPlayerVar( "OldTyreRearRight" ); # Vanha Rengas taka oikea
$TFR = GetCurrentPlayerVar( "TyreFrontRight" ); # Rengas etu oikea
$TRR = GetCurrentPlayerVar( "TyreRearRight" ); # Rengas taka oikea
$FWAdj = GetCurrentPlayerVar( "FrontWheelsAdj" ); # Etu rengas säätö?
$RWAdj = GetCurrentPlayerVar( "RearWheelsAdj" ); # Taka rengas säätö?
IF (($OTRR != "TYRE_ROAD_SUPER" ) && ($OTFR != "TYRE_ROAD_SUPER" ) && ($TRR != "TYRE_ROAD_SUPER" ) && ($TFR != "TYRE_ROAD_SUPER" ) && ($OTRR != "TYRE_ROAD_NORMAL" ) && ($OTFR != "TYRE_ROAD_NORMAL" ) && ($TRR != "TYRE_ROAD_NORMAL" ) && ($TFR != "TYRE_ROAD_NORMAL" ))
THEN
cmdLFS( "/spec " . GetCurrentPlayerVar("UserName") );
openPrivButton( "tyrespec",50,35,100,15,5,15,32, "^7You have been moved to spectators because your ^1disallowed ^7tyres");
openPrivButton( "tyrechange",50,50,100,15,5,15,32, "^7Please change your tyres to ^3Normal ^7or ^3Super" );
# openPrivButton( "tyrechange",50,50,100,15,5,15,32, "^7Please change rear ^7and front ^7tyres to ^3Super" );
ENDIF
## Allowed cars on the server
## Vehicle class: saloon, touring car or GT
## List of correct names of vehicleclasses
## Object, //0: Object
## Touring_Car, //1: Touring car
## Saloon_Car, //2: Saloon car
## Buggy, //3: Buggy
## Formula, //4: Formula
## GT, //5: GT
## Kart, //6: Kart
## Bike, //7: Bike
## Van, //8: Van
## Truck, //9: Truck
## Formula_1, //10: Formula 1
## Formula_SAE //11: Formula SAE
$modinfo["class"] = getmoddedcarinfo($userName);
IF(($modinfo["class"] != "GT" ) && ($modinfo["class"] != "Saloon_Car") && ($modinfo["class"] != "Touring_Car"))
THEN
cmdLFS( "/spec " . GetCurrentPlayerVar("UserName") );
openPrivButton( "classspec",50,35,100,15,5,15,32, "^7You have been moved to spectators because your ^1car ^7does not meet the server ^1requirements.");
openPrivButton( "classchange",50,50,100,15,5,15,32, "^7Allowed vehicles ^7on the server are ^3Saloon, Touring Car, or GT" );
ENDIF
## Allowed Drivetrains on the server
## Drivetrain: Rear Wheel Drive [RWD] or Four wheel drive AWD
## List of Drivetrains
## No_drive, //0: No_drive
## Rear_wheel_drive, //1: RWD
## Front_wheel_drive, //2: FWD
## All_Wheel_Drive_AWD, //3: All-Wheel Drive
## Four_wheel_drive, //4: 4WD
$modinfo["drive"] = getmoddedcarinfo($userName);
IF(($modinfo["drive"] != "RWD" ) && ($modinfo["drive"] != "AWD") && ($modinfo["drive"] != "4WD"))
THEN
cmdLFS( "/spec " . GetCurrentPlayerVar("UserName") );
openPrivButton( "classspec",50,35,100,15,5,15,32, "^7You have been moved to spectators because your ^1car ^7does not meet the server ^1requirements.");
openPrivButton( "classchange",50,50,100,15,5,15,32, "^7Allowed drivetrains ^7on the server are ^3RWD or AWD" );
ENDIF
EndEvent
The key should be in the same folder as your lfslapper files.
API keys should be placed in : C:\LFS\LFSLapper\bin\<NameofServer>\includes\myInc.lpr
Your script: C:\LFS\LFSLapper\bin\<NameofServer>\includes\OPEN_drifting_server.lpr
Previosly lapper was complaining about these lines also but I deleted them to see is that the reason it stops working.
$StoredValueDbs = "Databases/storedvalue"; # Name of the database in which additional values are stored.
$StoreOfflineData = 0; #storedvalue.dbs Store Offline data , even when the player doesnt exist in the database.
**"Here's the error:"**
-----------------------------------------------------------------------------
7/4/2025 10:15:00 PM
$AdminFile = "./admin.txt"; # Name of the file containing admin lfsname player
$TrackInfoFile = "trackInfo.cfg"; # Path to the TrackInfoFile used to compare splits
$TCPmode = true; # Connection to LFS in UDP mode or TCP mode
$EnableRegisterWeb = false; # When set to "true" your LFS Server is displayed on the FRH Team website
$LongTimeFormat = "HH:mm:ss tt";
$ShortTimeFormat = "HH:mm";
$DateFormat = "dd/MM/yyyy";
$LongDateFormat = "dddd dd MMMM yyyy";
$MessageTime = 5000; # Time in milliseconds for a racecontrol message (started by: rcm_all) to be displayed on screen
$ShowPlayerControl = False; # Set option to "true" if you want to show the control configuration of players when leaving the pits.
$LayoutFolder = ""; #LFSLapper must be on the same machine as the LFS Server.
###############
#Debug Setting#
###############
#When setting one of these options below, it will displayed the executed subs/events/Loops etc in your Lapper console.
$DisplaySubs = -1; #Player created subs
$DisplayLoops = -1; #DelayedCommand functions,
$DisplayEvents = -1; #(Catch)Events
$DisplayGetPlayerVar = -1; #Display GetPlayerVars
$DisplaySetPlayerVar = -1; #Display SetPlayerVars
$DisplayLapperVar = -1; #Display LapperVars
$DisplayLapperFunction = -1; #Display LapperFunctions
$DisableAI = -1;
#################
#Control Allowed#
#################
$AuthAllowPlayer = "All";
$AuthMinPlayer = 0; # Minimum number of players on the server to auto enable authorization
$AutoGears = "N";
$HelpBrake = "N";
$KbNoHelp = "N";
$KbStabilised = "N";
$CustomView = "N";
Lang "EN"
example = "This text is an exampletext";
main_welc1 = "^7Welcome to ^1Sladi ^7Masters OPEN server";
main_welc2 = "^7Make your player name as example: ^7#000 F.Surename 'WHITE COLOR'";
main_accept = "^2Accept";
main_rules = "^2Rules";
main_speedtrap = "SpeedTrap = {0} {1}";
main_gotlevel = "^3You have got level: {0}";
main_swear11 = "^1Don't use this words on this server";
main_swear12 = "You will be spectated in ^2{0} ^1 more attempt(s)";
main_swear21 = "Too many swearwords, spectated";
main_nomatchflag = "Flags not match required flags";
main_yourflag = "Yours flags -> {0}";
main_requiredflag = "Required flags -> {0}" ;
main_spectated = "Spectated";
main_notadmin = "You are not an Admin!";
main_currnode = "The Current Node is : {0}";
main_currzone = "The Current Zone is : {0}";
main_lapclose = "Lapper Closed By Administrator!";
main_ban = "{0} Ban {1}";
main_kick = "{0} kick {1}";
main_friendpos = "Your friendly position is {0}";
main_groupqual = "Your groupqual is {0}";
main_level = "^3You have level(s): {0}";
main_dist = "Distance done on {0}/{1} = {2} {3}, session = {4} {5}";
main_lapdone = "Laps done on {0}/{1} = {2}, session = {3}";
main_timeinpit = "Time in pitting {0}";
main_trackused = "Track in use : {0} = {1}";
main_serverclock = "Server time clock reference : {0}";
main_midnight = "Midnight warning to all working men!";
main_newyear = "Happy New Year!";
main_allowed = "{0}^3 allowed on this server";
main_notallowed = "{0}^3 not allowed on this server";
main_tolowhand1 = "{0}^3 spectated for too low handicap";
main_tolowhand2 = "^3need {0}kg and {1}% of intake restriction!";
main_vote_restart1 = "Restart:";
main_vote_restart2 = "({0}/{1}) Need {2}";
main_vote_qualify1 = "Qualify";
main_vote_qualify2 = "({0}/{1}) Need {2}";
main_vote_end1 = "End:";
main_vote_end2 = "({0}/{1}) Need {2}";
main_car_changed = "Car changed, go to pit! Current car = {0}";
main_track_changed1 = "Track changed, please wait!";
main_track_changed2 = "Current Track = {0}";
main_left_server = "{0} ^7left the server";
main_great1 = "Great 1st split ({0}) by {1}^8!";
main_good1 = "Good 1st split ({0}) by {1}^8!";
main_great2 = "Great 2nd split ({0}) by {1}^8!";
main_good2 = "Good 2nd split ({0}) by {1}^8!";
main_great3 = "Great 3rd split ({0}) by {1}^8!";
main_good3 = "Good 3rd split ({0}) by {1}^8!";
main_greatlap = "Great lap ({0}) by {1}^8!";
main_goodlap = "Good lap ({0}) by {1}^8!";
main_flood = "{0}^3 kicked for flooding";
main_on_result = "Finished Pos = {0}";
main_lost_control = "^1Danger! ^8{0} ^2lost control!";
main_toslow1 = "you are too slow! Max : {0}";
main_toslow2 = "kick on {0}";
main_toslowvery1 = "You are very slow, spectated!";
main_toslowvery2 = "{0} is too slow, spectated!";
main_idle1 = "^3You are idle and will be spectated in 10 seconds" ;
main_idle2 = "^3You are spectated for non-activity";
main_onnewpb = "New PB by {0}^8 ({1}): {2}";
main_onnewpb_rank = "Friendly rank : {0}";
main_onnewpb_sesslaps = "Session laps done = {0}";
main_onnewpb_servlaps = "Total laps done (server) = {0}";
main_onnewpb_avgspeed = "Average speed: {0}{1}";
main_onnewpb_rank2 = "Friendly {0} rank: ^7{1}";
main_onnewpbqual = "League - New QT by {0}^8:{1}";
main_onnewpbqual_rank = "Friendly rank (all visitors): ^7{0}";
main_onnewpbqual_pos = "^2Qualify pos.: {0}";
main_onnewpbqual_pool = "^6Actual Pool: {0}";
main_onnewpbqual_avgspeed = "Average speed: {0}{1}";
main_onnewpbqual_posqual = "{0} ^2Pos:{1} - Pool:{2}";
main_accel = "^8Accelerated in ^3{0}^8 seconds to {1} {2}!";
main_notpitwindow = "{0} ^1You are not on pit Windows, allowed in {1}-{2}";
main_inpitwindows = "{0} ^1You are allowed to pit";
main_outpitwindows = "{0} ^1You are not allowed to pit";
main_beginpit = "{0}^8 makes a pit stop";
main_pitwork = "Pit begin! Work:{0}";
main_fastdrivepitl1_1 = "{0}^1 Warning for fast driving in pit";
main_fastdrivepitl1_2 = "^1WARNING-KICK POSSIBLE";
main_fastdrivepitl2_1 = "{0}^1 Spectated for fast driving in pit";
main_fastdrivepitl2_2 = "^1WARNING: YOU WILL BE KICKED IF YOU SPEED IN PITS {0} MORE TIME";
main_maxfastdrivepit1 = "{0}^1 kicked for fast driving in pit";
main_maxfastdrivepit2 = "^1YOU HAVE BEEN KICKED FOR SPEEDING IN PITS TOO MANY TIMES";
main_maxreset = "{0} spectated for exceeding max car resets";
main_oncarreset = "Car Reset by {0} on lap {1}";
main_specwarn = "^1Spectate Warning";
main_resetrest = "^2You have^3 {0} ^2car resets left";
main_close = "Close";
main_psdistance = "^7Distance: ^2{0} ^7{1}";
main_psfuel = "^7Fuel used: ^2{0} ^7liters ";
main_pslaps = "^7Laps done: ^2{0}";
main_pswins = "^7Wins: ^2{0}";
main_pssecond = "^7Second: ^2{0}";
main_psthird = "^7Third: ^2{0}";
main_psfinished = "^7Race finished: ^2{0}";
main_psquals = "^7Qualifications done: ^2{0}";
main_pspole = "^7Poles done: ^2{0}";
OnNewDriftPB = "{0}^3 made new PB: ^7{1} ^3pts!";
OnGoodDrift = "{0} ^3made excellent drift: ^7{1} ^3pts";
built_pos = "Pos";
built_grp = "Grp";
built_car = "Car";
built_track = "Track";
built_nick = "NickName";
built_pb = "Pb";
built_split = "Split";
built_splits = "Splits";
built_points = "Points";
built_nolfspb = "LFS World PB not yet retreived";
built_nolfspbcrit = "No LFS World PB for this criteria";
built_lapsdone = " Laps Done";
built_hand_nick = "^3{0}^9 handicap:";
built_hand_curr = " - Current {0}Kg - Intake Restr.: {1}%";
built_hand_req = " - Required {0}^9 {1}Kg - Intake Rest.: {2}%";
EndLang
/*
To create colored text, use the following codes in front of the text you want to color:
^0 - black
^1 - red
^2 - green
^3 - yellow
^4 - blue
^5 - violet
^6 - cyan
^7 - white
^8 - no color
Other variables that could be used on expressions
&& -> and
|| -> or
+ -> plus
- -> minus
/ -> devide
* -> multiply
^ -> pow
== -> equal to
!= -> not equal to
> -> bigger then
< -> smaller then
<= -> smaller then and equal to
>= -> bigger then and equal to
*/
-Do you get any other error messages.
-Is there other code you edited/created.
Looking at the error message, it seems that the faulty code is at Event OnConnect($userName)
But normally it points to the error in one of your scripts and not to the sourcecode.
example what i got today.
----------------------------------------------------------------------------- 7/4/2025 6:57:27 PM -> Error: Unclosed string on file: ".\default\.\includes\.\RallySystem\Scripts\Test\Convert.LPR" at line #6 ----------------------------------------------------------------------------- 7/4/2025 6:57:29 PM
Lapper Instance 188.122.74.156/55264 abort!
Object reference not set to an instance of an object. LFSLapper at LFSLapper.LFSClient.managePacket(NCN newConnection) at LFSLapper.LFSClient.Loop(Connect insimConnection) at LFSLapper.LFSClient.doloop() at LapperInstances.LapperInstance.doConnection() Void managePacket(NCN) Closing Instance...