ConVar.Find() does not find FakeConVars
public class Test : BasePlugin
{
public override string ModuleName => "Test";
public override string ModuleVersion => "1.0.0";
public FakeConVar<bool> ConVarTest = new("cvar_test", "Test", true, ConVarFlags.FCVAR_REPLICATED);
public override void Load(bool isReload)
{
RegisterFakeConVars(typeof(ConVar));
AddCommand("css_test", "", (player, info) =>
{
var cvar = ConVar.Find("cvar_test");
Console.WriteLine(cvar);
});
}
}
Because FakeConVar aren't registered as real ConVar, It just mimic the ConVar behaviour
so what is the solution for admin plugins to "interact" with "fakeconvars" if it cannot be registered? source mod managed it somehow
https://github.com/daffyyyy/CS2-SimpleAdmin/blob/3f1b6b3bf74ab974e777f9495edf20a24c847764/CS2-SimpleAdmin/Commands/basecommands.cs#L940
https://github.com/schwarper/cs2-admin/blob/74bc4c2fe3d6ce979fa43b683e91bbd07e86c6c5/basecommands/src/basecommands.cs#L152
https://github.com/alliedmodders/sourcemod/blob/cb0f8f0eaa8f1edb46888d7f1d797c0493f9f51f/plugins/basecommands.sp#L288
so what is the solution for admin plugins to "interact" with "fakeconvars" if it cannot be registered? source mod managed it somehow
https://github.com/daffyyyy/CS2-SimpleAdmin/blob/3f1b6b3bf74ab974e777f9495edf20a24c847764/CS2-SimpleAdmin/Commands/basecommands.cs#L940
https://github.com/schwarper/cs2-admin/blob/74bc4c2fe3d6ce979fa43b683e91bbd07e86c6c5/basecommands/src/basecommands.cs#L152
https://github.com/alliedmodders/sourcemod/blob/cb0f8f0eaa8f1edb46888d7f1d797c0493f9f51f/plugins/basecommands.sp#L288
FakeConVar is now based on ConCommand because hl2sdk does not implement ConVar correctly