IsPlayerMapVisible: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
Line 4: Line 4:
[[Image:MTAsa_Default_Map.png|thumb|224px|Screenshot of the default map]]
[[Image:MTAsa_Default_Map.png|thumb|224px|Screenshot of the default map]]


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


==Syntax==
==Syntax==

Latest revision as of 11:50, 9 November 2024

Screenshot of the default map

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

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("Player-map closed", 0, 255, 0)
      forcePlayerMap(false)
   else
      outputChatBox("Viewing player-map", 0, 255, 0)
      forcePlayerMap(true)
   end
end
addCommandHandler("showmap", showMap)

See Also