<?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 == -1 ) THEN
$command = $text;
$argv = "";
ELSE
$command = subStr( $text,0,$idxOfFirtsSpace );
$argv = trim( subStr( $text,$idxOfFirtsSpace ) );
ENDIF
SWITCH( $command )
#Create a file somewhere on your pc.
CASE "!createfile":
IF (UserIsAdmin($userName) == 1) THEN
#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) == 1) THEN
$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-1 ; $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) == 1) THEN
$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) == 1) THEN
$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) == 1) THEN
#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
?>
-Open LFSLapper.LPR.
-Go to line 228.
-Change $DisplayLoops = 1; to $DisplayLoops = 0;
=================================================
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.
+---------------------------------------------------------------+
|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)
-Spectated: NumPlayers = 0.
-Spectated and rebooted lapper: NumPlayers = 0.
-Joined the track: NumPlayers = 1.
-Joined the track and rebooted Lapper: NumPlayers = 1.
$ListP = getListOfPlayers();
$randomnumber = round(ToNum(RandomNum(1,$player)),0)
$Player = $ListP[ToNum($randomnumber)];
$Var = GetLapperVar("LapperVar");
numconns //Number of players are connected to the server (include Host)
numplayers //Number of players are connected to the server
UserName = Bass-Driver
Cash = 98987
Cars = UF1+XFG+XRT
etc
GlobalVar $Variable;
$Variable[1] = "userName";
$Variable[2] = "Cash";
$Variable[3] = "Cars";
$Variable[4] = "Distance";
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)