<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.gtaconnected.com/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Bluesn0w</id>
	<title>GTA Connected - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.gtaconnected.com/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Bluesn0w"/>
	<link rel="alternate" type="text/html" href="https://wiki.gtaconnected.com/Special:Contributions/Bluesn0w"/>
	<updated>2026-05-10T17:33:14Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.15</generator>
	<entry>
		<id>https://wiki.gtaconnected.com/wiki/index.php?title=ScriptingExamples/BasicCommand&amp;diff=4457</id>
		<title>ScriptingExamples/BasicCommand</title>
		<link rel="alternate" type="text/html" href="https://wiki.gtaconnected.com/wiki/index.php?title=ScriptingExamples/BasicCommand&amp;diff=4457"/>
		<updated>2018-12-27T17:13:13Z</updated>

		<summary type="html">&lt;p&gt;Bluesn0w: &lt;/p&gt;
&lt;hr /&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;
&#039;&#039;&#039;JavaScript - Global Function&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{{JSCode|1=function textCommand(command, args, client) {&lt;br /&gt;
	message(&#039;This text is displayed in the chatbox when /text is typed ingame.&#039;, COLOUR_RED);&lt;br /&gt;
};&lt;br /&gt;
addCommandHandler(&#039;text&#039;, textCommand);}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;JavaScript - Lambda Function&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{{JSCode|1=addCommandHandler(&#039;text&#039;, function(command, args, client) {&lt;br /&gt;
	message(&#039;This text is displayed in the chatbox when /text is typed ingame.&#039;, COLOUR_RED);&lt;br /&gt;
});}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Squirrel - Global Function&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{{SquirrelCode|1=function textCommand(command, args, client) {&lt;br /&gt;
	message(&#039;This text is displayed in the chatbox when /text is typed ingame.&#039;, COLOUR_RED);&lt;br /&gt;
};&lt;br /&gt;
addCommandHandler(&#039;text&#039;, textCommand);}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Squirrel - Lambda Function&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{{SquirrelCode|1=addCommandHandler(&#039;text&#039;, function(command, args, client) {&lt;br /&gt;
	message(&#039;This text is displayed in the chatbox when /text is typed ingame.&#039;, COLOUR_RED);&lt;br /&gt;
});}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Lua - Global Function&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{{LuaCode|1=function textCommand(command, args, client)&lt;br /&gt;
	message(&#039;This text is displayed in the chatbox when /text is typed ingame.&#039;, COLOUR_RED)&lt;br /&gt;
end&lt;br /&gt;
addCommandHandler(&#039;text&#039;, textCommand)}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Lua - Lambda Function&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{{LuaCode|1=addCommandHandler(&#039;text&#039;, function(command, args, client)&lt;br /&gt;
	message(&#039;This text is displayed in the chatbox when /text is typed ingame.&#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>