<?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%2FBasicCommand</id>
	<title>ScriptingExamples/BasicCommand - 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%2FBasicCommand"/>
	<link rel="alternate" type="text/html" href="https://wiki.gtaconnected.com/wiki/index.php?title=ScriptingExamples/BasicCommand&amp;action=history"/>
	<updated>2026-06-14T01:04:52Z</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/BasicCommand&amp;diff=4457&amp;oldid=prev</id>
		<title>Bluesn0w at 17:13, 27 December 2018</title>
		<link rel="alternate" type="text/html" href="https://wiki.gtaconnected.com/wiki/index.php?title=ScriptingExamples/BasicCommand&amp;diff=4457&amp;oldid=prev"/>
		<updated>2018-12-27T17:13:13Z</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:Basic Command}}&lt;br /&gt;
== Description ==&lt;br /&gt;
&lt;br /&gt;
This code adds a red chat message to the chat box when any player types /text&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
All examples below do the same thing, in terms of adding the chat message when the command is typed.&amp;lt;br&amp;gt;&lt;br /&gt;
Two examples are shown for each supported scripting language, 1 with a global function, 1 with a lambda function. Lambda functions are favoured.&amp;lt;br&amp;gt;&lt;br /&gt;
All examples below are server-side code, not client-side code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;JavaScript - Global Function&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
{{JSCode|1=function textCommand(command, args, client) {&lt;br /&gt;
	message(&amp;#039;This text is displayed in the chatbox when /text is typed ingame.&amp;#039;, COLOUR_RED);&lt;br /&gt;
};&lt;br /&gt;
addCommandHandler(&amp;#039;text&amp;#039;, textCommand);}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;JavaScript - Lambda Function&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
{{JSCode|1=addCommandHandler(&amp;#039;text&amp;#039;, function(command, args, client) {&lt;br /&gt;
	message(&amp;#039;This text is displayed in the chatbox when /text is typed ingame.&amp;#039;, COLOUR_RED);&lt;br /&gt;
});}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Squirrel - Global Function&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
{{SquirrelCode|1=function textCommand(command, args, client) {&lt;br /&gt;
	message(&amp;#039;This text is displayed in the chatbox when /text is typed ingame.&amp;#039;, COLOUR_RED);&lt;br /&gt;
};&lt;br /&gt;
addCommandHandler(&amp;#039;text&amp;#039;, textCommand);}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Squirrel - Lambda Function&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
{{SquirrelCode|1=addCommandHandler(&amp;#039;text&amp;#039;, function(command, args, client) {&lt;br /&gt;
	message(&amp;#039;This text is displayed in the chatbox when /text is typed ingame.&amp;#039;, COLOUR_RED);&lt;br /&gt;
});}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Lua - Global Function&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
{{LuaCode|1=function textCommand(command, args, client)&lt;br /&gt;
	message(&amp;#039;This text is displayed in the chatbox when /text is typed ingame.&amp;#039;, COLOUR_RED)&lt;br /&gt;
end&lt;br /&gt;
addCommandHandler(&amp;#039;text&amp;#039;, textCommand)}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Lua - Lambda Function&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
{{LuaCode|1=addCommandHandler(&amp;#039;text&amp;#039;, function(command, args, client)&lt;br /&gt;
	message(&amp;#039;This text is displayed in the chatbox when /text is typed ingame.&amp;#039;, COLOUR_RED)&lt;br /&gt;
end)}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Notes ==&lt;br /&gt;
&lt;br /&gt;
The code uses [[addCommandHandler|addCommandHandler]], which is a shared function, shared means that the functionality is available both server-side and client-side.&amp;lt;br&amp;gt;&lt;br /&gt;
The code uses COLOUR_RED which is a server define, see [[Server/Defines#Colour_Defines|Server Colour Defines]].&lt;/div&gt;</summary>
		<author><name>Bluesn0w</name></author>
	</entry>
</feed>