getMapName | Multi Theft Auto: Wiki Skip to content

getMapName

Client-side
Server-side
Shared

Pair: setMapName

This function retrieves the current mapname as set by setMapName.

Syntax

string|nil getMapName ( )

Returns

  • string|nil: map name

Returns the mapname as a string. If no mapname is set it returns nil.

Code Examples

server

This example adds a checkmap command with which you can check what map you are currently playing.

local function checkMap ( thePlayer )
local mapName = getMapName() -- get the maps name
if (mapName and mapName ~= "None") then -- if map name was set and it isn't "None" (default map name)
outputChatBox("You're playing map called \"" .. mapName .. "\"", thePlayer) -- print out the map name
else -- there was no name so tell that to player
outputChatBox("You're playing an unnamed map.", thePlayer) -- print out the message
end
end
addCommandHandler("checkmap", checkMap)