game.GetMap

From GMod Wiki

Jump to: navigation, search
Function
Syntax game.GetMap( )
Where is this used?
Description:
Retrieve the current map name.
Returns: String
Part of Library: Game
Realm: NewerShared.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=Game.GetMap]Game.GetMap [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]



Example

DescriptionThis example prints the current map name to the console.
Used onNewerShared.png
Code
Msg("The current map is " .. game.GetMap() .. "\n")
Output"gm_flatgrass" (for example)
DescriptionThis example makes you leave the server if it's running a RP map.
Used onNewerClient.png
Code
hook.Add( "Think", "I_hate_rp", function()
    if ( string.find( string.lower( game.GetMap() ), "rp_" ) ) then RunConsoleCommand( "disconnect" ) end
end)
OutputN/A


See Also

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox