<?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=Adolfram</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=Adolfram"/>
	<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/wiki/Special:Contributions/Adolfram"/>
	<updated>2026-06-16T10:47:04Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.3</generator>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=OnPlayerWeaponFire&amp;diff=55676</id>
		<title>OnPlayerWeaponFire</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=OnPlayerWeaponFire&amp;diff=55676"/>
		<updated>2018-07-05T20:41:43Z</updated>

		<summary type="html">&lt;p&gt;Adolfram: /* Example */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Server event}}&lt;br /&gt;
__NOTOC__ &lt;br /&gt;
{{New feature/item|3.0153|1.5.3|9921|&lt;br /&gt;
This event is called when a player fires a weapon.  This does not trigger for projectiles, melee weapons, or camera.&lt;br /&gt;
}}&lt;br /&gt;
{{Note|This event works only with weapons which have enabled bullet sync.}}&lt;br /&gt;
==Parameters==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
int weapon, float endX, float endY, float endZ, element hitElement, float startX, float startY, float startZ&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
*'''weapon''':  an [[int]] representing [[weapons|weapon]] used for making a shot.&lt;br /&gt;
*'''endX''', '''endY''', '''endZ''': [[float]] world coordinates representing an end point.&lt;br /&gt;
*'''hitElement''': an [[element]] which was hit by a shot. Currently this can be only another [[player]]. '''Note: hitElement could be incorrect and should not be relied upon.'''&lt;br /&gt;
*'''startX''', '''startY''', '''startZ''': [[float]] world coordinates representing the start of the bullet. '''Note: This is not the gun muzzle.'''&lt;br /&gt;
&lt;br /&gt;
==Source==&lt;br /&gt;
The [[event system#Event source|source]] of this event is the [[player]] who fired the weapon.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
This code creates explosions when the source players shoots.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
addEventHandler (&amp;quot;onPlayerWeaponFire&amp;quot;, root, &lt;br /&gt;
   function (weapon, endX, endY, endZ, hitElement, startX, startY, startZ)&lt;br /&gt;
       createExplosion(endX, endY, endZ, 2, source);&lt;br /&gt;
   end&lt;br /&gt;
)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{See also/Server event|Player events}}&lt;/div&gt;</summary>
		<author><name>Adolfram</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=GetThisResource&amp;diff=49958</id>
		<title>GetThisResource</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GetThisResource&amp;diff=49958"/>
		<updated>2016-12-22T21:26:48Z</updated>

		<summary type="html">&lt;p&gt;Adolfram: changed &amp;quot;event&amp;quot; to &amp;quot;command&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Server client function}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function retrieves the resource from which the function call was made.&lt;br /&gt;
&lt;br /&gt;
Note: every resource has a predefined global variable called ''resource'' that contains the resource pointer for that resource, in other words, the value that this function returns.&lt;br /&gt;
&lt;br /&gt;
==Syntax== &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
resource getThisResource ( )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns the resource in which the current script is.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
This example retrieves the current resource's root element and attaches it to an onResourceStart event handler. This causes the event handler to get called only when the ''current'' resource is started rather than when ''any'' resource is started, thereby reducing unnecessary overhead.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- get the root element of this resource (the resource that the script is a part of)&lt;br /&gt;
resourceRoot = getResourceRootElement(getThisResource()) &lt;br /&gt;
--getThisResource() is the same thing as MTA's secret global variable &lt;br /&gt;
--&amp;quot;resource&amp;quot; as explained in the note above. &lt;br /&gt;
&lt;br /&gt;
-- create a function to handle the command&lt;br /&gt;
function onResourceCommand()&lt;br /&gt;
   local thisResource = getThisResource()&lt;br /&gt;
   local resourceName = getResourceName(thisResource)&lt;br /&gt;
   outputChatBox(&amp;quot;You are in the &amp;quot; .. resourceName .. &amp;quot; resource!&amp;quot;)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- add the command handler&lt;br /&gt;
addCommandHandler(&amp;quot;what&amp;quot;, onResourceCommand)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Resource_functions}}&lt;/div&gt;</summary>
		<author><name>Adolfram</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=OnPlayerWeaponFire&amp;diff=49508</id>
		<title>OnPlayerWeaponFire</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=OnPlayerWeaponFire&amp;diff=49508"/>
		<updated>2016-10-11T23:13:09Z</updated>

		<summary type="html">&lt;p&gt;Adolfram: /* Example */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Server event}}&lt;br /&gt;
__NOTOC__ &lt;br /&gt;
{{New feature/item|3.0160|1.5.3|9921|&lt;br /&gt;
This event is called when a player fires a weapon.  This does not trigger for projectiles, melee weapons, or camera.&lt;br /&gt;
}}&lt;br /&gt;
{{Note|This event works only with weapons which have enabled bullet sync.}}&lt;br /&gt;
==Parameters==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
int weapon, float endX, float endY, float endZ, element hitElement, float startX, float startY, float startZ&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
*'''weapon''':  an [[int]] representing [[weapons|weapon]] used for making a shot.&lt;br /&gt;
*'''endX''', '''endY''', '''endZ''': [[float]] world coordinates representing an end point.&lt;br /&gt;
*'''hitElement''': an [[element]] which was hit by a shot.&lt;br /&gt;
*'''startX''', '''startY''', '''startZ''': [[float]] world coordinates representing the start of the bullet. Note: This is not the gun muzzle.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
{{Example}}&lt;br /&gt;
&lt;br /&gt;
{{See also/Server event|Player events}}&lt;br /&gt;
&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 code outputs the information on debug screen when a player shoots.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
addEventHandler (&amp;quot;onPlayerWeaponFire&amp;quot;, root, &lt;br /&gt;
   function (weapon, endX, endY, endZ, hitElement, startX, startY, startZ)&lt;br /&gt;
       iprint (getPlayerName(source).. &amp;quot; just shot a &amp;quot; .. getElementType (hitElement) .. &amp;quot; at X: &amp;quot;.. endX .. &amp;quot; Y: &amp;quot; .. endY .. &amp;quot; Z: &amp;quot; .. endZ .. &amp;quot; from X: &amp;quot; .. startX .. &amp;quot; Y: &amp;quot;.. startY .. &amp;quot; Z: &amp;quot; .. startZ .. &amp;quot; with a &amp;quot;.. getWeaponNameFromID (weapon))&lt;br /&gt;
   end&lt;br /&gt;
)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;/div&gt;</summary>
		<author><name>Adolfram</name></author>
	</entry>
</feed>