GetMapName: Difference between revisions
Jump to navigation
Jump to search
(New page: __NOTOC__ {{Server function}}<!-- Change this to "Client function" or "Server function" appropriately--> <!-- Describe in plain english what this function does. Don't go into details, jus...) |
mNo edit summary |
||
(One intermediate revision by one other user not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{Server function}} | {{Server function}} | ||
This function retrieves the current mapname as set by [[setMapName]]. | This function retrieves the current mapname as set by [[setMapName]]. | ||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
string getMapName () | string getMapName () | ||
Line 11: | Line 9: | ||
===Returns=== | ===Returns=== | ||
Returns the mapname as a string. If no mapname is set it returns ''nil''. | Returns the mapname as a string. If no mapname is set it returns ''nil''. | ||
==Example== | ==Example== | ||
This example adds a ''checkmap'' command with which you can check what map you are currently playing. | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
-- | 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 ) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
==See Also== | ==See Also== | ||
{{Announce functions}} | |||
{{ | |||
Latest revision as of 16:19, 30 January 2009
This function retrieves the current mapname as set by setMapName.
Syntax
string getMapName ()
Returns
Returns the mapname as a string. If no mapname is set it returns nil.
Example
This example adds a checkmap command with which you can check what map you are currently playing.
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 )
See Also