<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.multitheftauto.com/wiki/DxDrawRectangleOnPlayer?action=history&amp;feed=atom</id>
	<title>DxDrawRectangleOnPlayer - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.multitheftauto.com/wiki/DxDrawRectangleOnPlayer?action=history&amp;feed=atom"/>
	<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=DxDrawRectangleOnPlayer&amp;action=history"/>
	<updated>2026-05-08T05:06:35Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.3</generator>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=DxDrawRectangleOnPlayer&amp;diff=72963&amp;oldid=prev</id>
		<title>Hydra: Created page with &quot;{{Useful Function}} __NOTOC__ This function draws 3D rectangles above the player.&lt;br&gt; * '''NOTE:''' The structure of the code was made based on the greenzone tag resource!.  =...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=DxDrawRectangleOnPlayer&amp;diff=72963&amp;oldid=prev"/>
		<updated>2021-10-26T19:34:30Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;{{Useful Function}} __NOTOC__ This function draws 3D rectangles above the player.&amp;lt;br&amp;gt; * &amp;#039;&amp;#039;&amp;#039;NOTE:&amp;#039;&amp;#039;&amp;#039; The structure of the code was made based on the greenzone tag resource!.  =...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Useful Function}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function draws 3D rectangles above the player.&amp;lt;br&amp;gt;&lt;br /&gt;
* '''NOTE:''' The structure of the code was made based on the greenzone tag resource!.&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;bool dxDrawRectangleOnPlayer ( float x, float y, float width, float height, int color )&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
* '''X:''' The x position of the rectangle.&lt;br /&gt;
* '''Y:''' The y position of the rectangle.&lt;br /&gt;
* '''WIDTH:''' The width of the rectangle.&lt;br /&gt;
* '''HEIGHT:''' The width of the rectangle.&lt;br /&gt;
* '''COLOR:''' The color of the rectangle using tocolor.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns a ''true'' if the operation was successful, ''false'' otherwise.&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Clientside script&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;&lt;br /&gt;
function dxDrawRectangleOnPlayer(x, y, width, height, color)&lt;br /&gt;
   local players = getElementsByType(&amp;quot;player&amp;quot;, root, true)&lt;br /&gt;
   if players then&lt;br /&gt;
   local x, y, z = getElementPosition(localPlayer)&lt;br /&gt;
	for _, v in ipairs(players) do&lt;br /&gt;
	    if v and isElement(v) then&lt;br /&gt;
		local px, py, pz = getElementPosition(v)&lt;br /&gt;
		if getDistanceBetweenPoints3D(x, y, z, px, py, pz) &amp;lt;= 20 then&lt;br /&gt;
		   local sx, sy = getScreenFromWorldPosition(px, py, pz + 1.3)&lt;br /&gt;
		   if sx and sy then&lt;br /&gt;
		   dxDrawRectangle(sx + x, sy + y/1.6, width, height, color, false)&lt;br /&gt;
                end&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
This example draws 2 rectangles above the player&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local sx, sy = guiGetScreenSize()&lt;br /&gt;
&lt;br /&gt;
function t()&lt;br /&gt;
   dxDrawRectangleOnPlayer(sx * 0.5300, sy * 0.0500, sx * 0.0800, sy * 0.0600, tocolor(255, 0, 0, 255))&lt;br /&gt;
   dxDrawRectangleOnPlayer(sx * 1.0000, sy * 0.0500, sx * 0.0300, sy * 0.0600, tocolor(255, 167, 0, 255))&lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;onClientRender&amp;quot;, root, t)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Author: Hydra&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Useful_Functions}}&lt;/div&gt;</summary>
		<author><name>Hydra</name></author>
	</entry>
</feed>