<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.multitheftauto.com/wiki/Modules/FileSystem/file/write?action=history&amp;feed=atom</id>
	<title>Modules/FileSystem/file/write - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.multitheftauto.com/wiki/Modules/FileSystem/file/write?action=history&amp;feed=atom"/>
	<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Modules/FileSystem/file/write&amp;action=history"/>
	<updated>2026-04-28T15:26:09Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.3</generator>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=Modules/FileSystem/file/write&amp;diff=73743&amp;oldid=prev</id>
		<title>Danilo at 03:05, 23 January 2022</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Modules/FileSystem/file/write&amp;diff=73743&amp;oldid=prev"/>
		<updated>2022-01-23T03:05:10Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 03:05, 23 January 2022&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;pageclass class=&quot;#3cc882&quot; subcaption=&quot;File function&quot;&gt;&amp;lt;/pageclass&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;__NOTOC__&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;__NOTOC__&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This function attempts to write a string of bytes (characters) into the file. It returns the amount of bytes that have actually been written.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This function attempts to write a string of bytes (characters) into the file. It returns the amount of bytes that have actually been written.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;!-- diff cache key wiki-wiki_dev_:diff::1.12:old-73659:rev-73743 --&gt;
&lt;/table&gt;</summary>
		<author><name>Danilo</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=Modules/FileSystem/file/write&amp;diff=73659&amp;oldid=prev</id>
		<title>Danilo: Created page with &quot;__NOTOC__ This function attempts to write a string of bytes (characters) into the file. It returns the amount of bytes that have actually been written.  ==Syntax== &lt;syntaxhighlight lang=&quot;lua&quot;&gt; int file:write ( string dataString ) &lt;/syntaxhighlight&gt;  ==Arguments== *'''dataString:''' the string of data that should be written into the file  ==Returns== Returns the amount of bytes that have been actually written into the file. Returns false if '''dataString''' is not a valid...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Modules/FileSystem/file/write&amp;diff=73659&amp;oldid=prev"/>
		<updated>2022-01-19T03:38:15Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;__NOTOC__ This function attempts to write a string of bytes (characters) into the file. It returns the amount of bytes that have actually been written.  ==Syntax== &amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt; int file:write ( string dataString ) &amp;lt;/syntaxhighlight&amp;gt;  ==Arguments== *&amp;#039;&amp;#039;&amp;#039;dataString:&amp;#039;&amp;#039;&amp;#039; the string of data that should be written into the file  ==Returns== Returns the amount of bytes that have been actually written into the file. Returns false if &amp;#039;&amp;#039;&amp;#039;dataString&amp;#039;&amp;#039;&amp;#039; is not a valid...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;__NOTOC__&lt;br /&gt;
This function attempts to write a string of bytes (characters) into the file. It returns the amount of bytes that have actually been written.&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
int file:write ( string dataString )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Arguments==&lt;br /&gt;
*'''dataString:''' the string of data that should be written into the file&lt;br /&gt;
&lt;br /&gt;
==Returns==&lt;br /&gt;
Returns the amount of bytes that have been actually written into the file. Returns false if '''dataString''' is not a valid string.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Client&amp;quot; class=&amp;quot;client&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This snippet logs the local player's chat output into a file.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Open up the logfile.&lt;br /&gt;
-- If it was not created already, create it.&lt;br /&gt;
local logFile = false;&lt;br /&gt;
&lt;br /&gt;
if ( fileExists( &amp;quot;log.dat&amp;quot; ) ) then&lt;br /&gt;
    logFile = fileOpen( &amp;quot;log.dat&amp;quot; );&lt;br /&gt;
else&lt;br /&gt;
    logFile = fileCreate( &amp;quot;log.dat&amp;quot; );&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Table of all log entries.&lt;br /&gt;
-- The logfile has to be written at the destruction of the resource environment.&lt;br /&gt;
-- This is done so we can have multiple log sessions added into a file stream.&lt;br /&gt;
local logEntries = {};&lt;br /&gt;
&lt;br /&gt;
-- Function to append entries into the logfile.&lt;br /&gt;
local function addLogEntry( message )&lt;br /&gt;
    local entry = {&lt;br /&gt;
        message = message,&lt;br /&gt;
        time = getRealTime()&lt;br /&gt;
    };&lt;br /&gt;
&lt;br /&gt;
    table.insert( logEntries, entry );&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Event handler to add log entries when chat messages are created.&lt;br /&gt;
addEventHandler( &amp;quot;onClientChatMessage&amp;quot;, root,&lt;br /&gt;
    function(message)&lt;br /&gt;
        -- Forward the message into our logging system.&lt;br /&gt;
        addLogEntry( message );&lt;br /&gt;
    end&lt;br /&gt;
);&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
-- Write the log when the resource is terminated.&lt;br /&gt;
addEventHandler( &amp;quot;onClientResourceStop&amp;quot;, root,&lt;br /&gt;
    function()&lt;br /&gt;
        -- todo: write session start and end times.&lt;br /&gt;
&lt;br /&gt;
        -- Write the amount of log entries.&lt;br /&gt;
        logFile:writeShort( #logEntries );&lt;br /&gt;
&lt;br /&gt;
        -- Write the log entries.&lt;br /&gt;
        for m,n in ipairs( logEntries ) do&lt;br /&gt;
            local encryptedMessage = teaEncode( n.message );&lt;br /&gt;
&lt;br /&gt;
            logFile:writeShort( #encryptedMessage );&lt;br /&gt;
            logFile:write( encryptedMessage );&lt;br /&gt;
&lt;br /&gt;
            -- Write date information.&lt;br /&gt;
            logFile:writeShort( n.time.second ); logFile:writeShort( n.time.minute ); logFile:writeShort( n.time.hour );&lt;br /&gt;
            logFile:writeShort( n.time.monthday ); logFile:writeShort( n.time.month + 1 ); logFile:writeShort( n.time.year + 1900 );&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
);&lt;br /&gt;
&lt;br /&gt;
-- todo: create a log file viewer.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
{{:Modules/FileSystem/file/functions}}&lt;/div&gt;</summary>
		<author><name>Danilo</name></author>
	</entry>
</feed>