C# Class GarrysModLuaShared.util

The utility library.
ファイルを表示 Open project: OmegaExtern/gmod-csharp-binary-module

Public Methods

Method Description
AddNetworkString ( LuaState luaState, string networkString ) : uint

Adds the specified string to a string table, which will cache it and network it to all clients automatically. Whenever you want to create a net message with net.Start, you must add the name of that message as a networked string via this function. If the passed string already exists, nothing will happen and the ID of the existing item will be returned. NOTE: Due to the way string tables work, it's preferable to call this function as soon as the server starts up, such as in Initialize hook. The string table used for this function does not interfere with the engine string tables and has 2048 slots.

Base64Encode ( LuaState luaState, string stringToEncode ) : string

Encodes the specified string to base64.

CRC ( LuaState luaState, string stringToHash ) : string

Generates the checksum of the specified string.

Compress ( LuaState luaState, string stringToCompress ) : string

Compresses the given string using FastLZ. Use with net.WriteData and net.ReadData for networking.

DateStamp ( LuaState luaState ) : string

Returns the current date formatted like '2015-10-27 20-04-59'.

DecalMaterial ( LuaState luaState, string decalName ) : string

Gets the full material path by the decal name.

Decompress ( LuaState luaState, string compressedString ) : string

Decompresses the given string using FastLZ.

GetPData ( LuaState luaState, string steamId, string name, string @default ) : string

Gets PData of an offline player using their Steam ID.

GetSurfaceIndex ( LuaState luaState, string surfaceName ) : uint

Returns the matching surface index for the surface name.

GetSurfacePropName ( LuaState luaState, uint id ) : string

Returns a name of surfaceproperties ID.

IsModelLoaded ( LuaState luaState, string modelName ) : bool

Checks if the model is loaded in the game.

IsValidModel ( LuaState luaState, string modelName ) : bool

Checks if the specified model is valid.

IsValidProp ( LuaState luaState, string modelName ) : bool

Checks if the specified prop is valid.

IsValidRagdoll ( LuaState luaState, string ragdollName ) : bool

Checks if the specified model name points to a valid ragdoll.

NetworkIDToString ( LuaState luaState, uint stringTableId ) : string

Returns the networked string associated with the given ID from the string table.

NetworkStringToID ( LuaState luaState, string networkString ) : uint

Returns the networked ID associated with the given string from the string table.

NiceFloat ( LuaState luaState, double @float ) : string

Formats a float by stripping off extra zeros and dots.

PrecacheModel ( LuaState luaState, string modelName ) : void

Precaches a model for later use. Model is cached after being loaded once.

PrecacheSound ( LuaState luaState, string soundName ) : void

Precaches a sound for later use. Sound is cached after being loaded once.

RelativePathToFull ( LuaState luaState, string file ) : string

Returns the absolute system path to the file relative to /garrysmod/ folder.

RemovePData ( LuaState luaState, string steamId, string name ) : void

Removes PData of an offline player using their Steam ID.

SetPData ( LuaState luaState, string steamId, string name, object value ) : void

Sets PData for an offline player using their Steam ID.

SharedRandom ( LuaState luaState, string uniqueName, double min, double max, double additionalSeed = 0.0D ) : double

Generates a random float value that should be the same on client and server. NOTE: This function is best used in a predicted hook.

SteamIDFrom64 ( LuaState luaState, string steam64Id ) : string

Given a 64bit Steam ID will return a STEAM_0 style Steam ID.

SteamIDTo64 ( LuaState luaState, string steamId ) : string

Given a STEAM_0 style Steam ID will return a 64bit Steam ID.

TimerCycle ( LuaState luaState ) : double

Returns the time since this function has been last called in milliseconds.

TypeToString ( LuaState luaState, object input ) : string

Converts a type to a (nice, but still parsable) string.

Method Details

AddNetworkString() public static method

Adds the specified string to a string table, which will cache it and network it to all clients automatically. Whenever you want to create a net message with net.Start, you must add the name of that message as a networked string via this function. If the passed string already exists, nothing will happen and the ID of the existing item will be returned. NOTE: Due to the way string tables work, it's preferable to call this function as soon as the server starts up, such as in Initialize hook. The string table used for this function does not interfere with the engine string tables and has 2048 slots.
public static AddNetworkString ( LuaState luaState, string networkString ) : uint
luaState LuaState Pointer to lua_State struct.
networkString string The string to add to the table.
return uint

Base64Encode() public static method

Encodes the specified string to base64.
public static Base64Encode ( LuaState luaState, string stringToEncode ) : string
luaState LuaState Pointer to lua_State struct.
stringToEncode string String to encode.
return string

CRC() public static method

Generates the checksum of the specified string.
public static CRC ( LuaState luaState, string stringToHash ) : string
luaState LuaState Pointer to lua_State struct.
stringToHash string The string to calculate the checksum of.
return string

Compress() public static method

Compresses the given string using FastLZ. Use with net.WriteData and net.ReadData for networking.
public static Compress ( LuaState luaState, string stringToCompress ) : string
luaState LuaState Pointer to lua_State struct.
stringToCompress string String to compress.
return string

DateStamp() public static method

Returns the current date formatted like '2015-10-27 20-04-59'.
public static DateStamp ( LuaState luaState ) : string
luaState LuaState Pointer to lua_State struct.
return string

DecalMaterial() public static method

Gets the full material path by the decal name.
public static DecalMaterial ( LuaState luaState, string decalName ) : string
luaState LuaState Pointer to lua_State struct.
decalName string Name of the decal.
return string

Decompress() public static method

Decompresses the given string using FastLZ.
public static Decompress ( LuaState luaState, string compressedString ) : string
luaState LuaState Pointer to lua_State struct.
compressedString string String to decompress.
return string

GetPData() public static method

Gets PData of an offline player using their Steam ID.
public static GetPData ( LuaState luaState, string steamId, string name, string @default ) : string
luaState LuaState Pointer to lua_State struct.
steamId string Steam ID of the player.
name string Variable name to get the value of.
@default string
return string

GetSurfaceIndex() public static method

Returns the matching surface index for the surface name.
public static GetSurfaceIndex ( LuaState luaState, string surfaceName ) : uint
luaState LuaState Pointer to lua_State struct.
surfaceName string The name of the surface.
return uint

GetSurfacePropName() public static method

Returns a name of surfaceproperties ID.
public static GetSurfacePropName ( LuaState luaState, uint id ) : string
luaState LuaState Pointer to lua_State struct.
id uint Surface properties ID. You can get it from structure.
return string

IsModelLoaded() public static method

Checks if the model is loaded in the game.
public static IsModelLoaded ( LuaState luaState, string modelName ) : bool
luaState LuaState Pointer to lua_State struct.
modelName string Name or path of the model to check.
return bool

IsValidModel() public static method

Checks if the specified model is valid.
public static IsValidModel ( LuaState luaState, string modelName ) : bool
luaState LuaState Pointer to lua_State struct.
modelName string Name or path of the model to check.
return bool

IsValidProp() public static method

Checks if the specified prop is valid.
public static IsValidProp ( LuaState luaState, string modelName ) : bool
luaState LuaState Pointer to lua_State struct.
modelName string Name or path of the model to check.
return bool

IsValidRagdoll() public static method

Checks if the specified model name points to a valid ragdoll.
public static IsValidRagdoll ( LuaState luaState, string ragdollName ) : bool
luaState LuaState Pointer to lua_State struct.
ragdollName string Name or path of the model to check.
return bool

NetworkIDToString() public static method

Returns the networked string associated with the given ID from the string table.
public static NetworkIDToString ( LuaState luaState, uint stringTableId ) : string
luaState LuaState Pointer to lua_State struct.
stringTableId uint ID to get the associated string from.
return string

NetworkStringToID() public static method

Returns the networked ID associated with the given string from the string table.
public static NetworkStringToID ( LuaState luaState, string networkString ) : uint
luaState LuaState Pointer to lua_State struct.
networkString string String to get the associated networked ID from.
return uint

NiceFloat() public static method

Formats a float by stripping off extra zeros and dots.
public static NiceFloat ( LuaState luaState, double @float ) : string
luaState LuaState Pointer to lua_State struct.
@float double
return string

PrecacheModel() public static method

Precaches a model for later use. Model is cached after being loaded once.
public static PrecacheModel ( LuaState luaState, string modelName ) : void
luaState LuaState Pointer to lua_State struct.
modelName string The model to precache.
return void

PrecacheSound() public static method

Precaches a sound for later use. Sound is cached after being loaded once.
public static PrecacheSound ( LuaState luaState, string soundName ) : void
luaState LuaState Pointer to lua_State struct.
soundName string The sound to precache.
return void

RelativePathToFull() public static method

Returns the absolute system path to the file relative to /garrysmod/ folder.
public static RelativePathToFull ( LuaState luaState, string file ) : string
luaState LuaState Pointer to lua_State struct.
file string The file to get the absolute path of.
return string

RemovePData() public static method

Removes PData of an offline player using their Steam ID.
public static RemovePData ( LuaState luaState, string steamId, string name ) : void
luaState LuaState Pointer to lua_State struct.
steamId string Steam ID of the player.
name string Variable name to remove.
return void

SetPData() public static method

Sets PData for an offline player using their Steam ID.
public static SetPData ( LuaState luaState, string steamId, string name, object value ) : void
luaState LuaState Pointer to lua_State struct.
steamId string Steam ID of the player.
name string Variable name to store the value in.
value object The value to store.
return void

SharedRandom() public static method

Generates a random float value that should be the same on client and server. NOTE: This function is best used in a predicted hook.
public static SharedRandom ( LuaState luaState, string uniqueName, double min, double max, double additionalSeed = 0.0D ) : double
luaState LuaState Pointer to lua_State struct.
uniqueName string The seed for the random value.
min double The minimum value of the random range.
max double The maximum value of the random range.
additionalSeed double The additional seed.
return double

SteamIDFrom64() public static method

Given a 64bit Steam ID will return a STEAM_0 style Steam ID.
public static SteamIDFrom64 ( LuaState luaState, string steam64Id ) : string
luaState LuaState Pointer to lua_State struct.
steam64Id string The 64 bit Steam ID.
return string

SteamIDTo64() public static method

Given a STEAM_0 style Steam ID will return a 64bit Steam ID.
public static SteamIDTo64 ( LuaState luaState, string steamId ) : string
luaState LuaState Pointer to lua_State struct.
steamId string The STEAM_0 style ID.
return string

TimerCycle() public static method

Returns the time since this function has been last called in milliseconds.
public static TimerCycle ( LuaState luaState ) : double
luaState LuaState Pointer to lua_State struct.
return double

TypeToString() public static method

Converts a type to a (nice, but still parsable) string.
public static TypeToString ( LuaState luaState, object input ) : string
luaState LuaState Pointer to lua_State struct.
input object What to convert.
return string