C# Class GarrysModLuaShared.util

The utility library.
Afficher le fichier Open project: OmegaExtern/gmod-csharp-binary-module

Méthodes publiques

Méthode 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 méthode

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.
Résultat uint

Base64Encode() public static méthode

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.
Résultat string

CRC() public static méthode

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.
Résultat string

Compress() public static méthode

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.
Résultat string

DateStamp() public static méthode

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.
Résultat string

DecalMaterial() public static méthode

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.
Résultat string

Decompress() public static méthode

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.
Résultat string

GetPData() public static méthode

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
Résultat string

GetSurfaceIndex() public static méthode

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.
Résultat uint

GetSurfacePropName() public static méthode

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.
Résultat string

IsModelLoaded() public static méthode

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.
Résultat bool

IsValidModel() public static méthode

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.
Résultat bool

IsValidProp() public static méthode

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.
Résultat bool

IsValidRagdoll() public static méthode

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.
Résultat bool

NetworkIDToString() public static méthode

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.
Résultat string

NetworkStringToID() public static méthode

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.
Résultat uint

NiceFloat() public static méthode

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
Résultat string

PrecacheModel() public static méthode

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.
Résultat void

PrecacheSound() public static méthode

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.
Résultat void

RelativePathToFull() public static méthode

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.
Résultat string

RemovePData() public static méthode

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.
Résultat void

SetPData() public static méthode

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.
Résultat void

SharedRandom() public static méthode

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.
Résultat double

SteamIDFrom64() public static méthode

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.
Résultat string

SteamIDTo64() public static méthode

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.
Résultat string

TimerCycle() public static méthode

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.
Résultat double

TypeToString() public static méthode

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.
Résultat string