<?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=CXo</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=CXo"/>
	<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/wiki/Special:Contributions/CXo"/>
	<updated>2026-04-14T15:27:50Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.3</generator>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=GetPedWeaponMuzzlePosition&amp;diff=41023</id>
		<title>GetPedWeaponMuzzlePosition</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GetPedWeaponMuzzlePosition&amp;diff=41023"/>
		<updated>2014-07-24T21:38:04Z</updated>

		<summary type="html">&lt;p&gt;CXo: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Client function}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Returns the world position of the muzzle of the weapon that a ped is currently carrying. The weapon muzzle is the end of the gun barrel where the bullets/rockets/... come out.&lt;br /&gt;
&lt;br /&gt;
The position may not be accurate if the ped is off screen.&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;float, float, float getPedWeaponMuzzlePosition ( ped thePed )&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
*'''thePed:''' the ped whose weapon muzzle position to retrieve.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
If successful, returns the x/y/z coordinates of the weapon muzzle. Returns ''false'' otherwise.&lt;br /&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;
This Example draws a red 3D-Line when a Player shoots,between the Players WeaponMuzzlePosition and the Point where the Bullet hits.[Tested]&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
	&lt;br /&gt;
function OnPlayerFire(w,a,aC,hX,hY,hZ,hE)-- the function to which onClientPlayerFire is attached, contains the Paramteres for the the Bullet hit Position&lt;br /&gt;
 local sx,sy,sz = getPedWeaponMuzzlePosition(source)-- get the WeaponMuzzlePosition of the Player who shot&lt;br /&gt;
 Position = {sx,sy,sz,hX,hY,hZ} -- save it in a table so we can use it later in 'onClientRender'function&lt;br /&gt;
 removeEventHandler(&amp;quot;onClientRender&amp;quot;,root,onRender)-- remove onClientRender-Event from function onRender  to not have multiple add for same function&lt;br /&gt;
 addEventHandler(&amp;quot;onClientRender&amp;quot;,root,onRender) -- add the onClientRender-Event to the function onRender&lt;br /&gt;
end -- end of function onPlayerFire&lt;br /&gt;
addEventHandler(&amp;quot;onClientPlayerWeaponFire&amp;quot;,root,OnPlayerFire)&lt;br /&gt;
&lt;br /&gt;
function onRender() -- function to which onClientRender-Event will be attached.&lt;br /&gt;
 if Position then -- check if there are Positions available&lt;br /&gt;
  local startX,startY,startZ,endX,endY,endZ = unpack(Position)-- unpack the Position table&lt;br /&gt;
  dxDrawLine3D( startX,startY,startZ,endX,endY,endZ,tocolor(200,0,0,255),3) -- draws the 3D line between start-Position and end-Position&lt;br /&gt;
 end -- end of if&lt;br /&gt;
end -- end of onRender&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Client ped functions}}&lt;/div&gt;</summary>
		<author><name>CXo</name></author>
	</entry>
</feed>