<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.multitheftauto.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Samgreen</id>
	<title>Multi Theft Auto: Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.multitheftauto.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Samgreen"/>
	<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/wiki/Special:Contributions/Samgreen"/>
	<updated>2026-04-24T05:22:32Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.3</generator>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=OnPlayerTarget&amp;diff=22436</id>
		<title>OnPlayerTarget</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=OnPlayerTarget&amp;diff=22436"/>
		<updated>2010-02-19T22:53:56Z</updated>

		<summary type="html">&lt;p&gt;Samgreen: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Server event}}&lt;br /&gt;
This event is triggered when a player targets an element with his crosshair while aiming, or simply facing it while standing close. It's triggered again when the player no longer targets anything.&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
element targettedElement&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*'''targettedElement''': The element the player is targetting. ''false'' if no element is being targetted anymore.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Add the event's source in the section below --&amp;gt;&lt;br /&gt;
==Source==&lt;br /&gt;
The [[event system#Event source|source]] of this event is the [[player]] that is targetting the element.&lt;br /&gt;
&lt;br /&gt;
==Example== &lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This example destroys a haystack when a player targets it&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function onPlayerTarget ( targetElem )&lt;br /&gt;
    -- if the targeted object is a haystack (an object with model ID 3374) remove it from the game&lt;br /&gt;
    if getElementType ( targetElem ) == &amp;quot;object&amp;quot; and getElementModel ( targetElem ) == 3374 then&lt;br /&gt;
        destroyElement ( targetElem )&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
addEventHandler ( &amp;quot;onPlayerTarget&amp;quot;, getRootElement(), onPlayerTarget )    -- add above function as handler for targeting event&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{See also/Server event|Player events}}&lt;/div&gt;</summary>
		<author><name>Samgreen</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=OnPlayerTarget&amp;diff=22435</id>
		<title>OnPlayerTarget</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=OnPlayerTarget&amp;diff=22435"/>
		<updated>2010-02-19T22:53:33Z</updated>

		<summary type="html">&lt;p&gt;Samgreen: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Server event}}&lt;br /&gt;
This event is triggered when a player targets an element with his crosshair while aiming, or simply facing it while standing close. It's triggered again when the player no longer targets anything.&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
element targettedElement&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*'''targettedElement''': The element the player is targetting. ''false'' if no element is being targetted anymore.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Add the event's source in the section below --&amp;gt;&lt;br /&gt;
==Source==&lt;br /&gt;
The [[event system#Event source|source]] of this event is the [[player]] that is targetting the element.&lt;br /&gt;
&lt;br /&gt;
==Example== &lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This example destroys a haystack when a player targets it&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function onPlayerTarget ( targetElem )&lt;br /&gt;
    -- if the targeted object is a haystack (an object with model ID 3374) remove it from the game&lt;br /&gt;
    if getElementType ( targetElem ) == &amp;quot;object&amp;quot; and getElementModel ( targetElem ) == 3374 then&lt;br /&gt;
        destroyElement ( targetElem )&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
addEventHandler ( &amp;quot;onPlayerTarget&amp;quot;, getRootElement(), onPlayerTarget )    -- add above function as handler for targeting event&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{See also/Server event|Player events}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Needs Example]]&lt;/div&gt;</summary>
		<author><name>Samgreen</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=OutputChatBox&amp;diff=22434</id>
		<title>OutputChatBox</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=OutputChatBox&amp;diff=22434"/>
		<updated>2010-02-19T20:36:26Z</updated>

		<summary type="html">&lt;p&gt;Samgreen: Removed reference to visibleTo from Client section.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Server client function}}&lt;br /&gt;
{{Note_box|Avoid outputting text to the chatbox that isn't actually chat, as this can be annoying for players. Output information and status messages to the HUD.}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This outputs the specified text string to the chatbox. It can be specified as a message to certain player(s) or all players.&lt;br /&gt;
&lt;br /&gt;
It can optionally allow you to embed color changes into the string by setting the colorCoded boolean to true. This allows: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
outputChatBox ( &amp;quot;#FF0000Hello #00FF00World&amp;quot;, getRootElement(), 255, 255, 255, true )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
This will display as: '''&amp;lt;span style='color:red;'&amp;gt;Hello&amp;lt;/span&amp;gt; &amp;lt;span style='color:green'&amp;gt;World&amp;lt;/span&amp;gt; '''&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;bool outputChatBox ( string text [, element visibleTo=getRootElement(), int r=255, int g=255, int b=255, bool colorCoded=false ] )&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Required Arguments==&lt;br /&gt;
*'''text:''' The text string that you wish to send to the chat window.&lt;br /&gt;
&lt;br /&gt;
==Optional Arguments==&lt;br /&gt;
{{OptionalArg}}&lt;br /&gt;
*'''visibleTo:''' This specifies who the chat is visible to. Any players in this element will see the chat message. See [[visibility]].&lt;br /&gt;
*'''r:''' The amount of red in the color of the text. Default value is 255.&lt;br /&gt;
*'''g:''' The amount of green in the color of the text. Default value is 255.&lt;br /&gt;
*'''b:''' The amount of blue in the color of the text. Default value is 255.&lt;br /&gt;
*'''colorCoded:''' A boolean value determining whether or not '#RRGGBB' tags should be used.&lt;br /&gt;
Note: '''visibleTo''' can also be a Team object, in this case, the text will be visible to all the players of that team. Also the #RRGGBB format must contain capital letters a-f is not acceptable but A-F is.&lt;br /&gt;
&amp;lt;/section&amp;gt;&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;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;bool outputChatBox ( string text [, int r=255, int g=255, int b=255, bool colorCoded=false ] )&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Required Arguments==&lt;br /&gt;
*'''text:''' The text string that you wish to send to the chat window.&lt;br /&gt;
&lt;br /&gt;
==Optional Arguments==&lt;br /&gt;
{{OptionalArg}}&lt;br /&gt;
*'''r:''' The amount of red in the color of the text. Default value is 255.&lt;br /&gt;
*'''g:''' The amount of green in the color of the text. Default value is 255.&lt;br /&gt;
*'''b:''' The amount of blue in the color of the text. Default value is 255.&lt;br /&gt;
*'''colorCoded:''' A boolean value determining whether or not '#RRGGBB' tags should be used.&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Returns==&lt;br /&gt;
Returns ''true'' if the message was displayed successfully. Returns ''false'' if invalid arguments are specified.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
'''Example 1:''' This example displays a chat message to all users.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
x = 5&lt;br /&gt;
y = 10  &lt;br /&gt;
-- Displays the message&lt;br /&gt;
outputChatBox ( &amp;quot;I have &amp;quot; .. x .. &amp;quot; apples and &amp;quot; .. y .. &amp;quot; oranges.&amp;quot; )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Example 2:''' This example outputs a simple colour coded message, &amp;quot;Red White&amp;quot;, where the 'White' is in white colour, and 'Red' is in a red colour.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
 outputChatBox ( &amp;quot;Red #FFFFFFWhite&amp;quot;, getRootElement(), 255, 0, 0, true )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Example 3:''' This example allows for coloured chat, according to a player's nametag.  This makes use of colour coded outputs.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function colouredChat ( message, theType )&lt;br /&gt;
	if theType == 0 then --if its normal chat (not /me or teamchat) then&lt;br /&gt;
		cancelEvent() --prevent MTA from outputting chat&lt;br /&gt;
		message = string.gsub(message, &amp;quot;#%x%x%x%x%x%x&amp;quot;, &amp;quot;&amp;quot;) --remove any hex tags in a player's chat to prevent custom colours by using lua's string.gsub&lt;br /&gt;
		local r,g,b = getPlayerNametagColor ( source ) --get the player's nametag colour&lt;br /&gt;
		local chatterName = getPlayerName ( source ) --get his name&lt;br /&gt;
		--output a message with the name as his nametag colour, and the rest in white.&lt;br /&gt;
		outputChatBox ( chatterName..&amp;quot;:#FFFFFF &amp;quot;..message, getRootElement(), r, g, b, true )&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Example 4:''' This example displays a chat message to a single user called ''someguy''.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Find the player element for the player called 'someguy'&lt;br /&gt;
myPlayer = getPlayerFromNick ( &amp;quot;someguy&amp;quot; )&lt;br /&gt;
-- If a player was found called 'someguy' then...&lt;br /&gt;
if ( myPlayer ~= false ) then&lt;br /&gt;
    x = 5&lt;br /&gt;
    y = 10&lt;br /&gt;
    -- Display the message&lt;br /&gt;
    outputChatBox ( &amp;quot;I have &amp;quot; .. x .. &amp;quot; apples and &amp;quot; .. y .. &amp;quot; oranges.&amp;quot;, myPlayer )&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Example 5:''' These two functions can speed up typing, and display a message when a player Joins.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local msg_red,msg_green,msg_blue = 255,255,0&lt;br /&gt;
&lt;br /&gt;
function servertalkprivate(message, sendto)&lt;br /&gt;
        --Talk to one client only&lt;br /&gt;
	outputChatBox(tostring(message), sendto, msg_red, msg_green, msg_blue, true)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function servertalk(message)&lt;br /&gt;
        --Talk to everyone&lt;br /&gt;
	servertalkprivate(message, getRootElement())&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function onJoin()&lt;br /&gt;
	servertalkprivate(&amp;quot;Welcome to My Server&amp;quot;, source)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
addEventHandler(&amp;quot;onPlayerJoin&amp;quot;,getRootElement(),onJoin)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Server functions}}&lt;/div&gt;</summary>
		<author><name>Samgreen</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=OnClientResourceStart&amp;diff=22433</id>
		<title>OnClientResourceStart</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=OnClientResourceStart&amp;diff=22433"/>
		<updated>2010-02-19T20:22:29Z</updated>

		<summary type="html">&lt;p&gt;Samgreen: Fixed a minor typo.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Client event}}&lt;br /&gt;
__NOTOC__ &lt;br /&gt;
This event is triggered when a [[resource]] is started.  Please note that this is '''not''' triggered the same time as the serverside event [[onResourceStart]] is.  The event is triggered when any ''clientside resources'' are started.  This means it is triggered when a clientside script is initiated after a download, which includes downloading after join. So:&lt;br /&gt;
&lt;br /&gt;
* If a resource is running '''before''' a player joins, the onClientResourceStart event will be triggered after they join and have downloaded that resource.&lt;br /&gt;
* If a resource is started '''after''' a player has joined, the player will be made to download the required files, and then the onClientResourceStart event will be triggered.&lt;br /&gt;
&lt;br /&gt;
==Parameters== &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
resource startedResource&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*'''startedResource''': the [[resource]] that was started.&lt;br /&gt;
&lt;br /&gt;
==Source==&lt;br /&gt;
The [[event system#Event source|source]] of this event is the started resource's [[root element]].&lt;br /&gt;
&lt;br /&gt;
==Example== &lt;br /&gt;
This example outputs name of resource that was started.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
addEventHandler( &amp;quot;onClientResourceStart&amp;quot;, getRootElement( ),&lt;br /&gt;
    function ( startedRes )&lt;br /&gt;
        outputChatBox( &amp;quot;Resource started: &amp;quot; .. getResourceName( startedRes ) );&lt;br /&gt;
    end&lt;br /&gt;
);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
===Client resource events===&lt;br /&gt;
{{Client_resource_events}}&lt;br /&gt;
===Client event functions===&lt;br /&gt;
{{Client_event_functions}}&lt;/div&gt;</summary>
		<author><name>Samgreen</name></author>
	</entry>
</feed>