C# Класс GarrysModLuaShared.util

The utility library.
Показать файл Открыть проект

Открытые методы

Метод Описание
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.

Описание методов

AddNetworkString() публичный статический Метод

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.
Результат uint

Base64Encode() публичный статический Метод

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.
Результат string

CRC() публичный статический Метод

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.
Результат string

Compress() публичный статический Метод

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.
Результат string

DateStamp() публичный статический Метод

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.
Результат string

DecalMaterial() публичный статический Метод

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.
Результат string

Decompress() публичный статический Метод

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.
Результат string

GetPData() публичный статический Метод

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
Результат string

GetSurfaceIndex() публичный статический Метод

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.
Результат uint

GetSurfacePropName() публичный статический Метод

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.
Результат string

IsModelLoaded() публичный статический Метод

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.
Результат bool

IsValidModel() публичный статический Метод

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.
Результат bool

IsValidProp() публичный статический Метод

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.
Результат bool

IsValidRagdoll() публичный статический Метод

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.
Результат bool

NetworkIDToString() публичный статический Метод

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.
Результат string

NetworkStringToID() публичный статический Метод

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.
Результат uint

NiceFloat() публичный статический Метод

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
Результат string

PrecacheModel() публичный статический Метод

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.
Результат void

PrecacheSound() публичный статический Метод

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.
Результат void

RelativePathToFull() публичный статический Метод

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.
Результат string

RemovePData() публичный статический Метод

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.
Результат void

SetPData() публичный статический Метод

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.
Результат void

SharedRandom() публичный статический Метод

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.
Результат double

SteamIDFrom64() публичный статический Метод

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.
Результат string

SteamIDTo64() публичный статический Метод

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.
Результат string

TimerCycle() публичный статический Метод

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.
Результат double

TypeToString() публичный статический Метод

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.
Результат string