The online racing simulator
Searching in All forums
(884 results)
Files - Create/Read/Edit/Delete
Bass-Driver
S3 licensed

<?php 
######################################################################################
#Tutorial: Create/Edit/Read/Delete files and delete lines in a file.
#In this tutorial i show you some code examples. You may use these in your scripts aswell. 
#
#We use the OnMSO Playerevent , which registers the input of the message box ('T' keypress)
######################################################################################
Event OnMSO$userName$text # Player event
    
$idxOfFirtsSpace indexOf$text" ");

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

            
#Create a file somewhere on your pc.

            
CASE "!createfile":
                IF (
UserIsAdmin($userName) == 1THEN
                    
#Action if file already exist
                    #0 = no action
                    #1 = overwrite file
                    #2 = overwrite file + create backup file.
                    
                    
$Filename "TestFile";
                    
$Folder "C:\Users\User\Desktop";
                    
$Action 2;

                    
CreateFile($Filename,$Folder,$Action);
                ENDIF
            BREAK;

            
#Read File

            
CASE "!readfile":
                IF (
UserIsAdmin($userName) == 1THEN
                    $Filename 
"TestFile";
                    
$Folder "C:\Users\User\Desktop";
                    
$Extension ".txt";

                    
$LinesofFile ReadFile($Filename,$Folder,$Extension);
                
                    
#Get Information from the file.
                    
$NrOfLines $LinesofFile["NumberOfLines"];
                    
$FileCreationDate $LinesofFile["TimeOfCreation"];
                    
$FileModificationDate $LinesofFile["TimeOfModification"];
                    
$FileSize $LinesofFile["FileSize"];
                    
                    
#Display info in the chat about the file 
                    
privmsg("Reading file: " $Filename ".txt");
                    
privmsg("NumberOfLines: " $NrOfLines "");
                    
privmsg("Size of file: " $FileSize " Bytes");
                    
privmsg("Creation time: " $FileCreationDate "");
                    
privmsg("Modify time: " $FileModificationDate "");
                    
                    
#Create a FOR loop to display each line from the file in the chat.

                    
FOR ( $i 0$i <= $NrOfLines-$i $i 1)
                        
$linenr $LinesofFile[$i,"LineNumber"];    #LineNr
                        
$line $LinesofFile[$i,"Line"];             #Text
                        
privmsg("[".$linenr."]: ".$line);            #Display LineNr and Text
                    
ENDFOR    
                ENDIF            
            BREAK;
            
            
#Edit File
            #You can edit a line or you can create a new one.
            #IF $LineToEdit = -1, a new line will be added in your created file. 
   
            
CASE "!editfile":
                IF (
UserIsAdmin($userName) == 1THEN
                    $Filename 
"TestFile";
                    
$Folder "C:\Users\User\Desktop";
                    
$NewText "NewText ";
                    
$LineToEdit 5;  # -1 to create a extra line
                    
$Extension ".txt";
 
                    
EditFile($Filename,$Folder,$NewText,$LineToEdit,$Extension);
                ENDIF
            BREAK;
            
            
#Delete File
            #By deleting a file, you can choose if you want to make a backup before deleting.
            #Keep value of '$CopyFolder' empty if you dont want to copy the file before deleting.
            #Otherwise enter the foldername where the backup need to be placed.

            
CASE "!deletefile":
                IF (
UserIsAdmin($userName) == 1THEN
                    $Filename 
"TestFile";
                    
$Folder "C:\Users\User\Desktop";
                    
$CopyFolder "";                    #$CopyFolder is empty , no backup will be created.
                    
$Extension ".txt";
                    
                    
DeleteFile($Filename,$Folder,$CopyFolder,$Extension);
                ENDIF
            BREAK;
            
            
#Delete a single line , based on a LineNr

            
CASE "!deleteline":
                IF (
UserIsAdmin($userName) == 1THEN
                
                    
#Enter -1 to $NewText to enable the "deleteline" function
                    #set the line @ $LineToEdit, which line that need to be deleted.
                    
                    
$Filename "TestFile";
                    
$Folder "C:\Users\User\Desktop";
                    
$NewText = -1;    # -1 = deleteline function.
                    
$LineToDelete 5;  
                    
$Extension ".txt";
 
                    
EditFile($Filename,$Folder,$NewText,$LineToDelete,$Extension);
                ENDIF
            BREAK;            
    ENDSWITCH
EndEvent
?>


Last edited by Bass-Driver, .
Bass-Driver
S3 licensed
Merry Christmas to the devs and the community
Bass-Driver
S3 licensed
Dont have any idea why it shouldnt work.
only thing i can advise is to verify the files listed below.

-Verify LFSServers.cfg with your LFSLapper V7.0.4.4.
-Verify Default.ini with your LFSLapper V7.0.4.4.

One question, did you have copied some scripts from V7.0.4.4 to the newer releases of Lapper??

And indeed a errorlog whould become handy.
Bass-Driver
S3 licensed
Thx, i made a small mistake with releasing this version. I accidently didnt changed one of the debug options in lapper back to its default state. This will cause a spam of messages in the lapperconsole.

The users can easily change it back.

How to:


-Open LFSLapper.LPR.
-Go to line 228.
-Change $DisplayLoops = 1; to $DisplayLoops = 0;

Bass-Driver
S3 licensed
good looking update, keep them going.
Release: LFSLapper V7.0.6.3
Bass-Driver
S3 licensed
Hello Lapperusers,

We have been working in cooperation with "iceman121" on a cruise insim for many months now. During the development of this insim we encountered some bugs. Some are old bugs and some are fairly new, that are caused by the latest releases of LFSLapper, ye sorry Smile. But we are gonna fix them bit by bit.

In this version we fixed some bugs and updated 1 GetLapperVar().

See the changelog below.

=================================================
Changed:
=================================================
1: GetLapperVar(ShortDate): Possible to add a 2nd parameter to add/delete days
Example: calculate date of unban a player

$NewDate = GetLapperVar(ShortDate,5); // Adds 5 days to the current date
$NewDate = GetLapperVar(ShortDate,+5); // Adds 5 days to the current date
$NewDate = GetLapperVar(ShortDate,-5); // Deletes 5 days to the current date
=================================================
Fix:
=================================================
1: InstantSpeed Playervar didnt reset to '0' after going to pit or spec (Shift+P / Shift+S)
2: Angle of car didnt reset to '0' after going to pit or spec (Shift+P / Shift+S)
-This could spam Event OnAngleVelocity() after losing control and pit/spec at the same time.
3: Event OnTakeOverCar(): Typo in sourcecode, didnt execute the event.
4: RegisterScheduledAction(): Function did not execute when only minutes are set.
-Rewrote small code of RegisterScheduledAction() and (Priv/Host)DelayedCommand();
-Lapper will now check, if it is a scheduled action or a delayedaction.
5: RegisterStreetAction(); Lappercrash when changing tracks or random lappercrash when leaving a street.
6: RegisterZoneAction ID still remains when a player pit/specs while standing inside a zone.

Have fun and see you on the roads Smile
Last edited by Bass-Driver, .
Release: LFSLapper V7.0.6.2
Bass-Driver
S3 licensed
Hello Lapperusers,

Couple of months ago, some players reported 1 big issue when using RegisterScheduledAction() and DelayedCommand() Lapperfuctions.

This version contains the fixes for them.

This version is tested is a few servers, and one of them is a cruiseserver, which is using many of these functions.
After couple of weeks running this testversion, we find this version stable enough for release.

+---------------------------------------------------------------+
|Changes from 7.0.6.1 to 7.0.6.2 |
+---------------------------------------------------------------+
=================================================
Fix:
=================================================
1:RegisterScheduledAction bug: Executed every second.
2:DelayedCommand: When out of sync with the current time, delayed command wont executed anymore. ( Old Bug)

Bass-Driver
S3 licensed
As far i know, does Lapper have problems with the newer version of Linux/Debain/Mono.
I have seen this error message many times. And have no solution for this problem yet.

Link with the same problem.

https://www.lfs.net/forum/post/1937835#post1937835

====================================================================
Unrelated to the problem above.

I have fixed the RegisterScheduledAction/(Host)DelayedCommand bug. Will release a testversion as soon as possible.
Bass-Driver
S3 licensed
I have tested those lappervars , but it seems that they are working as it should be.
See below on the various ways i have tested these Lappervars:
The server is empty while doing the tests below.

NumConns:

-Left the server, started lapper, joined the server: Numconns = 2 (Include host)
-Joined the server and rebooted lapper, Numconns = 2.


NumPlayers: Numplayers is the amount of Players driving on the track. So Spectators doesnt count.

-Spectated: NumPlayers = 0.
-Spectated and rebooted lapper: NumPlayers = 0.
-Joined the track: NumPlayers = 1.
-Joined the track and rebooted Lapper: NumPlayers = 1.

Last edited by Bass-Driver, .
Bass-Driver
S3 licensed
Thanks for the report, will look into it when i have time.
Bass-Driver
S3 licensed
He's a member of Black-Garage, which is a cracked community.
Bass-Driver
S3 licensed
well, as i can see you count the players aswell in the WHILE loop.

$ListP = getListOfPlayers();
$randomnumber = round(ToNum(RandomNum(1,$player)),0)
$Player = $ListP[ToNum($randomnumber)];

To make it easier, Lapper does have a Lappervar to count the players.

$Var = GetLapperVar("LapperVar");
numconns //Number of players are connected to the server (include Host)
numplayers //Number of players are connected to the server

Bass-Driver
S3 licensed
@ Scawen,
Any idea, when you could show us the rest of the updated tracks.
And if there are other updates/fixes aswell beside the graphical update.
Bass-Driver
S3 licensed
a combo with "LayoutList(.LPR)" !layoutlist and this script whould be nice indeed.
Bass-Driver
S3 licensed
you could check out this votesystem i uploaded 3 years ago.
The date of creation is much older.

https://www.lfs.net/forum/thread/88352
Bass-Driver
S3 licensed
The new shadowsystem looks amazing.
I like the new dragstrip area aswell.

Cant wait to see the rest of the updated tracks.

Job well done Devs Thumbs up
Bass-Driver
S3 licensed
thank you for keeping these scripts updated.
Bass-Driver
S3 licensed
Nice script mate. Thumbs up
Bass-Driver
S3 licensed
I think the userfile will look like this?

UserName = Bass-Driver
Cash = 98987
Cars = UF1+XFG+XRT
etc

You could create a array with all the variables.

GlobalVar $Variable;
$Variable[1] = "userName";
$Variable[2] = "Cash";
$Variable[3] = "Cars";
$Variable[4] = "Distance";

Verify each line of the file with the name of the $variable.
And if it doesnt exist. You create a new line with the new variable.
Bass-Driver
S3 licensed
i see now its has something todo with a fix in 7.0.5.0.

13: (Priv/Host)Delayedcommand: Cannot be executed when settime is not equal with the current time.
The Delayedcommand task stays in the list and will never be executed.
Continues loops could hang. And had to be resetted manually.

i will look into it to see what went wrong.


What are you trying to receive from the web??
Do you request anything at all??
Bass-Driver
S3 licensed
Ok thanks for the bug reports. We will look into it.
Weird that noone else came with this before.

Have you tried 7.0.6.0 aswell?
Bass-Driver
S3 licensed
New update:
This update contains a few design changes in the TimeTable and Helpmenu.

V1.15(19-08-2018)
Update: HelpMenu: design changes.
Update: HelpMenu: New Tab , Player Stats. Not completed yet.
Update: HelpMenu: Added more serverinfo in 'ServerInfo' tab
Update: TimeTable: CarClass filter (TBO+GTR+LFR+NGT)
Update: TimeTable: New stageselection methode.
Update: TimeTable: Add 'Gaptime' colomn.
Fix: TimeTable: Layoutname not displayed.
Fix: Yellowflag still enabled when someone is leaving the race (Pit/Spec/Disconnect)

Bass-Driver
S3 licensed
Thank you.
There are still some Todo's left, that i really want to implement in this addon.
Bass-Driver
S3 licensed
i found something on this topic with the same result.
Seems like a Dos attack?

https://www.lfs.net/forum/post/1830209#post1830209
Bass-Driver
S3 licensed
Nothing special on my servers, as far i can see.

Looks like someone is scanning the servers of something. Or trying to connect from a faulty/cracked masterserver list / LFS.exe . Shrug

Did you receive any other messages from that IP?

Hope the devs can tell you/us more about those messages.
FGED GREDG RDFGDR GSFDG