The online racing simulator
[solved] Drivers briefing - How to make Timed rolling text with lauch command
Greetings

I am trying to organize an open drifting competition.
At the beginning of the competition, I want to hold a drivers’ meeting where I briefly explain the competition format and the rules.

I assume I won’t get all interested drivers to join the Discord voice chat, so my solution is to write the drivers’ briefing directly into the game chat.
This can be automated with Lapper.

I will create a separate `Briefing.lpr` file in the folder:
C:\LFS\LFSLapper\bin\servers\includes

and then add the following line at the top of the file
C:\LFS\LFSLapper\bin\servers\DriftingServer.lpr

include("./includes/Briefing.lpr");

In the `Briefing.lpr` file, I want to create a command that only the server admin can run.
The command is "!brief", which starts the drivers’ meeting consisting of 25 lines of text.

PROBLEM
My code now crashes lapper, when includes line is active (include("./includes/Briefing.lpr")Wink.

When line in inactive (#include("./includes/Briefing.lpr")Wink lapper works fine.

I changed word chat -> rivi

QUESTION
1. What I did wrong?
2. How to fix it?

Here is my code in Briefing.lpr -file:
-----
# Driftin OPEN
# DriversBriefing


$distToDo = -1;

Event OnMSO( $userName, $text ) # Player event
$idxOfFirtsSpace = indexOf( $text, " ");

IF( $idxOfFirtsSpace == -1 ) THEN
$command = $text;
$argv = "";
ELSE
$command = subStr( $text,0,$idxOfFirtsSpace );
$argv = trim( subStr( $text,$idxOfFirtsSpace ) );
ENDIF

SWITCH( $command )

CASE "!brief":
IF ( UserIsAdmin( $userName ) == 1 )
THEN
DelayedCommand( 5,rivi2 );

ELSE
privMsg("Only for admin!");
ENDIF
BREAK;
ENDSWITCH
EndEvent


Sub rivi1 ()
cmdLFS("/msg" );
DelayedCommand( 10,rivi2 );
EndSub
Sub rivi2 ()
globalmsg("^7We now start the DRIVERS BRIEFING.");
DelayedCommand( 10,rivi3 );
EndSub
Sub rivi3 ()
globalmsg("^7Keep the game chat empty for competition leader messages.");
DelayedCommand( 10,rivi4 );
EndSub
Sub rivi4 ()
globalmsg("^7Do not write anything to the game chat during the QUALIFY and TOP20 bracket.");
DelayedCommand( 10,rivi5 );
EndSub
Sub rivi5 ()
globalmsg("^7You can follow competition by opening www.sladimasters.com/scoreboard ");
DelayedCommand( 10,rivi6 );
EndSub
What does the errorlog tells you.

Beside that, i do see one issue already with the events
All

Event OnMSO should be CatchEvent OnMSO, this is for all external scripts outside the default lfslapper.lpr

so
Event
EndEvent

must be

CatchEvent
EndCatchEvent


CatchEvent OnMSO( $userName, $text ) # Player event
$idxOfFirtsSpace = indexOf( $text, " ");

IF( $idxOfFirtsSpace == -1 ) THEN
$command = $text;
$argv = "";
ELSE
$command = subStr( $text,0,$idxOfFirtsSpace );
$argv = trim( subStr( $text,$idxOfFirtsSpace ) );
ENDIF

SWITCH( $command )

CASE "!brief":
IF ( UserIsAdmin( $userName ) == 1 )
THEN
DelayedCommand( 5,rivi2 );

ELSE
privMsg("Only for admin!");
ENDIF
BREAK;
ENDSWITCH
EndCatchEvent


Sub rivi1 ()
cmdLFS("/msg" );
DelayedCommand( 10,rivi2 );
EndSub

Sub rivi2 ()
globalmsg("^7We now start the DRIVERS BRIEFING.");
DelayedCommand( 10,rivi3 );
EndSub

Sub rivi3 ()
globalmsg("^7Keep the game chat empty for competition leader messages.");
DelayedCommand( 10,rivi4 );
EndSub

Sub rivi4 ()
globalmsg("^7Do not write anything to the game chat during the QUALIFY and TOP20 bracket.");
DelayedCommand( 10,rivi5 );
EndSub

Sub rivi5 ()
globalmsg("^7You can follow competition by opening www.sladimasters.com/scoreboard ");
DelayedCommand( 10,rivi6 );
EndSub

Quote : DelayedCommand( 10,rivi6 );

Try to remove that line.
It tries to call a function named "rivi6" but you only have rivi1 to rivi5.
The most obvious issue is that if you are adding a lapper script, you need to 'Catch' any and all events.

So "Event onMSO.." should be "CatchEvent OnMSO...", and the end should be changed from "EndEvent" to "EndCatchEvent".

Not sure why there's a 'rivi1' sub, when the !brief command sends you to 'rivi2'.

As for the sub info (or lack thereof) within the brackets after the sub name, this is something I always struggle with, and even asked about ...

SUB event Q - https://www.lfs.net/forum/post/1693093#post1693093
SUB event A - https://www.lfs.net/forum/post/1693302#post1693302

The answer helped me a little, but not always, so I go through the following ...

# Possible subs to use:
# Sub sub1()
# Sub sub1($userName)
# Sub sub1($KeyFlags,$userName)
# Sub sub1($KeyFlags,$argv)
# Sub sub1($KeyFlags,$id)

If you're using a command to start things off, why do you need a distance to do first?

Another issue might be the directory and folder you're placing your briefing.lpr file. It should be in the standard \bin\default\includes directory, and should be added into the existing addonsused.lpr file.

Good luck.
Quote from Bass-Driver :What does the errorlog tells you...

First i did correct obvious, Event -> CatchEvent & EndEvent -> EndCatchEvent, Problem.

Then opened the error log, and found out that i had left there a mark for my self wich caused the crashing.
I re moved the error and then added briefing.lpr to addons.lpr
After these modifications, lapper and its other functions are working.
But can get my command to make to text flow.

Here is the code now
-----
# Drift OPEN
# DriversBriefing

$distToDo = -1; # <-- I don't know is this necessary

CatchEvent OnMSO( $userName, $text ) # Player event
$idxOfFirtsSpace = indexOf( $text, " ");

IF( $idxOfFirtsSpace == -1 ) THEN
$command = $text;
$argv = "";
ELSE
$command = subStr( $text,0,$idxOfFirtsSpace );
$argv = trim( subStr( $text,$idxOfFirtsSpace ) );
ENDIF

SWITCH( $command )

CASE "!kokous":
IF ( UserIsAdmin( $userName ) == 1 )
THEN
DelayedCommand( 5,line1 );

ELSE
privMsg("Only for admin!");
ENDIF
BREAK;
ENDSWITCH
EndCatchEvent

Sub line1 ()
cmdLFS("/msg" );
DelayedCommand( 10,line2 );
EndSub
Sub line2 ()
globalmsg("^7We now start the DRIVERS BRIEFING.");
DelayedCommand( 10,line3 );
EndSub
Sub line3 ()
globalmsg("^7Keep the game line empty for competition leader messages.");
DelayedCommand( 10,line4 );
EndSub
Sub line4 ()
globalmsg("^7Do not write anything to the game line during the QUALIFY and TOP20 bracket.");
DelayedCommand( 10,line5 );
EndSub
Sub line5 ()
globalmsg("^7You can follow competition by opening www.website.ne/scoreboard ");
DelayedCommand( 10,line6 );
EndSub
Sub line6 ()
globalmsg("^7Stay on server as long as you are still competing.");
DelayedCommand( 10,line7 );
EndSub
Sub line7 ()
globalmsg("^7Add your competition number front of your name => #666 E.Xample ");
DelayedCommand( 10,line8 );
EndSub
Sub line8 ()
globalmsg("^7Only drivers with competition number get to the qualifying list.");
DelayedCommand( 10,line9 );
EndSub
Sub line9 ()
globalmsg("^7You are free to choose any competition number between 1-999.");
DelayedCommand( 10,line10 );
EndSub
Sub line10 ()
globalmsg("^7Competition Leader will call you by name when it is your turn.");
DelayedCommand( 10,line11 );
EndSub
Sub line11 ()
globalmsg("^7NAME CAll FOR THE EVENT");
DelayedCommand( 10,line12 );
EndSub
Sub line12 ()
globalmsg("^7ALL DRIVERS who want to PARTICIPATE in the competition TODAY");
DelayedCommand( 10,line13 );
EndSub
Sub line13 ()
globalmsg("^7TYPE hi in the game chat now.");
EndSub

Sub OnConnectClose( $KeyFlags,$id )
closePrivButton("welc&pos&clos&ref");
LoginNonMember(GetCurrentPlayerVar( "UserName" ));
EndSub
Quote from sinanju :The most obvious issue is that if you are adding a lapper script, you need to...

I changed rivi -> line for better describtion what it is and also changed that command to send to sub "line1" (previous was to sub line2).


I think I have made the error in the "CatchEvent OnMSO" - part of the script.
I just need simple button, when pressed checks am I admin of server and then runs the text.
I think this catchevent does not suit for this purpose.
I copied it from an another part from my lapper code, where it is used to reload lapper (when changes are made).


Tell my greetings to Chiun
Can the [CatchEvent OnMSO] section be in its own file, or does it have to be written directly in the LFSLapper.lpr file?"
-
(J_Valkonen) DELETED by J_Valkonen : left too early
I got it working.

If you want to do Drivers Briefing file here is how I did it.
First i made the file Briefing.lpr in the folder location:
C:\LFS\LFSLapper\bin\servers\includes\

Then i added line:
include( "./Briefing.lpr");

Line was added to file:
C:\LFS\LFSLapper\bin\servers\includes\addonsused.lpr

Then I made sure that my Server_OPEN.lpr in the folder location:
C:\LFS\LFSLapper\bin\servers\

had line
include( "./includes/addonsused.lpr");

After that
I wrote code and tested it.
I found out that, if you want to have multiple commands for different text flods, you have to write them in same file as I have done here.

Next I am going to explore the "SWITCH( $command )" if it would make possible to make individual "files with execute commands".

Here is my code
----------
# DriversBriefing

# THIS IS THE DRIVERSBRIEFING text
Sub line1 ()
cmdLFS("/msg" ); #This maybe clears all other written text before it
DelayedCommand( 1,line2 );
EndSub
Sub line2 ()
globalmsg("^7Welcome to OPEN Drift Event 1 ");
DelayedCommand( 4,line3 );
EndSub
Sub line3 ()
globalmsg("^7We now start the DRIVERS BRIEFING.");
DelayedCommand( 4,line4 );
EndSub
Sub line4 ()
globalmsg("^7Keep the game chat empty for competition leader messages.");
DelayedCommand( 4,line5 );
EndSub
Sub line5 ()
globalmsg("^7Do not write anything to the game chat during the QUALIFY.");
DelayedCommand( 4,line6 );
Sub line6 ()
globalmsg("^7Thank you!");
EndSub

# THIS CLOSES DRIVERSBRIEFING text flod
Sub CloseBriefMsg( $KeyFlags,$id )
closeGlobalButton("Brief_msg");
EndSub

# THIS IS THE COMMAND FOR START DRIVERSBRIEFING text flod
CatchEvent OnMSO( $userName, $text )
$ucaseText = ToLower($text);
IF( $ucaseText == "!brief" ) THEN
IF( UserIsAdmin($userName) == 1 ) THEN
DelayedCommand( 1, line1 ); # delay in secends, here 1, whats happens next
privMsg($userName, "^2Drivers Briefing starts ...");
ELSE
privMsg("Only for admin!");
ENDIF
ENDIF
IF( $ucaseText == "!huuto" ) THEN
IF( UserIsAdmin($userName) == 1 ) THEN
DelayedCommand( 1, huuto_line1 ); # delay in secends, here 1, whats happens next
privMsg($userName, "^2Sign up name call starts ...");
ELSE
privMsg("Only for admin!");
ENDIF
ENDIF
EndCatchEvent

# THIS IS THE SIGN UP NAME CALL text
##########NIMENHUUTO##########
Sub huuto_line1 ()
globalmsg("^4SIGN UP NAME CALL");
DelayedCommand( 4,huuto_line2 );
EndSub
Sub huuto_line2 ()
globalmsg("^7We now start the SIGN UP NAME CALL FOR THE EVENT.");
DelayedCommand( 4,huuto_line3 );
Sub huuto_line3 ()
globalmsg("^7ALL DRIVERS who want to PARTICIPATE in the competition TODAY,");
DelayedCommand( 4,huuto_line4 );
EndSub
Sub huuto_line4 ()
globalmsg("^7TYPE hi in the game chat now.");
EndSub

# THIS CLOSES text flod
Sub CloseHuutoMsg( $KeyFlags,$id )
closeGlobalButton("huuto_msg");
EndSub

FGED GREDG RDFGDR GSFDG