swiftlys2/docs/api/ai/
API Reference Convars

IConVarService

Interface
Namespace: SwiftlyS2.Shared.Convars · Assembly: SwiftlyS2.CS2.dll
public interface IConVarService
View source

Methods

Create<T>(string, string, T, ConvarFlags)

Create a new convar.

IConVar<T> Create<T>(string name, string helpMessage, T defaultValue, ConvarFlags flags = ConvarFlags.NONE)
Parameters
  • namestringThe name of the convar.
  • helpMessagestringThe help message of the convar.
  • defaultValueTThe default value of the convar.
  • flagsConvarFlagsoptionalThe flags of the convar.
Returns
IConVar<T>
The created convar.

Create<T>(string, string, T, T?, T?, ConvarFlags)

Create a new convar with min and max values.

IConVar<T> Create<T>(string name, string helpMessage, T defaultValue, T? minValue, T? maxValue, ConvarFlags flags = ConvarFlags.NONE) where T : unmanaged
Parameters
  • namestringThe name of the convar.
  • helpMessagestringThe help message of the convar.
  • defaultValueTThe default value of the convar.
  • minValueT?The min value of the convar.
  • maxValueT?The max value of the convar.
  • flagsConvarFlagsoptionalThe flags of the convar.
Returns
IConVar<T>
The created convar.

CreateOrFind<T>(string, string, T, ConvarFlags)

Create a new convar or find an existing one by name.

IConVar<T> CreateOrFind<T>(string name, string helpMessage, T defaultValue, ConvarFlags flags = ConvarFlags.NONE)
Parameters
  • namestringThe name of the convar.
  • helpMessagestringThe help message of the convar.
  • defaultValueTThe default value of the convar.
  • flagsConvarFlagsoptionalThe flags of the convar.
Returns
IConVar<T>
The created or found convar.

CreateOrFind<T>(string, string, T, T?, T?, ConvarFlags)

Create a new convar or find an existing one by name with min and max values.

IConVar<T> CreateOrFind<T>(string name, string helpMessage, T defaultValue, T? minValue, T? maxValue, ConvarFlags flags = ConvarFlags.NONE) where T : unmanaged
Parameters
  • namestringThe name of the convar.
  • helpMessagestringThe help message of the convar.
  • defaultValueTThe default value of the convar.
  • minValueT?The min value of the convar.
  • maxValueT?The max value of the convar.
  • flagsConvarFlagsoptionalThe flags of the convar.
Returns
IConVar<T>
The created or found convar.

Find<T>(string)

Find a existing convar by name.

IConVar<T>? Find<T>(string name)
Parameters
  • namestringThe name of the convar.
Returns
IConVar<T>?
The convar if found, null otherwise.

FindAsString(string)

Find a existing convar by name with no type.

IConVar? FindAsString(string name)
Parameters
  • namestringThe name of the convar.
Returns
The convar if found, null otherwise.

ReplicateToAll(string, string)

Replicate the value of the convar to all clients. You can use this method to replicate those convars that don't exist on server.

void ReplicateToAll(string name, string value)
Parameters
  • namestringThe name of the convar.
  • valuestringThe value to replicate.

ReplicateToClient(int, string, string)

Replicate the value of the convar to a specific client. You can use this method to replicate those convars that don't exist on server.

void ReplicateToClient(int clientId, string name, string value)
Parameters
  • clientIdintThe client id to replicate to.
  • namestringThe name of the convar.
  • valuestringThe value to replicate.