GetElementRadius: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
(Added OOP syntax introduced in r6987 and improved the page)
 
(14 intermediate revisions by 7 users not shown)
Line 1: Line 1:
{{Client function}}
{{Client function}}
__NOTOC__
__NOTOC__
This function gets the radius from a element.
This function gets the radius of an [[element]]. Normally, sphere or circle-shaped elements tend to return a more accurate and expected radius than others with another shapes.


==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
float getElementRadius ( element theElement )
float getElementRadius ( element theElement )
</syntaxhighlight>  
</syntaxhighlight>
{{New feature/item|3.0141|1.4.0|6987|{{OOP||[[element]]:getRadius|radius}}}}


===Required Arguments===  
===Required Arguments===  
*'''theElement:''' The element.
*'''theElement:''' The element to get the radius of. It can be any entity type, such as:
** '''[[player|Players]]'''.
** '''[[ped|Peds]]'''.
** '''[[vehicle|Vehicles]]'''.
** '''[[object|Objects]]'''.


===Returns===
===Returns===
Returns ''float'' as radius, ''false'' otherwise.
Returns a ''float'' containing the radius if the element is valid, ''false'' otherwise.


==Example==  
==Example==  
<section name="Client" class="client" show="true">
This example shows how to get and output the radius of every player who types the ''/getmyradius'' command (which will always be ''1'').
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
-- Add example..
local function outputLocalPlayerRadius()
    outputChatBox("Your radius is " .. getElementRadius(localPlayer))
end
addCommandHandler("getmyradius", outputLocalPlayerRadius)
</syntaxhighlight>
</syntaxhighlight>
</section>


==See Also==
==See Also==
{{Client element functions}}
{{Client element functions}}
[[Category:Needs Example]]
[[Category:Incomplete]]

Latest revision as of 13:53, 31 December 2014

This function gets the radius of an element. Normally, sphere or circle-shaped elements tend to return a more accurate and expected radius than others with another shapes.

Syntax

float getElementRadius ( element theElement )

OOP Syntax Help! I don't understand this!

Method: element:getRadius(...)
Variable: .radius

Required Arguments

Returns

Returns a float containing the radius if the element is valid, false otherwise.

Example

This example shows how to get and output the radius of every player who types the /getmyradius command (which will always be 1).

local function outputLocalPlayerRadius()
    outputChatBox("Your radius is " .. getElementRadius(localPlayer))
end
addCommandHandler("getmyradius", outputLocalPlayerRadius)

See Also