Running Simple Console Commands with Lua
Garry's Mod, built on the Source engine, supports console commands for various tasks, including performance optimization and gameplay adjustments. Players can enable the developer console to input commands directly. For more advanced functionalities, Lua scripting can be used to create custom commands or automate actions, such as saving cannon configurations or triggering specific dances.
Enabling the Developer Console
To access console commands, first enable the developer console:
- Launch Garry's Mod.
- From the main menu, select Options.
- Go to the Keyboard tab.
- Click the Advanced button.
- Check the box next to Enable developer console (~).
- Click Apply.
Press the ~ key to open the console. Some commands may require enabling sv_cheats 1 first. Be aware that many servers disable cheats or prevent play with them enabled.
Optimizing Framerate with Console Commands
Improve your Garry's Mod framerate without installing additional mods by modifying the autoexec.cfg file and using launch options:
- Locate your
garrysmod/cfgfolder. - Open
autoexec.cfgwith a text editor (e.g., Notepad). - Paste the following code into the file:
gmod_mcore_test 1
mat_queue_mode 2
cl_threaded_bone_setup 1
cl_threaded_client_leaf_system 1
r_threaded_client_shadow_manager 1
r_threaded_particles 1
r_threaded_renderables 1
r_queued_ropes 1
studio_queue_mode 1
mat_specular 1
fps_max FRAMERATE
menu_cleanupgmas
host_writeconfig - Replace FRAMERATE with your monitor's refresh rate for optimal results.
- Save the file.
- Open Garry's Mod properties in Steam.
- Navigate to the General section.
- In the Launch Options box, paste:
+exec autoexec.cfg
Launch the game using the 64-Bit or Garry's Mod option to apply these settings.
Lua Scripting Examples
- Confetti Cannons: Players with allowedRanks defined in
confettycannon_config.luacan type!savecannonsto save all cannons on the server with a defined interval. - Custom Taunts/Dances: Commands can be used to trigger specific dances or emotes, including 26 full MMD/anime dances, 45 MMD short dances, and 277 original Fortnite emotes, supporting Garry's Mod female and male skeletons.
- Aimbot Gun: A Lua-based Aimbot Gun addon allows players to shoot heads and potentially lock onto other players.