IsPlayerMapVisible: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Removed {{Needs Example}})
No edit summary
Line 8: Line 8:
===Returns===
===Returns===
Returns ''true'' if the player has the map visible, ''false'' otherwise.
Returns ''true'' if the player has the map visible, ''false'' otherwise.
[[File:MTAsa_Default_Map.png|400px|thumb|left|MTA:SA Default Map]]


==Example==
==Example==

Revision as of 15:06, 23 June 2018

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.

MTA:SA Default Map















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