SetRadarAreaFlashing: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(new example & updated)
No edit summary
Line 1: Line 1:
{{Needs_Checking|Does it return false if the radararea is set to flash but already is flashing (and vice versa)? [[User:Erorr404|Erorr404]]}}
__NOTOC__  
__NOTOC__  
Makes an existing radar area flash in transparency.
This function makes an existing radar area flash in transparency.


==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool setRadarAreaFlashing ( radararea theRadararea, bool flash )
bool setRadarAreaFlashing ( radararea theRadarArea, bool flash )
</syntaxhighlight>  
</syntaxhighlight>  


===Required Arguments===  
===Required Arguments===  
*'''theRadararea:''' the radararea element.
*'''theRadarArea:''' the [[radararea]] element we want to change flashing state of.
*'''flash:''' a bool indicating whether the radar area should flash (true to flash, false to not flash).
*'''flash:''' a bool indicating whether the radar area should flash (''true'' to flash, ''false'' to not flash).


===Returns===
===Returns===
Returns ''true'' if the radar area was successfuly set to flash, ''false'' if the radar area doesn't exist.
Returns ''true'' if the new flash state was successfully set, ''false'' if the radar area doesn't exist or invalid arguments were passed.


==Example==  
==Example==  
'''Example 1:''' This example checks to see whether an existing radar area (''someArea'') is flashing, and forces it to flash if it isn't:
'''Example 1:''' This example checks to see whether an existing radar area (''someArea'') is flashing, and forces it to flash if it isn't:
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
flag = isRadarAreaFlashing ( someArea )
local isFlashing = isRadarAreaFlashing ( someArea )
if ( flag ) then -- if the area is already flashing...
if isFlashing then -- if the area is already flashing...
   outputChatBox ( "The radar area is already flashing." )
   outputChatBox ( "The radar area is already flashing." )
else -- it it isn't...
else -- it it isn't...
Line 27: Line 25:
</syntaxhighlight>
</syntaxhighlight>


'''Example 2:'''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.
'''Example 2:'''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.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
-- create our hill area for our gamemode
-- create our hill area for our gamemode
Line 36: Line 34:
function hill_Enter ( thePlayer, matchingDimension )
function hill_Enter ( thePlayer, matchingDimension )
--announce to everyone that the player entered the hill
--announce to everyone that the player entered the hill
outputChatBox( getClientName(thePlayer).." entered the zone!", getRootElement(),255, 255, 109, )
outputChatBox( getClientName(thePlayer).." entered the zone!", getRootElement(), 255, 255, 109, )
setRadarAreaFlashing ( hillRadar, true )
setRadarAreaFlashing ( hillRadar, true )
end
end
Line 47: Line 45:
--if he was alive, announce to everyone that the player has left the hill
--if he was alive, announce to everyone that the player has left the hill
outputChatBox ( getClientName(thePlayer).." left the zone!", getRootElement(), 255, 255, 109 )
outputChatBox ( getClientName(thePlayer).." left the zone!", getRootElement(), 255, 255, 109 )
setRadarAreaFlashing ( hillRadar, false )
setRadarAreaFlashing ( hillRadar, false )
end
end
end
end

Revision as of 14:02, 16 July 2007

This function makes an existing radar area flash in transparency.

Syntax

bool setRadarAreaFlashing ( radararea theRadarArea, bool flash )

Required Arguments

  • theRadarArea: the radararea element we want to change flashing state of.
  • flash: a bool indicating whether the radar area should flash (true to flash, false to not flash).

Returns

Returns true if the new flash state was successfully set, false if the radar area doesn't exist or invalid arguments were passed.

Example

Example 1: This example checks to see whether an existing radar area (someArea) is flashing, and forces it to flash if it isn't:

local isFlashing = isRadarAreaFlashing ( someArea )
if isFlashing then -- if the area is already flashing...
   outputChatBox ( "The radar area is already flashing." )
else -- it it isn't...
   setRadarAreaFlashing ( someArea, true ) -- make the area flash
end

Example 2: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