GetRadarAreaSize: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
mNo edit summary
Line 17: Line 17:
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
radarareas = getElementsByType ( "radararea" ) -- get a tabele of radararea elements
radarareas = getElementsByType ( "radararea" ) -- get a tabele of radararea elements
for k,v in radarareas do -- use a generic for loop to step through each of the elements
for k,v 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 ( v ) -- 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

Revision as of 09:12, 30 July 2007

Used for getting the X and Y size of an existing radar area.

Syntax

float float getRadarAreaSize ( radararea theRadararea )              

Required Arguments

  • theRadararea: The radararea 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 doesn't exist.

Example

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

radarareas = getElementsByType ( "radararea" ) -- get a tabele of radararea elements
for k,v 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
   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

This example creates a radar area and stores it's size in variables x and y:

greenArea = createRadarArea ( 1024, 1024, 50, 120, 0, 220, 0, 85 )
local x, y = getRadarAreaSize ( greenArea )

See Also