C# Class GarrysModLuaShared.game

The game library provides functions to access various features in the game's engine, most of it's functions are related to controlling the map.
Show file Open project: OmegaExtern/gmod-csharp-binary-module

Public Methods

Method Description
AddDecal ( LuaState luaState, string decalName, string materialName ) : void

Registers a new decal.

AddParticles ( LuaState luaState, string particleFileName ) : void

Loads a particle file.

ConsoleCommand ( LuaState luaState, string stringCommand ) : void

Runs a console command. Make sure to add a newline ("\n") at the end of the command.

GetAmmoID ( LuaState luaState, string name ) : double

Returns the ammo type ID for given ammo type name. See GetAmmoName for reverse.

GetAmmoMax ( LuaState luaState, double id ) : double

Returns the real maximum amount of ammo of the given ammo ID. Note: Currently all ammo types have overridden maximum value of reserve ammo set to 9999.

GetAmmoName ( LuaState luaState, double id ) : string

Returns the ammo name for given ammo type ID. See GetAmmoID for reverse.

GetMap ( LuaState luaState ) : string

Returns the name of the current map, without a file extension.

GetMapNext ( LuaState luaState ) : string

Returns the next map that would be loaded according to the file that is set by the mapcyclefile convar.

GetMapVersion ( LuaState luaState ) : double

Returns the VBSP version of the current map.

GetSkillLevel ( LuaState luaState ) : double

Returns the difficulty level of the game. TIP: You can use this function in your scripted NPCs or Nextbots to make them harder, however, it is a good idea to lock powerful attacks behind the highest difficulty instead of just increasing the health.

GetTimeScale ( LuaState luaState ) : double

Returns the timescale of the game.

IsDedicated ( LuaState luaState ) : bool

Returns whenever the server or the server we are connected to is a dedicated server.

LoadNextMap ( LuaState luaState ) : void

Loads the next map according to the file that is set by the mapcyclefile convar.

MapLoadType ( LuaState luaState ) : string

Returns the map load type of the current map.

MaxPlayers ( LuaState luaState ) : double

Returns the maximum number of players for this server.

RemoveRagdolls ( LuaState luaState ) : void

Removes all the clientside ragdolls.

SetSkillLevel ( LuaState luaState, double level ) : void

Sets the difficulty level of the game, can be retrieved with game.GetSkillLevel. This will automatically change whenever the "skill" convar is modified serverside.

SetTimeScale ( LuaState luaState, double timeScale ) : void

Sets the time scale of the game. This function is supposed to remove the need of using the host_timescale convar, which is cheat protected. To slow down or speed up the movement of a specific player, use Player.SetLaggedMovementValue instead. NOTE: Like host_timescale, this method does not affect sounds, if you wish to change that, look into EntityEmitSound hook.

SinglePlayer ( LuaState luaState ) : bool

Returns whenever the current session is a single player game.

Method Details

AddDecal() public static method

Registers a new decal.
public static AddDecal ( LuaState luaState, string decalName, string materialName ) : void
luaState LuaState Pointer to lua_State struct.
decalName string The name of the decal.
materialName string /// The material to be used for the decal. May also be a list of material names, in which case a /// random material from that list will be chosen every time the decal is placed. ///
return void

AddParticles() public static method

Loads a particle file.
public static AddParticles ( LuaState luaState, string particleFileName ) : void
luaState LuaState Pointer to lua_State struct.
particleFileName string The path of the file to add. Must be (file).pcf.
return void

ConsoleCommand() public static method

Runs a console command. Make sure to add a newline ("\n") at the end of the command.
public static ConsoleCommand ( LuaState luaState, string stringCommand ) : void
luaState LuaState Pointer to lua_State struct.
stringCommand string String containing the command and arguments to be ran.
return void

GetAmmoID() public static method

Returns the ammo type ID for given ammo type name. See GetAmmoName for reverse.
public static GetAmmoID ( LuaState luaState, string name ) : double
luaState LuaState Pointer to lua_State struct.
name string Name of the ammo type to look up ID of.
return double

GetAmmoMax() public static method

Returns the real maximum amount of ammo of the given ammo ID. Note: Currently all ammo types have overridden maximum value of reserve ammo set to 9999.
public static GetAmmoMax ( LuaState luaState, double id ) : double
luaState LuaState Pointer to lua_State struct.
id double Ammo type ID.
return double

GetAmmoName() public static method

Returns the ammo name for given ammo type ID. See GetAmmoID for reverse.
public static GetAmmoName ( LuaState luaState, double id ) : string
luaState LuaState Pointer to lua_State struct.
id double Ammo ID to retrieve the name of. Starts from 1.
return string

GetMap() public static method

Returns the name of the current map, without a file extension.
public static GetMap ( LuaState luaState ) : string
luaState LuaState Pointer to lua_State struct.
return string

GetMapNext() public static method

Returns the next map that would be loaded according to the file that is set by the mapcyclefile convar.
public static GetMapNext ( LuaState luaState ) : string
luaState LuaState Pointer to lua_State struct.
return string

GetMapVersion() public static method

Returns the VBSP version of the current map.
public static GetMapVersion ( LuaState luaState ) : double
luaState LuaState Pointer to lua_State struct.
return double

GetSkillLevel() public static method

Returns the difficulty level of the game. TIP: You can use this function in your scripted NPCs or Nextbots to make them harder, however, it is a good idea to lock powerful attacks behind the highest difficulty instead of just increasing the health.
public static GetSkillLevel ( LuaState luaState ) : double
luaState LuaState Pointer to lua_State struct.
return double

GetTimeScale() public static method

Returns the timescale of the game.
public static GetTimeScale ( LuaState luaState ) : double
luaState LuaState Pointer to lua_State struct.
return double

IsDedicated() public static method

Returns whenever the server or the server we are connected to is a dedicated server.
public static IsDedicated ( LuaState luaState ) : bool
luaState LuaState Pointer to lua_State struct.
return bool

LoadNextMap() public static method

Loads the next map according to the file that is set by the mapcyclefile convar.
public static LoadNextMap ( LuaState luaState ) : void
luaState LuaState Pointer to lua_State struct.
return void

MapLoadType() public static method

Returns the map load type of the current map.
public static MapLoadType ( LuaState luaState ) : string
luaState LuaState Pointer to lua_State struct.
return string

MaxPlayers() public static method

Returns the maximum number of players for this server.
public static MaxPlayers ( LuaState luaState ) : double
luaState LuaState Pointer to lua_State struct.
return double

RemoveRagdolls() public static method

Removes all the clientside ragdolls.
public static RemoveRagdolls ( LuaState luaState ) : void
luaState LuaState Pointer to lua_State struct.
return void

SetSkillLevel() public static method

Sets the difficulty level of the game, can be retrieved with game.GetSkillLevel. This will automatically change whenever the "skill" convar is modified serverside.
public static SetSkillLevel ( LuaState luaState, double level ) : void
luaState LuaState Pointer to lua_State struct.
level double The difficulty level, Easy( 1 ), Normal( 2 ), Hard( 3 ).
return void

SetTimeScale() public static method

Sets the time scale of the game. This function is supposed to remove the need of using the host_timescale convar, which is cheat protected. To slow down or speed up the movement of a specific player, use Player.SetLaggedMovementValue instead. NOTE: Like host_timescale, this method does not affect sounds, if you wish to change that, look into EntityEmitSound hook.
public static SetTimeScale ( LuaState luaState, double timeScale ) : void
luaState LuaState Pointer to lua_State struct.
timeScale double The new timescale, minimum value is 0.001 and maximum is 5.
return void

SinglePlayer() public static method

Returns whenever the current session is a single player game.
public static SinglePlayer ( LuaState luaState ) : bool
luaState LuaState Pointer to lua_State struct.
return bool