Load a map
map_loadLoads a Garry's Mod map and waits until the new server and client realms are playable, resetting Lua state so subsequent realm tools run against the new map.
Instructions
Loads a map and WAITS until it is playable: client mode = the console map command (singleplayer when maxplayers is 1, listen server otherwise), then it waits until NEW server and client realms are up and ready (gamemode loaded, local player valid) and the loading screen is gone; srcds = changelevel, server realm only. Every Lua state of the previous map is destroyed: its globals, hooks, timers, jobs and debug drawings are gone, and the addons' files are loaded again from disk. Changing maxplayers on a running game disconnects first (client mode only). Result: {map, gamemode, maxplayers, requested_map, duration_s, server_generation, client_generation, warning?, lua_mount?, lua_cache_emptied?}. With a mounted Lua folder (lua_mount) it empties the engine's Lua file cache before loading (lua_cache_emptied), and when the load ends it checks the folder: if its files changed since the realms loaded them (edited during the load) or a realm did not get the folder, warning says so and lua_mount is the status.lua_mount object. Errors: not_found (no maps/.bsp), busy (another map_load/disconnect runs), timeout (with which realms are up), cancelled. If the game crashes during the load, the call through the coordinator answers client_crashed (dump name in details; relaunch with instances_launch). IMPORTANT: when your client runs it as a background MCP task, wait for its result before calling a realm tool: a call made before it ends reaches the OLD map's state. Every lua_exec/lua_job result carries the realm's generation: equal to server_generation/client_generation = the new map's state. Starting a game makes every other running Garry's Mod release its GPU resources for 2-10 s, and a map load ending in that window crashes that game (engine bug, Facepunch garrysmod-issues #7137). So a map_load that goes through the bridge (any session, any target instance) first waits while a game is being started (instances_launch) and for 15 s after the last start. A call that waited carries waited_s and waited_reason (and progress; as a task, in statusMessage). If the wait would exceed timeout_s it fails with error launch_in_progress and sends nothing to the game: retry later, or with a larger timeout_s. When another game was loading a map at that moment (started by anything: console, Lua, a script, another session), the result lists it as other_games_loading; it does not delay the load. A launch, however, waits for loads like that. Not held back by the bridge: a game started by hand, and a map change triggered from Lua or the console while a game is being started (changelevel, map through console_exec): do not do those. Right after a game starts, the other games can be unreachable for 15-18 s (instance_unreachable, timeouts): expected, wait and retry. Example: {"map": "gm_construct"}.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"map": "<map>"
},
"name": "map_load"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| map | Yes | Name without extension, e.g. gm_construct. | |
| gamemode | No | Gamemode (e.g. sandbox). Default: unchanged. | |
| instance | No | Optional. Instance identifier (see instances_list). If present and different from the local instance, the call is relayed by the coordinator to that instance. | |
| timeout_s | No | Max wait in seconds (default 180). | |
| maxplayers | No | 1 = singleplayer, >1 = listen server (needed for bots_add). Default: unchanged. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| map | No | ||
| next | No | ||
| note | No | ||
| warning | No | ||
| gamemode | No | ||
| lua_mount | No | ||
| next_call | No | ||
| duration_s | Yes | ||
| maxplayers | No | ||
| answered_by | No | ||
| requested_map | Yes | ||
| truncated_note | No | ||
| version_warning | No | ||
| client_generation | No | ||
| lua_cache_emptied | No | ||
| server_generation | No |