HolyLib Wiki

gameserver

gameserver

This module adds a new gameserver library for more control over the engine's CGameServer and CGameClients. Supports: Linux32

Methods

Approximates the memory usage of the server in bytes. This function was removed since it never actually worked
gameserver.BroadcastMessage( number type, string name, bf_write buffer )
Sends a custom net message to all clients.
This function allows you send any netmessage you want.
You should know what your doing since this function doesn't validate anything.
Calculates and returns the CPU Usage. This function was removed since it never actually worked
Creates a new fake client (bot) with the given name and adds it to the server.
Returns nil if the server isn't active or the engine failed to create the client (e.g. no free client slot left).
Creates a new fake client with the given name, similar to gameserver.CreateFakeClient, but manually replicates the connection process instead of going through the engine's sv_stressbots-based fake client creation.
It sets a bunch of default user convars (rate, cl_updaterate, cl_interp, ...) and puts the client into the SIGNONSTATE_PRESPAWN state before returning it.
CNetChan gameserver.CreateNetChannel( string ip, boolean useDNS, number protocolVersion = 1, number socket = NS_SERVER )
Creates a net channel for the given ip.
Creates and returns a brand new CGameClient appended to the end of the server's client list (at slot gameserver.GetClientCount).
Unlike gameserver.CreateFakeClient this does not connect the client or configure it as a bot, it merely allocates the client object.
table gameserver.GetAll( )
Returns a table that contains all CGameClients.
It will return nil on failure.
number gameserver.GetClassBits( )
CGameClient gameserver.GetClient( number playerSlot )
Returns the CGameClient at that player slot or nil on failure.
CGameClient gameserver.GetClientBySteamID( string steamID )
Returns the CGameClient for the given steamID or nil on failure. (steamID not steamID64!)
CGameClient gameserver.GetClientByUserID( number userID )
Returns the CGameClient for the given userID or nil on failure.
number gameserver.GetClientCount( )
returns client count for iteration of gameserver.GetClient
This will include inactive CGameClient's since the engine re-uses them and doesn't delete them on disconnect.
If you want to get the count of active client's use gameserver.GetNumClients
number gameserver.GetCPUUsage( )
Returns the server's current CPU usage as tracked by the engine itself (CBaseServer::GetCPUUsage).
Returns a table containing all net channels created by gameserver.CreateNetChannel
Returns the server's current random nonce, used internally by the engine for Steam client authentication.
CGameClient gameserver.GetFreeClient( string ip, boolean useDNS, boolean noQueueLookup = false )
Finds (or creates) a free client slot for the given address, this is the same lookup the engine performs internally whenever a new player connects.
Calling this function will not trigger the HolyLib:GetFreeClient hook, to prevent infinite recursion.
CGameClient gameserver.GetFreeQueueClient( string ip, boolean useDNS )
Directly looks up (or creates) a free client from HolyLib's internal queue client list for the given address.
This is the same fallback that gameserver.GetFreeClient (and the engine's own free client search) uses when the server has no regular free client slot left.
Queue clients are kept out of the server's normal client list (see CBaseClient:AddToQueueList) until moved back in.
Returns the server's previous random nonce, used internally by the engine for Steam client authentication.
string gameserver.GetMapName( )
Returns the current map name.
number gameserver.GetMaxClients( )
returns current client limit
string gameserver.GetName( )
Returns the current server/host name.
Should be the same as GetConVar("hostname"):GetString()
number gameserver.GetNumClasses( )
number gameserver.GetNumClients( )
returns current number of clients
returns current number of fake clients/bots
number gameserver.GetNumProxies( )
returns number of attached HLTV proxies
string gameserver.GetPassword( )
Returns the current server password.
number gameserver.GetSocket( )
Returns the network socket index the server is listening on, usable with functions like gameserver.SendConnectionlessPacket or gameserver.CreateNetChannel.
number gameserver.GetSpawnCount( )
number gameserver.GetTick( )
Returns the current tick
number gameserver.GetTickInterval( )
Returns the current tick interval
number gameserver.GetTime( )
Returns the current time/curtime
number gameserver.GetUDPPort( )
returns the udp port the server is running on.
boolean gameserver.IsActive( )
boolean gameserver.IsDedicated( )
boolean gameserver.IsHLTV( )
boolean gameserver.IsLoading( )
boolean gameserver.IsMultiplayer( )
boolean gameserver.IsPausable( )
boolean gameserver.IsPaused( )
gameserver.RemoveNetChannel( CNetChan channel )
Removes/Destroys a net channel invalidating it.
number gameserver.SendConnectionlessPacket( bf_write bf, string ip, boolean useDNS, number socket = NS_SERVER )
Sends out a connectionless packet to the target ip.
See HolyLib:ProcessConnectionlessPacket for examples. It's expected that YOU already added the connectionless header, this was done to not have to copy the buffer.
bf:WriteLong(-1) -- Write this as the first thing. This is the CONNECTIONLESS_HEADER
gameserver.SetMaxClients( number slots )
Sets the max client count.
Should do nothing.
gameserver.SetPassword( string password )
Sets the server password.
gameserver.SetPaused( boolean paused = false )
Pauses/Unpauses the server. does this actually work?