GetRadarAreaSize: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Added OOP syntax)
 
(5 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{Needs_Checking|Need confirmnation on what exactly size means. [[User:Erorr404|Erorr404]]}}
__NOTOC__  
__NOTOC__  
Used for getting the X and Y size of an existing radar area.
{{Server client function}}
This function is used for getting the X and Y size of an existing [[radararea|radar area]].


==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
float float getRadarAreaSize ( radararea theRadararea )               
float, float getRadarAreaSize ( radararea theRadararea )               
</syntaxhighlight>  
</syntaxhighlight>  
{{OOP||[[radararea]]:getSize}}


===Required Arguments===  
===Required Arguments===  
*'''theRadararea:''' The radararea element whose size you wish to get.
*'''theRadararea:''' The [[radararea|radar area]] element whose size you wish to get.


===Returns===
===Returns===
Returns two ''floats'' indicating the X and Y length of the radar area respectively, ''false'' if the radar area doesn't exist.
Returns two ''floats'' indicating the X and Y length of the radar area respectively, ''false'' if the radar area is invalid.


==Example==  
==Example==
The following example looks for radar areas whose size is smaller than 100 by 100:
The following example looks for radar areas whose size is smaller than 100 by 100:
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
radarareas = getElementsByType ( "radararea" ) -- get a tabele of radararea elements
local radarareas = getElementsByType ( "radararea" ) -- get a table of radararea elements
for k,v in radarareas do -- use a generic for loop to step through each of the elements
for k, theArea in ipairs(radarareas) do -- use a generic for loop to step through each of the elements
   local sizeX, sizeY = getRadarAreaSize ( v ) -- get the size of the radar area
   local sizeX, sizeY = getRadarAreaSize ( theArea ) -- get the size of the radar area
   if ( sizeX < 100 and sizeY < 100 ) then -- check if it's smaller than 100 by 100
   if ( sizeX < 100 and sizeY < 100 ) then -- check if it's smaller than 100 by 100
       outputChatBox ( "A small radar area was found!" )
       outputChatBox ( "A small radar area was found!" )
   end
   end
end
end
</syntaxhighlight>
This example creates a radar area and stores it's size in variables x and y:
<syntaxhighlight lang="lua">
greenArea = createRadarArea ( 1024, 1024, 50, 120, 0, 220, 0, 85 )
local x, y = getRadarAreaSize ( greenArea )
</syntaxhighlight>
</syntaxhighlight>


==See Also==
==See Also==
{{Radar area_functions}}
{{Radar area functions}}

Latest revision as of 17:35, 26 November 2014

This function is used for getting the X and Y size of an existing radar area.

Syntax

float, float getRadarAreaSize ( radararea theRadararea )              

OOP Syntax Help! I don't understand this!

Method: radararea:getSize(...)


Required Arguments

  • theRadararea: The radar area element whose size you wish to get.

Returns

Returns two floats indicating the X and Y length of the radar area respectively, false if the radar area is invalid.

Example

The following example looks for radar areas whose size is smaller than 100 by 100:

local radarareas = getElementsByType ( "radararea" ) -- get a table of radararea elements
for k, theArea in ipairs(radarareas) do -- use a generic for loop to step through each of the elements
   local sizeX, sizeY = getRadarAreaSize ( theArea ) -- get the size of the radar area
   if ( sizeX < 100 and sizeY < 100 ) then -- check if it's smaller than 100 by 100
      outputChatBox ( "A small radar area was found!" )
   end
end

See Also