SetRadarAreaSize: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
(Added OOP syntax) |
||
(8 intermediate revisions by 5 users not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{Server client function}} | |||
This function changes the size of an existing [[radararea|radar area]]. | |||
==Syntax== | ==Syntax== | ||
Line 6: | Line 7: | ||
bool setRadarAreaSize ( radararea theRadararea, float x, float y ) | bool setRadarAreaSize ( radararea theRadararea, float x, float y ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{OOP||[[radararea]]:setSize}} | |||
===Required Arguments=== | ===Required Arguments=== | ||
*'''theRadararea:''' the radararea element whose size is to be changed. | *'''theRadararea:''' the [[radararea]] element whose size is to be changed. | ||
*'''x:''' the x length of the radar area. | *'''x:''' the x length of the radar area. | ||
*'''y:''' the y length of the radar area. | *'''y:''' the y length of the radar area. | ||
===Returns=== | ===Returns=== | ||
Returns ''true'' if the size was set successfully, ''false'' if | Returns ''true'' if the size was set successfully, ''false'' if invalid arguments are passed. | ||
==Example== | ==Example== | ||
This example decreases the size of a team's radar area whenever a player from that team dies: | '''Example 1:''' This example decreases the size of a team's radar area whenever a player from that team dies: | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
-- assume that team elements exist and that each player belongs to one of them | -- assume that team elements exist and that each player belongs to one of them | ||
-- assume that radararea elements exist and that each is a child of one of the teams | -- assume that radararea elements exist and that each is a child of one of the teams | ||
function playerWasted ( killer, killerweapon, bodypart ) | function playerWasted ( killer, killerweapon, bodypart ) | ||
local victimteam = getPlayerTeam ( source ) -- get the team of the victim | |||
local killerteam = getPlayerTeam ( killer ) -- get the team of the killer | |||
if ( killer and killerteam ~= victimteam ) then -- if there is a killer and he is from an opposing team | |||
local victimarea = getElementChild ( victimteam, 0 ) -- get the radararea belonging to the victim's team | |||
local x, y = getRadarAreaSize ( victimarea ) -- get the size of the radar area | |||
x = x - 5 | |||
y = y - 5 | |||
setRadarAreaSize ( victimarea, x, y ) -- set a new (smaller) size for the victim's radar area | |||
end | |||
end | end | ||
addEventHandler ( "onPlayerWasted", root, playerWasted ) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
This | '''Example 2:''' This example creates a radar area and resets its size right away: | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
aRadarArea = createRadarArea ( 1024, 1024, 30, 140, 255, 255, 0, 85 ) | aRadarArea = createRadarArea ( 1024, 1024, 30, 140, 255, 255, 0, 85 ) | ||
flag = setRadarAreaSize ( aRadarArea, 50, 90 ) | |||
if ( flag ) then | if ( flag ) then | ||
outputChatBox ( "Radar area size set successfully!" ) | |||
else | else | ||
outputChatBox ( "Failed to set radar area size." ) | |||
end | end | ||
</syntaxhighlight> | </syntaxhighlight> |
Latest revision as of 17:38, 26 November 2014
This function changes the size of an existing radar area.
Syntax
bool setRadarAreaSize ( radararea theRadararea, float x, float y )
OOP Syntax Help! I don't understand this!
- Method: radararea:setSize(...)
Required Arguments
- theRadararea: the radararea element whose size is to be changed.
- x: the x length of the radar area.
- y: the y length of the radar area.
Returns
Returns true if the size was set successfully, false if invalid arguments are passed.
Example
Example 1: This example decreases the size of a team's radar area whenever a player from that team dies:
-- assume that team elements exist and that each player belongs to one of them -- assume that radararea elements exist and that each is a child of one of the teams function playerWasted ( killer, killerweapon, bodypart ) local victimteam = getPlayerTeam ( source ) -- get the team of the victim local killerteam = getPlayerTeam ( killer ) -- get the team of the killer if ( killer and killerteam ~= victimteam ) then -- if there is a killer and he is from an opposing team local victimarea = getElementChild ( victimteam, 0 ) -- get the radararea belonging to the victim's team local x, y = getRadarAreaSize ( victimarea ) -- get the size of the radar area x = x - 5 y = y - 5 setRadarAreaSize ( victimarea, x, y ) -- set a new (smaller) size for the victim's radar area end end addEventHandler ( "onPlayerWasted", root, playerWasted )
Example 2: This example creates a radar area and resets its size right away:
aRadarArea = createRadarArea ( 1024, 1024, 30, 140, 255, 255, 0, 85 ) flag = setRadarAreaSize ( aRadarArea, 50, 90 ) if ( flag ) then outputChatBox ( "Radar area size set successfully!" ) else outputChatBox ( "Failed to set radar area size." ) end
See Also
- createRadarArea
- getRadarAreaColor
- getRadarAreaSize
- isInsideRadarArea
- isRadarAreaFlashing
- setRadarAreaColor
- setRadarAreaFlashing
- setRadarAreaSize