Some utility functions. Unlike the functions in misc.lua, this file only holds HL2 specific functions.
| Utilities | Some utility functions. |
| Functions | |
| execFile | Executes a file on the console. |
| execString | Just like execFile, except acts on newline-delimited strings. |
| serialize | Serializes a variable. |
| isSandbox | Returns true if the current gamemode is sandbox or is derived from sandbox. |
| filesInDir | Returns files in directory. |
| queueFunctionCall | Adds a function call to the queue to be called. |
| backupFile | Copies a file to a backup file. |
| nameCheck | Checks all players’ names at regular intervals to detect name changes. |
| getPlyByUID |
function ULib.execFile( f, usebasefolder )
Executes a file on the console. Use this instead of the “exec” command when the config lies outside the cfg folder.
| f | The file, relative to the data folder. |
| usebasefolder | An optional boolean stating whether or not the file specified is relative to the base folder. |
| v2.40 | No longer strips comments, removed ability to execute on players. |
| v2.42 | Added usebasefolder to conform to Garry’s API changes. |
function ULib.execString( f, ply )
Just like execFile, except acts on newline-delimited strings.
| f | The string. |
| ply | The player to execute on. Leave nil to execute on server. (Ignores this param on client) |
| v2.40 | Initial. |
function ULib.filesInDir( dir, recurse, root )
Returns files in directory.
| dir | The dir to look for files in. |
| recurse | (Optional, defaults to false) If true, searches directories recursively. |
| root | INTERNAL USE ONLY This helps with recursive functions. |
| v2.10 | Initial (But dragged over from GM9 archive). |
| v2.40 | Fixed (was completely broken). |
| v2.42 | Now assumes paths relative to base folder. |
function ULib.queueFunctionCall( fn, ... )
Adds a function call to the queue to be called. Guaranteed to be called sometime after the current frame. Very handy when you need to delay a call for some reason. Uses a think hook, but it’s only hooked when there’s stuff in the queue.
| fn | The function to call |
| ... | (Optional) The parameters to pass to the function |
| v2.40 | Initial (But dragged over from UPS). |
Executes a file on the console.
function ULib.execFile( f, usebasefolder )
Just like execFile, except acts on newline-delimited strings.
function ULib.execString( f, ply )
Serializes a variable.
function ULib.serialize( v )
Returns true if the current gamemode is sandbox or is derived from sandbox.
function ULib.isSandbox()
Returns files in directory.
function ULib.filesInDir( dir, recurse, root )
Adds a function call to the queue to be called.
function ULib.queueFunctionCall( fn, ... )
Copies a file to a backup file.
function ULib.backupFile( f )
Checks all players’ names at regular intervals to detect name changes.
function ULib.nameCheck()
function ULib.getPlyByUID( uid )