API Reference › Convars
IConVarService
InterfaceNamespace: SwiftlyS2.Shared.Convars · Assembly: SwiftlyS2.CS2.dll
public interface IConVarServiceMethods
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 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 : unmanagedParameters
- 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.
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.
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 : unmanagedParameters
- 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 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.
Find a existing convar by name with no type.
IConVar? FindAsString(string name)Parameters
- namestringThe name of the convar.
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)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)