<?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=Ambassador64</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=Ambassador64"/>
	<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/wiki/Special:Contributions/Ambassador64"/>
	<updated>2026-05-17T09:05:32Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.3</generator>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=SetPedAimTarget&amp;diff=81905</id>
		<title>SetPedAimTarget</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=SetPedAimTarget&amp;diff=81905"/>
		<updated>2025-04-06T17:16:17Z</updated>

		<summary type="html">&lt;p&gt;Ambassador64: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Client function}}&lt;br /&gt;
This function allows you to set a ped's aim target to a specific point. If a ped is within a certain range defined by [[getPedTargetStart]] and [[getPedTargetEnd]] he will be targeted and shot. &lt;br /&gt;
&lt;br /&gt;
''Note: If you wish to make a ped shoot you must use this in conjunction with an equipped weapon and [[setPedControlState]].  Also for akimbo weapons such as 22, 26, 28, 32 and the sniper rifle you must also set both aim_weapon and fire to true at least once.''&lt;br /&gt;
&lt;br /&gt;
==Syntax== &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
bool setPedAimTarget ( ped thePed, float x, float y, float z )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''thePed:''' The ped whose target you want to set. Only peds and remote players will work; this function has no effect on the local player.&lt;br /&gt;
*'''x:''' The x coordinate of the aim target point.&lt;br /&gt;
*'''y:''' The y coordinate of the aim target point.&lt;br /&gt;
*'''z:''' The z coordinate of the aim target point.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns ''true'' if the function was successful, ''false'' otherwise.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
'''Example 1:''' This example creates a ped in the middle of the map and sets its aim target to point north-east.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function createPedAndsetHisAimTarget ()&lt;br /&gt;
        local ped = createPed (0, 0, 0, 5 ) -- create a ped, who looks like cj, in the middle of the map&lt;br /&gt;
        setPedAimTarget ( ped, 10, 10, 5 ) -- set the ped's target to a point in North-East&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Example 2:''' This example creates a ped at grove street that will shoot at anything that enters a certain marker.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local cj = createPed(0, 2498.5, -1684.0, 13.5, 20) -- create a ped at cjs house in grove street and give it an ak&lt;br /&gt;
givePedWeapon(cj, 30, 3000, true)&lt;br /&gt;
&lt;br /&gt;
local marker = createMarker(2493.0, -1669.0, 13.5, &amp;quot;checkpoint&amp;quot;, 3, 255, 0, 0, 128) -- create a marker and get its associated colshape for later use&lt;br /&gt;
local colshape = getElementColShape(marker)&lt;br /&gt;
&lt;br /&gt;
function renderHandler()&lt;br /&gt;
	local intruder = getElementsWithinColShape(colshape)[2] -- get the second element found within the colshape, because the first one will normally be the marker itself&lt;br /&gt;
	if intruder then&lt;br /&gt;
		local x,y,z = getElementPosition(intruder) -- if an intruder exists, get its position and have the cj ped fire at it&lt;br /&gt;
		setPedAimTarget(cj, x, y, z)&lt;br /&gt;
		setPedControlState(cj, &amp;quot;fire&amp;quot;, true)&lt;br /&gt;
		setPedControlState(cj, &amp;quot;aim_weapon&amp;quot;, true) -- needed for akimbo weapons (22, 26, 28, 32) and the sniper rifle&lt;br /&gt;
	else&lt;br /&gt;
		setPedControlState(cj, &amp;quot;fire&amp;quot;, false) -- otherwise stop shooting&lt;br /&gt;
		setPedControlState(cj, &amp;quot;aim_weapon&amp;quot;, false)&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;onClientRender&amp;quot;, root, renderHandler) -- add an event handler to go through the target acquisition procedure every frame&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Client ped functions}}&lt;/div&gt;</summary>
		<author><name>Ambassador64</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=SetPedAimTarget&amp;diff=81904</id>
		<title>SetPedAimTarget</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=SetPedAimTarget&amp;diff=81904"/>
		<updated>2025-04-06T17:15:20Z</updated>

		<summary type="html">&lt;p&gt;Ambassador64: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Client function}}&lt;br /&gt;
This function allows you to set a ped's aim target to a specific point. If a ped is within a certain range defined by [[getPedTargetStart]] and [[getPedTargetEnd]] he will be targeted and shot. &lt;br /&gt;
&lt;br /&gt;
''Note: If you wish to make a ped shoot you must use this in conjunction with an equipped weapon and [[setPedControlState]].  Also for akimbo weapons such as 22, 26, 28, 32 and the sniper rifle you must also set both aim_weapon and fire to true at least once.''&lt;br /&gt;
&lt;br /&gt;
==Syntax== &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
bool setPedAimTarget ( ped thePed, float x, float y, float z )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''thePed:''' The ped whose target you want to set. Only peds and remote players will work; this function has no effect on the local player.&lt;br /&gt;
*'''x:''' The x coordinate of the aim target point.&lt;br /&gt;
*'''y:''' The y coordinate of the aim target point.&lt;br /&gt;
*'''z:''' The z coordinate of the aim target point.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns ''true'' if the function was successful, ''false'' otherwise.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
'''Example 1:''' This example creates a ped in the middle of the map and sets its aim target to point north-east.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function createPedAndsetHisAimTarget ()&lt;br /&gt;
        local ped = createPed (0, 0, 0, 5 ) -- create a ped, who looks like cj, in the middle of the map&lt;br /&gt;
        setPedAimTarget ( ped, 10, 10, 5 ) -- set the ped's target to a point in North-East&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Example 2:''' This example creates a ped at grove street that will shoot at anything that enters a certain marker.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local cj = createPed(0, 2498.5, -1684.0, 13.5, 20) -- create a ped at cjs house in grove street and give it an ak&lt;br /&gt;
givePedWeapon(cj, 30, 3000, true)&lt;br /&gt;
&lt;br /&gt;
local marker = createMarker(2493.0, -1669.0, 13.5, &amp;quot;checkpoint&amp;quot;, 3, 255, 0, 0, 128) -- create a marker and get its associated colshape for later use&lt;br /&gt;
local colshape = getElementColShape(marker)&lt;br /&gt;
&lt;br /&gt;
function renderHandler()&lt;br /&gt;
	local intruder = getElementsWithinColShape(colshape)[2] -- get the second element found within the colshape, because the first one will normally be the marker itself&lt;br /&gt;
	if intruder then&lt;br /&gt;
		local x,y,z = getElementPosition(intruder) -- if an intruder exists, get its position and have the cj ped fire at it&lt;br /&gt;
		setPedAimTarget(cj, x, y, z)&lt;br /&gt;
		setPedControlState(cj, &amp;quot;fire&amp;quot;, true)&lt;br /&gt;
		setPedControlState(cj, &amp;quot;aim_weapon&amp;quot;, true) -- needed for akimbo weapons (22, 26, 28, 32) and the sniper rifle&lt;br /&gt;
	else&lt;br /&gt;
		setPedControlState(cj, &amp;quot;fire&amp;quot;, false) -- otherwise stop shooting&lt;br /&gt;
		setPedControlState(cj, &amp;quot;aim_weapon&amp;quot;, false)&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;onClientRender&amp;quot;, getRootElement(), renderHandler) -- add an event handler to go through the target acquisition procedure every frame&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Client ped functions}}&lt;/div&gt;</summary>
		<author><name>Ambassador64</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=SetPedAimTarget&amp;diff=81903</id>
		<title>SetPedAimTarget</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=SetPedAimTarget&amp;diff=81903"/>
		<updated>2025-04-06T17:13:16Z</updated>

		<summary type="html">&lt;p&gt;Ambassador64: Adding info for aim_weapon control state.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Client function}}&lt;br /&gt;
This function allows you to set a ped's aim target to a specific point. If a ped is within a certain range defined by [[getPedTargetStart]] and [[getPedTargetEnd]] he will be targeted and shot. &lt;br /&gt;
&lt;br /&gt;
''Note: If you wish to make a ped shoot you must use this in conjunction with an equipped weapon and [[setPedControlState]].  Also for akimbo weapons such as 22, 26, 28, 32 and the sniper rifle you must also set both aim_weapon and fire to true at least once.''&lt;br /&gt;
&lt;br /&gt;
==Syntax== &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
bool setPedAimTarget ( ped thePed, float x, float y, float z )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''thePed:''' The ped whose target you want to set. Only peds and remote players will work; this function has no effect on the local player.&lt;br /&gt;
*'''x:''' The x coordinate of the aim target point.&lt;br /&gt;
*'''y:''' The y coordinate of the aim target point.&lt;br /&gt;
*'''z:''' The z coordinate of the aim target point.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns ''true'' if the function was successful, ''false'' otherwise.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
'''Example 1:''' This example creates a ped in the middle of the map and sets its aim target to point north-east.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function createPedAndsetHisAimTarget ()&lt;br /&gt;
        local ped = createPed (0, 0, 0, 5 ) -- create a ped, who looks like cj, in the middle of the map&lt;br /&gt;
        setPedAimTarget ( ped, 10, 10, 5 ) -- set the ped's target to a point in North-East&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Example 2:''' This example creates a ped at grove street that will shoot at anything that enters a certain marker.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local cj = createPed(0, 2498.5, -1684.0, 13.5, 20) -- create a ped at cjs house in grove street and give it an ak&lt;br /&gt;
givePedWeapon(cj, 30, 3000, true)&lt;br /&gt;
&lt;br /&gt;
local marker = createMarker(2493.0, -1669.0, 13.5, &amp;quot;checkpoint&amp;quot;, 3, 255, 0, 0, 128) -- create a marker and get its associated colshape for later use&lt;br /&gt;
local colshape = getElementColShape(marker)&lt;br /&gt;
&lt;br /&gt;
function renderHandler()&lt;br /&gt;
	local intruder = getElementsWithinColShape(colshape)[2] -- get the second element found within the colshape, because the first one will normally be the marker itself&lt;br /&gt;
	if intruder then&lt;br /&gt;
		local x,y,z = getElementPosition(intruder) -- if an intruder exists, get its position and have the cj ped fire at it&lt;br /&gt;
		setPedAimTarget(cj, x, y, z)&lt;br /&gt;
		setPedControlState(cj, &amp;quot;fire&amp;quot;, true)&lt;br /&gt;
        setPedControlState(cj, &amp;quot;aim_weapon&amp;quot;, true) -- needed for akimbo weapons (22, 26, 28, 32) and the sniper rifle&lt;br /&gt;
	else&lt;br /&gt;
		setPedControlState(cj, &amp;quot;fire&amp;quot;, false) -- otherwise stop shooting&lt;br /&gt;
        setPedControlState(cj, &amp;quot;aim_weapon&amp;quot;, false)&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;onClientRender&amp;quot;, getRootElement(), renderHandler) -- add an event handler to go through the target acquisition procedure every frame&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Client ped functions}}&lt;/div&gt;</summary>
		<author><name>Ambassador64</name></author>
	</entry>
</feed>