CreateRadarArea: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
Line 26: Line 26:
This example creates a radar area when a player spawns, only if the player is in the 'grovestreet' team.
This example creates a radar area when a player spawns, only if the player is in the 'grovestreet' team.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
addEventHandler ( "onPlayerSpawn", root, "onPlayerSpawn" ) --add an event handler for onPlayerSpawn
addEventHandler ( "onPlayerSpawn", root, "playerSpawn" ) --add an event handler for onPlayerSpawn
function onPlayerSpawn ( spawnpoint ) --when a player spawns
function playerSpawn ( spawnpoint, team ) --when a player spawns
     createRadarArea ( 0, 0, 5, 5, 0, 255, 0, 150, grovestreet ) --create a green radar area at 0, 0 which is only visible to the 'grovestreet' team
     createRadarArea ( 0, 0, 5, 5, 0, 255, 0, 150, source ) --create a green radar area at 0, 0 which is only visible to the player
end
end
</syntaxhighlight>
</syntaxhighlight>

Revision as of 22:44, 10 September 2006

Dialog-information.png This article needs checking.

Reason(s): Unspecified

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

Syntax

radararea createRadarArea ( float x, float y, float sizex, float sizey, int r, int g, int b, int a, [ visibleTo=getRootElement () ] )             

Required Arguments

  • x: A float representing the starting 'x' position of the radar area
  • y: A float representing the starting 'y' position of the radar area
  • sizex: A float representing the width of the radar area, going in an east direction
  • sizey: A float representing the height of the radar area, going in a south direction
  • 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.

  • visibleto: An element or elements that you wish to restrict the visibility of the radar area to.

Example

This example creates a radar area when a player spawns, only if the player is in the 'grovestreet' team.

addEventHandler ( "onPlayerSpawn", root, "playerSpawn" ) --add an event handler for onPlayerSpawn
function playerSpawn ( spawnpoint, team ) --when a player spawns
    createRadarArea ( 0, 0, 5, 5, 0, 255, 0, 150, source ) --create a green radar area at 0, 0 which is only visible to the player
end

See Also