Skip to content

Scripting Network

Dreamy Cecil edited this page Oct 25, 2026 · 1 revision

Constants

  • PS enum - Automatic weapon selection type for player settings:

    • PS.WAS_ONLYNEW - Only select newly picked up weapons
    • PS.WAS_NONE - Never select weapons automatically
    • PS.WAS_ALL - Automatically select every picked up weapon
    • PS.WAS_BETTER - Only select weapons that are stronger than the currently held one
  • PSF enum - Player settings flags:

    • PSF.HIDEWEAPON - Whether to hide the weapon viewmodel from the first person view
    • PSF.PREFER3RDPERSON - Whether to automatically switch to the third person view
    • PSF.NOQUOTES - Whether to mute all sounds played by CVoiceHolder entities
    • PSF.AUTOSAVE - Whether to autosave the game in single player
    • PSF.COMPSINGLECLICK - Whether to only use a single press of the NETRICSA button in order to bring it up
    • PSF.SHARPTURNING - Whether to use sharp turning on the first person view
    • PSF.NOBOBBING - Whether to disable view & weapon bobbing from the first person view
  • SOF enum - Sound playback flags:

    • SOF.NONE - No flags (equal to 0)
    • SOF.LOOP - Make the sound repeat indefinitely
    • SOF.3D - Use 3D positioning for the sound
    • SOF.VOLUMETRIC - Allow the sound to change pitch when played from a moving source
    • SOF.SURROUND - Simulate the effect of the sound coming from every direction at once
    • SOF.LOCAL - Allow the sound to be played only for the local player (if playing from a sound object of a player entity)
    • SOF.SMOOTHCHANGE - Play the new sound as soon as the old one finishes playing instead of immediately switching to it
    • SOF.MUSIC - Use the music channel for playing the sound
    • SOF.NONGAME - Allow the sound to continue playing outside the game (when the menu is open)
    • SOF.NOFILTER - Ignore listener filter (e.g. more bassy sounds when underwater)
    • SOF.PAUSED
    • SOF.LOADED
    • SOF.PREPARE
    • SOF.PLAY
  • ChatCommandAccess enum - Access level for chat commands:

    • ChatCommandAccess.Everyone - Chat command can be used by anyone
    • ChatCommandAccess.Admin - Chat command can only be used by admins and operators
    • ChatCommandAccess.Operator - Chat command can only be used by operators

Vanilla session properties

VanillaSP enum contains byte offsets of each session property in the vanilla game. These values may be invalid when used in user-made mods due to the differences in session properties, where some of the properties may be offset or removed entirely. This enum exists purely for convenience when scripting server plugins for the vanilla game.

The First Encounter session properties in order
Session property Type Length Offset
VanillaSP.ctMaxPlayers Integer 4 bytes 0
VanillaSP.bWaitAllPlayers Integer 4 bytes 4
VanillaSP.bQuickTest Integer 4 bytes 8
VanillaSP.bCooperative Integer 4 bytes 12
VanillaSP.bSinglePlayer Integer 4 bytes 16
VanillaSP.bUseFrags Integer 4 bytes 20
VanillaSP.gmGameMode Integer 4 bytes 24
VanillaSP.gdGameDifficulty Integer 4 bytes 28
VanillaSP.ulSpawnFlags Integer 4 bytes 32
VanillaSP.bMental Integer 4 bytes 36
VanillaSP.iScoreLimit Integer 4 bytes 40
VanillaSP.iFragLimit Integer 4 bytes 44
VanillaSP.iTimeLimit Integer 4 bytes 48
VanillaSP.bTeamPlay Integer 4 bytes 52
VanillaSP.bFriendlyFire Integer 4 bytes 56
VanillaSP.bWeaponsStay Integer 4 bytes 60
VanillaSP.bAmmoStays Integer 4 bytes 64
VanillaSP.bHealthArmorStays Integer 4 bytes 68
VanillaSP.bPlayEntireGame Integer 4 bytes 72
VanillaSP.bAllowHealth Integer 4 bytes 76
VanillaSP.bAllowArmor Integer 4 bytes 80
VanillaSP.bInfiniteAmmo Integer 4 bytes 84
VanillaSP.fEnemyMovementSpeed Float 4 bytes 88
VanillaSP.fEnemyAttackSpeed Float 4 bytes 92
VanillaSP.fDamageStrength Float 4 bytes 96
VanillaSP.fAmmoQuantity Float 4 bytes 100
VanillaSP.fManaTransferFactor Float 4 bytes 104
VanillaSP.iInitialMana Integer 4 bytes 108
VanillaSP.fExtraEnemyStrength Float 4 bytes 112
VanillaSP.fExtraEnemyStrengthPerPlayer Float 4 bytes 116
VanillaSP.ctCredits Integer 4 bytes 120
VanillaSP.ctCreditsLeft Integer 4 bytes 124
VanillaSP.tmSpawnInvulnerability Float 4 bytes 128
VanillaSP.iBlood Integer 4 bytes 132
VanillaSP.bGibs Integer 4 bytes 136
VanillaSP.bEndOfGame Integer 4 bytes 140
VanillaSP.ulLevelsMask Integer 4 bytes 144
VanillaSP.bRespawnInPlace Integer 4 bytes 148
The Second Encounter session properties in order
Session property Type Length Offset
VanillaSP.ctMaxPlayers Integer 4 bytes 0
VanillaSP.bWaitAllPlayers Integer 4 bytes 4
VanillaSP.bQuickTest Integer 4 bytes 8
VanillaSP.bCooperative Integer 4 bytes 12
VanillaSP.bSinglePlayer Integer 4 bytes 16
VanillaSP.bUseFrags Integer 4 bytes 20
VanillaSP.gmGameMode Integer 4 bytes 24
VanillaSP.gdGameDifficulty Integer 4 bytes 28
VanillaSP.ulSpawnFlags Integer 4 bytes 32
VanillaSP.bMental Integer 4 bytes 36
VanillaSP.iScoreLimit Integer 4 bytes 40
VanillaSP.iFragLimit Integer 4 bytes 44
VanillaSP.iTimeLimit Integer 4 bytes 48
VanillaSP.bTeamPlay Integer 4 bytes 52
VanillaSP.bFriendlyFire Integer 4 bytes 56
VanillaSP.bWeaponsStay Integer 4 bytes 60
VanillaSP.bAmmoStays Integer 4 bytes 64
VanillaSP.bHealthArmorStays Integer 4 bytes 68
VanillaSP.bPlayEntireGame Integer 4 bytes 72
VanillaSP.bAllowHealth Integer 4 bytes 76
VanillaSP.bAllowArmor Integer 4 bytes 80
VanillaSP.bInfiniteAmmo Integer 4 bytes 84
VanillaSP.bRespawnInPlace Integer 4 bytes 88
VanillaSP.fEnemyMovementSpeed Float 4 bytes 92
VanillaSP.fEnemyAttackSpeed Float 4 bytes 96
VanillaSP.fDamageStrength Float 4 bytes 100
VanillaSP.fAmmoQuantity Float 4 bytes 104
VanillaSP.fManaTransferFactor Float 4 bytes 108
VanillaSP.iInitialMana Integer 4 bytes 112
VanillaSP.fExtraEnemyStrength Float 4 bytes 116
VanillaSP.fExtraEnemyStrengthPerPlayer Float 4 bytes 120
VanillaSP.ctCredits Integer 4 bytes 124
VanillaSP.ctCreditsLeft Integer 4 bytes 128
VanillaSP.tmSpawnInvulnerability Float 4 bytes 132
VanillaSP.iBlood Integer 4 bytes 136
VanillaSP.bGibs Integer 4 bytes 140
VanillaSP.bEndOfGame Integer 4 bytes 144
VanillaSP.ulLevelsMask Integer 4 bytes 148
VanillaSP.bUseExtraEnemies Integer 4 bytes 152

Classes

CPlayerAction

Class for representing a single input action for some server client.

Methods

Clear()

Resets action data to empty defaults. Equivalent to the engine's CPlayerAction::Clear().

Return value: null


Lerp(action0, action1, factor)

Applies linear interpolation between two actions and sets the results to this action. Equivalent to the engine's CPlayerAction::Lerp().

Arguments:

  • action0 - CPlayerAction with the first action.
  • action1 - CPlayerAction with the second action.
  • factor - Linear interpolation factor between the two actions from 0.0 to 1.0.

Return value: null

Variables

vTranslation

Applied movement of the player. Equivalent to the engine's CPlayerAction::pa_vTranslation.

Type Default value Readable Writeable
FLOAT3D FLOAT3D(0, 0, 0) Yes Yes

aRotation

Applied rotation of the player. Equivalent to the engine's CPlayerAction::pa_aRotation.

Type Default value Readable Writeable
FLOAT3D FLOAT3D(0, 0, 0) Yes Yes

aViewRotation

Applied rotation of the player's view. Equivalent to the engine's CPlayerAction::pa_aViewRotation.

Type Default value Readable Writeable
FLOAT3D FLOAT3D(0, 0, 0) Yes Yes

ulButtons

Mask of pressed button actions, excluding movement and rotations. Equivalent to the engine's CPlayerAction::pa_ulButtons.

Type Default value Readable Writeable
integer 0 Yes Yes

CPlayerCharacter

Class for representing a character profile of a specific server player.

Metamethods

CPlayerCharacter(buffer = CRawDataBuffer(16))

Constructs a character instance with a GUID from the specified buffer with at least 16 bytes of data.

Arguments:

  • buffer (optional) - CRawDataBuffer with at least 16 bytes containing the GUID to set to the player character.

clone()

Creates a copy of the character instance.

Return value: CPlayerCharacter


tostring()

Returns character name for printing with appropriate decoration tags around it.

Return value: string

Methods

Equal(other)

Compares this character with another character. A helper method for the lack of the == operator overloading.

Arguments:

  • other - Another CPlayerCharacter to compare this one with.

Return value: bool


GetModelFilename()

Returns full path to the file with the used player model. Equivalent to the engine's ((CPlayerSettings *)CPlayerCharacter::pc_aubAppearance)->GetModelFilename().

Return value: string

Variables

strName

Player's display name. Equivalent to the engine's CPlayerCharacter::pc_strName.

Type Readable Writeable
string Yes Yes

strTeam

Player's internal team name. Equivalent to the engine's CPlayerCharacter::pc_strTeam.

Type Readable Writeable
string Yes Yes

strSkin

Name of the used player model. Equivalent to the engine's ((CPlayerSettings *)CPlayerCharacter::pc_aubAppearance)->ps_achModelFile.

Type Readable Writeable
string Yes Yes

iWeaponAutoSelect

Weapon auto-select mode from the PS enum. Equivalent to the engine's ((CPlayerSettings *)CPlayerCharacter::pc_aubAppearance)->ps_iWeaponAutoSelect.

Type Readable Writeable
integer Yes Yes

iCrosshairType

Currently selected crosshair type. Equivalent to the engine's ((CPlayerSettings *)CPlayerCharacter::pc_aubAppearance)->ps_iCrossHairType.

Type Readable Writeable
integer Yes Yes

ulFlags

Player settings flags from the PSF enum. Equivalent to the engine's ((CPlayerSettings *)CPlayerCharacter::pc_aubAppearance)->ps_ulFlags.

Type Readable Writeable
integer Yes Yes

Network.SessionProperties

Class for holding a sequence of session properties values for applying over the network. Extends CRawDataBuffer class.

Metamethods

Network.SessionProperties(other = N/A)

Constructs a new buffer by copying session properties from another structure. If left unspecified, fills the buffer with the current session properties in order to preserve current values in gaps between modified values.

Arguments:

  • other (optional) - Network.SessionProperties to copy session properties from.

Methods

Apply()

Sends a chunk of modified session properties to all clients on the server.

Return value: null

Usage example

local props = Network.SessionProperties(); // Create session properties structure

// Use values from the VanillaSP enum to specify byte offsets of session properties from vanilla games
props.SetFloat(VanillaSP.fExtraEnemyStrength, 2); // Increase extra enemy strength
props.SetBool(VanillaSP.bInfiniteAmmo, true); // Enable infinite ammo
props.SetIndex(VanillaSP.ctCreditsLeft, props.GetIndex(VanillaSP.ctCreditsLeft) - 1); // Decrease respawn credits by 1
props.SetIndex(VanillaSP.bAllowHealth, props.GetIndex(VanillaSP.bAllowArmor)); // Synchronize bAllowHealth with bAllowArmor

props.Apply(); // Send new session properties values to all clients

Network.Sound

Class for setting up a network-synchronized sound to play for all clients (or locally).

Metamethods

Network.Sound(path = "", channel = 0, volume = 1.0)

Constructs a new sound and optionally presets the sound file, the channel to play on and the volume. Unspecified values are set to no sound file, channel 0 and volume 1.0.

Arguments:

  • path (optional) - Path to the sound file.
  • channel (optional) - Index of a channel to use for the sound from 0 to 31.
  • volume (optional) - Sound volume from 0.0 to 4.0.

Methods

IsPlaying()

Checks whether any sound is currently playing on the specified channel.

Return value: bool


IsPaused()

Checks whether the sound on the specified channel is currently paused.

Return value: bool


Play(local = false)

Plays set up sound. The optional argument specifies whether to play the sound locally, which doesn't send any packet from the server and can be called by non-hosting clients.

Arguments:

  • local (optional) - Whether to play the sound locally on the same game instance as the executed script.

Return value: null


Stop(local = false)

Stops the sound. The optional argument specifies whether to stop the sound locally, which doesn't send any packet from the server and can be called by non-hosting clients.

Arguments:

  • local (optional) - Whether to play the sound locally on the same game instance as the executed script.

Return value: null

Variables

strFile

Path to the sound file to play. Setting it to /stop/ stops any playback on the specified channel. Leaving it empty allows modifying sound properties during playback on the specified channel.

Type Default value Readable Writeable
string "" Yes Yes

iChannel

Index of a channel to use for playing the sound from 0 to 31. Only one sound can be played on each channel at a time.

Type Default value Readable Writeable
integer 0 Yes Yes

ulFlags

Sound playback flags from the SOF enum.

Type Default value Readable Writeable
integer SOF.NONE Yes Yes

fDelay

Delay before playing the sound in seconds.

Type Default value Readable Writeable
float 0.0 Yes Yes

fOffset

Sound cutoff point from the beginning in seconds.

Type Default value Readable Writeable
float 0.0 Yes Yes

fVolumeL

Volume of the left sound channel from 0.0 to 4.0.

Type Default value Readable Writeable
float 1.0 Yes Yes

fVolumeR

Volume of the right sound channel from 0.0 to 4.0.

Type Default value Readable Writeable
float 1.0 Yes Yes

fVolume

Convenience variable for setting volume for both sound channels at once.

Type Default value Readable Writeable
float N/A No Yes

fFilterL

Bass filter of the left sound channel from 1.0 to 500.0.

Type Default value Readable Writeable
float 1.0 Yes Yes

fFilterR

Bass filter of the right sound channel from 1.0 to 500.0.

Type Default value Readable Writeable
float 1.0 Yes Yes

fFilter

Convenience variable for setting bass filter for both sound channels at once.

Type Default value Readable Writeable
float N/A No Yes

fPitch

Sound pitch from 0.0 to 10.0.

Type Default value Readable Writeable
float 1.0 Yes Yes

Usage example

// Set up a new sound on channel 0 at 50% volume
local snd = Network.Sound("Sounds\\Menu\\Chat.wav", 0, 0.5);
snd.fPitch = 2; // Play twice as fast
snd.Play(); // Play the sound for all clients globally

Functions

Network states

Network.IsHost()

Checks whether the client is currently hosting any game: splitscreen, multiplayer server or a single player game.

Return value: bool


Network.IsOnline()

Checks whether the client is currently communicating via a network, e.g. hosting an online server or is connected to a remote server.

Return value: bool


Network.IsOnlineServer()

Helper function that checks whether the client is specifically hosting an online multiplayer server.

Return value: bool


Network.IsPlayingOnline()

Helper function that checks whether the client is specifically connected to a remote server.

Return value: bool


Network.IsObserving()

Checks whether the client is currently observing an online game instead of participating in it as another player.

Return value: bool


Network.IsPredicting()

Checks whether the client has prediction enabled for the current game.

Return value: bool


Network.GetMaxPlayers()

Returns maximum amount of players allowed in the current game.

Return value: integer


Network.IsVanillaCompatible()

Checks whether the currently running server is compatible with vanilla clients, i.e. has ser_bForbidVanilla turned off and has all gameplay extensions disabled.
This function is only relevant for the server and will always return false if Network.IsHost() is also false.

Return value: bool

Demos

Network.StartDemoRec(path)

Starts recording a new demo of the current game in the specified file.

Arguments:

  • path - Path to a demo file (.dem) to start recording the demo into.

Return value: null


Network.StopDemoRec()

Stops all demo recording, if there's any.

Return value: null


Network.IsPlayingDemo()

Checks whether the current game is a demo playback.

Return value: bool


Network.IsRecordingDemo()

Checks whether any demo is currently being recorded.

Return value: bool


Network.IsDemoPlayFinished()

Checks whether any demo playback has just finished.

Return value: bool

Session states

Network.IsWaitingForPlayers()

Checks whether the server is waiting for more players to connect.

Return value: bool


Network.IsWaitingForServer()

Checks whether the client is waiting for the server to respond.

Return value: bool


Network.IsConnectionStable()

Checks whether the connection to the server is stable.

Return value: bool


Network.IsDisconnected()

Checks whether the client got disconnected from a server.

Return value: bool


Network.WhyDisconnected()

Returns the reason for disconnecting the client from the server.

Return value: string


Network.IsGameFinished()

Checks whether the current game has been finished.

Return value: bool


Network.GetRealTimeFactor()

Returns time multiplication factor of the current simulation.

Return value: float


Network.GetCurrentWorld()

Returns file path of the currently loaded world.

Return value: string


Network.GetGameTime()

Returns time since the start of the current game in seconds.

Return value: float

Entities

Network.GetPlayerTarget(index)

Returns entity of a specific player by a unique index on the server. If the player target is inactive, returns an empty CEntityPointer.
Throws a runtime error if the specified index is out of bounds.

Arguments:

  • index - Index of a player from 0 to Network.GetMaxPlayerTargets() - 1.

Return value: CEntityPointer that points to a player entity (may be none).


Network.IsPlayerTargetActive(index)

Checks whether a specific player is currently active under a unique index on the server.
Throws a runtime error if the specified index is out of bounds.

Arguments:

  • index - Index of a player from 0 to Network.GetMaxPlayerTargets() - 1.

Return value: bool


Network.GetMaxPlayerTargets()

Returns maximum amount of player targets that can currently be on the server at any given time.

Return value: integer


Network.GetPlayerEntityByName(name)

Returns entity of a specific player by name on the server. If multiple players have the exact same name, returns the entity of the first found player with that name.

Arguments:

  • name - Display name of a specific player to search for.

Return value: CEntityPointer that points to a player entity (may be null).


Network.CountEntitiesWithName(name)

Counts all entities in the current world with a specific entity name.

Arguments:

  • name - Name of entities to count.

Return value: integer with the amount of entities under the specified name.


Network.GetEntityWithName(name, index)

Goes through all entities in the current world with a specific name and returns one under a specific index in order of appearance.

Arguments:

  • name - Name of entities to go through.
  • index - Which entity under the specified name to retrieve.

Return value: CEntityPointer that points to the indexth entity under the specified name.


Network.IsPlayerLocal(entity)

Checks whether the specified entity is a player entity and whether it belongs to the client who runs this function.

Arguments:

  • entity - CEntityPointer with the player entity to check.

Return value: bool with whether the specified entity is a player of a local client.

Client-specific

Network.TogglePause()

Requests a game pause from the client side. If "Clients may pause" game option is turned off, this won't work.

Return value: null


Network.IsPaused()

Checks whether the current game is paused.

Return value: bool


Network.SendChat(from, to, message)

Sends a chat message from specific clients to other specific clients.

Arguments:

  • from - Client flags to send the chat message from (-1 to send from all local players).
  • to - Client flags to send the chat message to (-1 to send to everyone on the server).
  • message - Chat message to send.

Return value: null

Server-specific

Network.SendChatToClient(client, name, message)

Sends a chat message to just one specific client with a custom sender name.

Arguments:

  • client - Index of a client to send a message to.
  • name - Name of the sender to display.
  • message - Chat message to send.

Return value: null

Network.SendChatToEveryone(name, message)

Sends a chat message to all clients on the server with a custom sender name.

Arguments:

  • name - Name of the sender to display.
  • message - Chat message to send.

Return value: null


Network.KickClient(client, reason)

Kicks a specific client from the server with a reason. Client index 0 refers to the server itself and cannot be used.

Arguments:

  • client - Index of a client to kick.
  • reason - Message explaining the reason for a kick.

Return value: null


Network.GetHostName()

Returns the name of the machine that's currently running the server.

Return value: string with the host name.


Network.GetHostAddress()

Returns a comma-separated list of local network addresses of the machine that are currently used for running the server.

Return value: string with the host addresses.


Network.GetClients()

Returns a list of unique indices of active server clients. Valid values may be from 0 to Network.GetMaxClients() - 1. These indices refer to unique computers that are connected to the server, which may include clients with no players (observers) and clients with multiple players (split screen).

Return value: array with indices of active server clients.


Network.GetMaxClients()

Returns maximum amount of clients that may exist on a server at any given time, including clients with no players (observers) and clients with multiple players (split screen).

Return value: integer


Network.IsClientActive(client)

Checks whether the specified client slot is currently occupied by an active client. Throws a runtime error if the client index is out of bounds.

Arguments:

  • client - Index of a client to check.

Return value: bool with whether the specified client is active.


Network.CountPlayers(vip)

Returns the amount of actual players on the server, which may differ from the amount of clients.

Arguments:

  • vip - Whether to only count VIP players.

Return value: integer with the amount of players.


Network.CountClients(vip)

Returns the amount of server clients.

Arguments:

  • vip - Whether to only count VIP clients.

Return value: integer with the amount of clients.


Network.CountObservers()

Returns the amount of clients with no players.

Return value: integer with the amount of observers.


Network.CountClientPlayers(client)

Returns the amount of actual players of a specific client.

Arguments:

  • client - Index of a client to count the players of

Return value: integer with the amount of players.

Extension packets

Network.GetGameplayExtension(name)

Returns current value of the specified gameplay extension. Throws a runtime error if the gameplay extension doesn't exist.

Arguments:

  • name - Name of the gameplay extension to get the value of.

Return value: bool/integer/float/string - depending on the gameplay extension type.


Network.SetGameplayExtension(name, value)

Sets a new value to the specified gameplay extension by sending a network packet with the change to all clients.

Arguments:

  • name - Name of the gameplay extension to set the value to.
  • value - New value to set. May be bool, integer, float or string.

Return value: null


Network.ChangeLevel(file)

Naturally changes the current level on the server by creating and triggering a CWorldLink entity. May not work in mods that significantly change the behavior of this entity class.

Arguments:

  • file - Path to a world file to change to.

Return value: null


Network.ChangeWorld(file)

Immediately changes the current level on the server by calling the CNetworkLibrary::ChangeLevel() engine function, which may introduce unintentional side effects, such as spawning all players in the center of the next level instead of any CPlayerMarker.

Arguments:

  • file - Path to a world file to change to.

Return value: null


Network.StopSound(channel)

Stops playing sounds on the specified global channel.

Arguments:

  • channel - Sound channel to stop playing sounds on (0 - 31).

Return value: null


Network.GetSound(channel)

Returns a copy of a network sound from the specified channel that can be used to get information about the currently playing sound or to set it up to play a different sound.

Arguments:

  • channel - Sound channel to get a sound from (0 - 31).

Return value: Network.Sound with copied sound properties from the specified channel.

Current session properties

Network.GetSessionPropIndex(offset)

Reads a signed 32-bit integer value (4 bytes) from raw session properties data at the specified offset. Throws a runtime error if the offset is out of bounds.

Arguments:

  • offset - Offset to read session properties data from.

Return value: integer


Network.GetSessionPropFloat(offset)

Reads a 32-bit float value (4 bytes) from raw session properties data at the specified offset. Throws a runtime error if the offset is out of bounds.

Arguments:

  • offset - Offset to read session properties data from.

Return value: float


Network.GetSessionPropBool(offset)

Reads a 32-bit integer value (4 bytes) from raw session properties data at the specified offset and casts it into a boolean value. Throws a runtime error if the offset is out of bounds.

Arguments:

  • offset - Offset to read session properties data from.

Return value: bool


Network.GetSessionPropString(offset, length)

Reads the specified amount of bytes from raw session properties data at the specified offset and returns them as a null-terminated string. Throws a runtime error if the offset is out of bounds.

Arguments:

  • offset - Offset to read session properties data from.
  • length - Amount of bytes/characters to read.

Return value: string


Network.GetSessionPropByte(offset)

Reads a single byte from raw session properties data at the specified offset and casts it into an integer value. Throws a runtime error if the offset is out of bounds.

Arguments:

  • offset - Offset to read session properties data from.

Return value: integer

Chat commands

Network.AddChatCommand(command, function)

Registers a new chat command by its name. Throws a runtime error if the command with that name already exists.
Squirrel closure for the command should accept two arguments: client index (integer) and command arguments as a continuous string as provided (string). The return value must be a string that will act as command output.

Arguments:

  • command - Name of the command to add.
  • function - Squirrel closure to execute upon running the command.

Return value: null

Usage example

function MyCommand(client, args) {
  // Example output:
  // : You are client number 1, congratulations!
  // : Passed command arguments: 123 hello
  return "You are client number " + client + ", congratulations!\nPassed command arguments: " + args;
};

// Example input:
// > !mycom 123 hello
Network.AddChatCommand("mycom", MyCommand);

Network.RemoveChatCommand(command)

Unregisters a chat command by its name. Throws a runtime error if the command with that name doesn't exist or hasn't been registered by the same VM/script.

Arguments:

  • command - Name of the command to remove.

Return value: null


Network.ChatCommandExists(command)

Checks whether some chat command has been registered.

Arguments:

  • command - Name of the command to check.

Return value: bool with whether the specified command already exists.


Network.SetChatCommandAccess(command, level, hidden)

Sets access level for the chat command and whether to hide it from regular clients when listing it using the !help command.

Arguments:

  • command - Name of the command to check.
  • level - Access level to set from the ChatCommandAccess enum.
  • hidden - Whether the command should be hidden from the list of all commands.

Return value: bool with whether the command access has been changed.


Network.SetChatCommandInfo(command, arguments, description)

Sets useful usage information about the chat command when listing it using the !help command.

Arguments:

  • command - Name of the command to set info for.
  • arguments - List of arguments that the command accepts (may be empty). Example: "<index> <time> [message]"
  • description - Short description of the command's purpose.

Return value: bool with whether the command info has been changed.

Clone this wiki locally