Garry's Mod Wiki


The engine library provides functions to access various features in the game's engine, most are related to the demo and save systems.


Returns non paused FrameTime.
Returns the name of the currently running gamemode.
Closes the server and completely exits. To enable this function for use on your server, add -allowquit to your commandline, which will make this function run quit keep_players when executed, this also does not forcibly disconnect players. This is also available when running in server test mode (launch option -systemtest). Server test mode is used internally at Facepunch as part of the build process to make sure that the dedicated servers aren't crashing on startup.
table engine.GetAddons()
Returns a list of addons the player have subscribed to on the workshop. This list will also include "Floating" . gma addons that are mounted by the game, but not the folder addons.
When starting playing a demo, engine. GetDemoPlaybackTick will be reset and its old value will be added to this functions return value.
Current tick of currently loaded demo. If not playing a demo, it will return amount of ticks since last demo playback.
Returns time scale of demo playback. If not during demo playback, returns 1.
Returns total amount of ticks of currently loaded demo. If not playing a demo, returns 0 or the value of last played demo.
Returns a table containing info for all installed gamemodes
table engine.GetGames()
Returns an array of tables corresponding to all games from which Garry's Mod supports mounting content.
We advise against using this. It may be changed or removed in a future update. Used internally for in-game menus, may be merged in the future into engine. GetAddons. Returns the UGC (demos, saves and dupes) the player have subscribed to on the workshop.
Returns true if we're currently playing a demo. You will notice that there's no server-side version of this. That's because there is no server when playing a demo. Demos are both recorded and played back purely clientside.
Returns true if the game is currently recording a demo file (. dem) using gm_demo
engine.LightStyle( number lightstyle, string pattern )
This is a direct binding to the function engine->LightStyle. This function allows you to change the default light style of the map - so you can make lighting lighter or darker. You’ll need to call render. RedownloadAllLightmaps clientside to refresh the lightmaps to this new color. Calling this function with arguments 0 and "a" will cause dynamic lights such as those produced by the Light tool to stop working. Issue Tracker: 3626
table engine.OpenDupe( string dupeName )
Loads a duplication from the local filesystem.
Returns an estimate of the server's performance. Equivalent to calling FrameTime from the server, according to source code.
engine.SetMounted( string depotID, boolean doMount )
Sets the mounting options for mountable content.
number engine.TickCount()
Returns the number of ticks since the game server started.
Returns the number of seconds between each gametick.
This is used internally - although you're able to use it you probably shouldn't. Returns video recording settings set by video. Record. Used by Demo-To-Video feature.
engine.WriteDupe( string dupe, string jpeg )
Saves a duplication as a file.
engine.WriteSave( string saveData, string name, number time, string map, string workshopID = nil )
Stores savedata into the game (can be loaded using the LoadGame menu)