CreateRadarArea: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(createRadarArea syntax changed)
Line 5: Line 5:
==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
radararea createRadarArea ( float x, float y, float sizex, float sizey, [ int r = 255, int g = 0, int b = 0, int a = 255, element visibleTo = getRootElement() ] )             
radararea createRadarArea ( float centerX, float centerY, float sizeX, float sizeY, [ int r = 255, int g = 0, int b = 0, int a = 255, element visibleTo = getRootElement() ] )             
</syntaxhighlight>  
</syntaxhighlight>  


===Required Arguments===  
===Required Arguments===  
*'''x:''' A float representing the origin 'x' position of the radar area
*'''centerX:''' A float representing the center 'x' position of the radar area.
*'''y:''' A float representing the origin 'y' position of the radar area
*'''centerY:''' A float representing the center 'y' position of the radar area.
*'''sizex:''' A float representing the width of the radar area, going in an east direction
*'''sizeX:''' A float representing the width of the radar area.
*'''sizey:''' A float representing the height of the radar area, going in a south direction
*'''sizeY:''' A float representing the height of the radar area.


*'''r:''' An integer representing the amount of red in the color.  Maximum value is 255
*'''r:''' An integer representing the amount of red in the color.  Maximum value is 255
Line 18: Line 18:
*'''b:''' An integer representing the amount of blue in the color.  Maximum value is 255
*'''b:''' An integer representing the amount of blue in the color.  Maximum value is 255
*'''a:''' An integer representing the amount of alpha in the color.  This allows setting the transparency of the radar area.  255 is opaque and 0 is transparent.
*'''a:''' An integer representing the amount of alpha in the color.  This allows setting the transparency of the radar area.  255 is opaque and 0 is transparent.
Note: The origin position specified by the ''x'' and ''y'' arguments is the bottom left (or south west) corner of the area.


===Optional Arguments===  
===Optional Arguments===  
{{OptionalArg}}  
{{OptionalArg}}  
*'''visibleto:''' An element or elements that you wish to restrict the visibility of the radar area to.
*'''visibleTo:''' An [[element]] that you wish to restrict the [[visibility]] of the radar area to.


==Example==  
==Example==  

Revision as of 15:06, 16 August 2007

This function can be used to create custom radar areas on the radar.

Syntax

radararea createRadarArea ( float centerX, float centerY, float sizeX, float sizeY, [ int r = 255, int g = 0, int b = 0, int a = 255, element visibleTo = getRootElement() ] )             

Required Arguments

  • centerX: A float representing the center 'x' position of the radar area.
  • centerY: A float representing the center 'y' position of the radar area.
  • sizeX: A float representing the width of the radar area.
  • sizeY: A float representing the height of the radar area.
  • r: An integer representing the amount of red in the color. Maximum value is 255
  • g: An integer representing the amount of green in the color. Maximum value is 255
  • b: An integer representing the amount of blue in the color. Maximum value is 255
  • a: An integer representing the amount of alpha in the color. This allows setting the transparency of the radar area. 255 is opaque and 0 is transparent.

Optional Arguments

NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use. For more information on optional arguments, see optional arguments.

Example

Click to collapse [-]
Server

This example creates a radar area for the King of the hill script, and a colsquare. When the player enters the radar area flashes, it stops flashing when a player leaves.

-- create our hill area for our gamemode
local hillArea = createColSquare ( -2171.0678710938, 678.17950439453, 0, 15, 15 )
local hillRadar = createRadarArea ( -2183.5678710938, 705.67950439453, 40, -40, 0, 255, 0, 175 )

-- add hill_Enter as a handler for when a player enters the hill area
function hill_Enter ( thePlayer, matchingDimension )
        --announce to everyone that the player entered the hill
        outputChatBox( getClientName(thePlayer).." entered the zone!", getRootElement(), 255, 255, 109 )
        setRadarAreaFlashing ( hillRadar, true )
end
addEventHandler ( "onColShapeHit", hillArea, hill_Enter )

-- add hill_Enter as a handler for when a player leaves the hill area
function hill_Exit ( thePlayer, matchingDimension )
        --check if the player is not dead
        if isPlayerDead ( thePlayer ) ~= true then
                --if he was alive, announce to everyone that the player has left the hill
                outputChatBox ( getClientName(thePlayer).." left the zone!", getRootElement(), 255, 255, 109 )
        setRadarAreaFlashing ( hillRadar, false )
        end
end
addEventHandler ( "onColShapeLeave", hillArea, hill_Exit )

See Also