Jump to content

fileWrite - New Line


Dealman

Recommended Posts

Working on getting some of my resources to write logs when a player does a specific action. So far I've accomplishes all I want, the only issue I have is that I can't seem to find a way to move the position to a new line. Thus it becomes a complete mess to read.

Does anyone know how to make it write on a new line? It's a text file so I understand that it doesn't have any 'true lines'(or does it...?).

I've tried \n, which doesn't do anything. :(

Link to comment
Working on getting some of my resources to write logs when a player does a specific action. So far I've accomplishes all I want, the only issue I have is that I can't seem to find a way to move the position to a new line. Thus it becomes a complete mess to read.

Does anyone know how to make it write on a new line? It's a text file so I understand that it doesn't have any 'true lines'(or does it...?).

I've tried \n, which doesn't do anything. :(

Check this out : https://forum.multitheftauto.com/viewtopic.php?f=91&t=53562

I hope it help .

  • Like 1
Link to comment
I even tried to search :roll: Thanks mate :)

If that doesn't work, you can also set the start of your new line at the end of your file by counting it. It's a dirty trick but I used it several times;

function writeLog ( text ) 
    if not ( fileExists ( "logs/logs.txt" ) ) then fileCreate ( "logs/logs.txt" ); end 
    file = fileOpen ( "logs/logs.txt" ) 
    if ( file ) then 
        pos = fileGetSize( file ); 
        newPos = fileSetPos ( file, pos ); 
        writeFile = fileWrite ( file, text .."\n" ); 
        if ( writeFile ) then 
            fileClose ( file ); 
        else 
            outputDebugString ( "Error writing the logs." ); 
            fileClose ( file ); 
            return false; 
        end 
    end      
end 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...