<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.gtaconnected.com/wiki/index.php?action=history&amp;feed=atom&amp;title=ScriptingExamples%2FLogChatMessagesToFile</id>
	<title>ScriptingExamples/LogChatMessagesToFile - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.gtaconnected.com/wiki/index.php?action=history&amp;feed=atom&amp;title=ScriptingExamples%2FLogChatMessagesToFile"/>
	<link rel="alternate" type="text/html" href="https://wiki.gtaconnected.com/wiki/index.php?title=ScriptingExamples/LogChatMessagesToFile&amp;action=history"/>
	<updated>2026-06-05T04:33:04Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.15</generator>
	<entry>
		<id>https://wiki.gtaconnected.com/wiki/index.php?title=ScriptingExamples/LogChatMessagesToFile&amp;diff=4815&amp;oldid=prev</id>
		<title>Mex at 00:07, 8 February 2019</title>
		<link rel="alternate" type="text/html" href="https://wiki.gtaconnected.com/wiki/index.php?title=ScriptingExamples/LogChatMessagesToFile&amp;diff=4815&amp;oldid=prev"/>
		<updated>2019-02-08T00:07:34Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{DISPLAYTITLE:Log Chat Messages to File}}&lt;br /&gt;
== Description ==&lt;br /&gt;
This code adds a line of text to ChatLog.txt, (in the resource folder), when any player types a chat message.&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;JavaScript, Server-Side:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
{{JSCode|1=addEventHandler(&amp;#039;onPlayerChat&amp;#039;, function(event,client,message)&lt;br /&gt;
{&lt;br /&gt;
    addToLog(client.name+&amp;#039;: &amp;#039;+message);&lt;br /&gt;
});&lt;br /&gt;
&lt;br /&gt;
function addToLog(text)&lt;br /&gt;
{&lt;br /&gt;
	var file2 = openFile(&amp;#039;ChatLog.txt&amp;#039;, false);&lt;br /&gt;
	if(!file2)&lt;br /&gt;
		return;&lt;br /&gt;
	var filePreviousData = file2.readBytes(file2.length);&lt;br /&gt;
	file2.close();&lt;br /&gt;
	&lt;br /&gt;
	var file = openFile(&amp;#039;ChatLog.txt&amp;#039;, true);&lt;br /&gt;
	if(!file)&lt;br /&gt;
		return;&lt;br /&gt;
	file.writeBytes(filePreviousData+text+&amp;quot;\r\n&amp;quot;);&lt;br /&gt;
	file.close();&lt;br /&gt;
} }}&lt;/div&gt;</summary>
		<author><name>Mex</name></author>
	</entry>
</feed>