IsPlayerMapVisible: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(New page: __NOTOC__ {{Server client function}} This function checks if the specified player has the map visible. ==Syntax== <syntaxhighlight lang="lua">bool isPlayerMapVisible ( player thePlayer )</syntaxhighlight> ===...)
 
mNo edit summary
 
(9 intermediate revisions by 6 users not shown)
Line 1: Line 1:
__NOTOC__
__NOTOC__
{{Server client function}}
{{Client function}}
This function checks if the specified [[player]] has the map visible.
 
[[Image:MTAsa_Default_Map.png|thumb|224px|Screenshot of the default map]]
 
This function checks if the local player has their map showing.


==Syntax==
==Syntax==
<syntaxhighlight lang="lua">bool isPlayerMapVisible ( player thePlayer )</syntaxhighlight>
<syntaxhighlight lang="lua">bool isPlayerMapVisible ()</syntaxhighlight>
 
===Required Arguments===
* '''thePlayer''': A [[player]] element to check if the map is visible


===Returns===
===Returns===
Line 13: Line 13:


==Example==
==Example==
<syntaxhighlight lang="lua">
<section name="Example 1" class="client" show="true"><syntaxhighlight lang="lua">
--Needs an example
function checkMap()
</syntaxhighlight>
  local text = (isPlayerMapVisible() and "You are currently viewing your map!") or "Your map is not visible!"
  outputChatBox(text, 255, 255, 0) -- output text
end
addCommandHandler("map", checkMap) -- add '/map' command to the check
</syntaxhighlight></section>
 
<section name="Example 2" class="client" show="true"><syntaxhighlight lang="lua">
function showMap()
  if isPlayerMapVisible() then
      outputChatBox("Radar closed", 0, 255, 0)
      forcePlayerMap(false)
  else
      outputChatBox("Viewing radar", 0, 255, 0)
      forcePlayerMap(true)
  end
end
addCommandHandler("showmap", showMap)
</syntaxhighlight></section>


==See Also==
==See Also==
{{Player functions}}
{{Client player functions}}

Latest revision as of 16:31, 23 June 2018

Screenshot of the default map

This function checks if the local player has their map showing.

Syntax

bool isPlayerMapVisible ()

Returns

Returns true if the player has the map visible, false otherwise.

Example

Click to collapse [-]
Example 1
function checkMap()
   local text = (isPlayerMapVisible() and "You are currently viewing your map!") or "Your map is not visible!"
   outputChatBox(text, 255, 255, 0) -- output text 
end
addCommandHandler("map", checkMap) -- add '/map' command to the check
Click to collapse [-]
Example 2
function showMap()
   if isPlayerMapVisible() then
      outputChatBox("Radar closed", 0, 255, 0)
      forcePlayerMap(false)
   else
      outputChatBox("Viewing radar", 0, 255, 0)
      forcePlayerMap(true)
   end
end
addCommandHandler("showmap", showMap)

See Also

Shared