<?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, " ");
#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";
#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";