Advertisement
TommyB

Edited Chatlog Archiver for SA-MP

Oct 29th, 2017
297
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; Set the working directory to the SA-MP directory...
  2. sampdir:=A_MyDocuments . "\GTA San Andreas User Files\SAMP\"
  3. chatlogdir:=A_MyDocuments . "\GTA San Andreas User Files\SAMP\chatlogs\"
  4. SetWorkingDir, %sampdir%
  5.  
  6. ; If we're working in the wrong directory (ie you can't find the SA-MP config file) then return an error and exit.
  7. IfNotExist, sa-mp.cfg
  8.     MsgBox, Error: Could not find SA-MP directory. Expected location: %sampdir%
  9.  
  10. IfNotExist, sa-mp.cfg
  11.     return
  12.  
  13. IfNotExist, %chatlogdir%
  14.     FileCreateDir, %chatlogdir% . MsgBox, Created directory %chatlogdir%.
  15.  
  16. Loop
  17. {
  18.     WinWait GTA:SA:MP ; Wait until GTA:SA is launched by SA-MP.
  19.     filename:=A_YYYY . "." . A_MM . "." . A_DD ; Generate the filename based on the time SA-MP is launched.
  20.     WinWaitClose GTA:SA:MP ; Now wait for it to close before continuing.
  21.     ifExist, %chatlogdir%\%filename%.txt ; Check to see if an archived chatlog already exists.
  22.     {
  23.         FileRead, newtext, %sampdir%\chatlog.txt ;Read the text from the current, unarchived chatlog and assign it to a variable.
  24.         FileAppend, %newtext%, %chatlogdir%\%filename%.txt ; Write the new chatlog to the already existing, archived one
  25.     }
  26.     else FileCopy, %sampdir%\chatlog.txt, %chatlogdir%\%filename%.txt ; If a chatlog for the current date doesn't exist, copy the current chatlog to the separate directory with the filename we generated earlier.
  27. }
  28.  
  29. return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement