AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Coding MM:S Plugins & SM Extensions (https://forums.alliedmods.net/forumdisplay.php?f=75)
-   -   OnQueryCvarValueFinished never gets called (https://forums.alliedmods.net/showthread.php?t=305095)

Backup 02-06-2018 18:02

OnQueryCvarValueFinished never gets called
 
Hi,
I'm writing an extension and I'm trying to get client's cvar.
When I called engine->GetClientConVarValue(...), I got empty string. I've expected this since the cvar is quite unusual.
Now I'm calling engine->StartQueryCvarValue(...), I get valid cookie, but OnQueryCvarValueFinished never gets called!
I have it hooked the same way as sourcemod does it:
Code:

SH_DECL_HOOK5_void(IServerGameDLL, OnQueryCvarValueFinished, SH_NOATTRIB, 0, QueryCvarCookie_t, edict_t *, EQueryCvarValueStatus, const char *, const char *);

bool CExtension::SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlen, bool late) {
        SH_ADD_HOOK(IServerGameDLL, OnQueryCvarValueFinished, gamedll, SH_MEMBER(this, &CExtension::OnQueryCvarValueFinished), false);
}

I've tried different cvars without any luck. I'm testing this in csgo.

Have you encountered such issue?

Thanks!

Fyren 02-06-2018 22:33

Re: OnQueryCvarValueFinished never gets called
 
Skimming the SM code, it appears you're hooking the wrong interface, at least. SM hooks it on IServerPluginCallbacks when the engine is not ep1.

Backup 02-07-2018 04:38

Re: OnQueryCvarValueFinished never gets called
 
Thanks!
Switched to IServerPluginCallbacks::OnQueryCvarValueFinis hed and to IServerPluginHelpers::StartQueryCvarValue, and it workes like a charm! :)

When we're at it - is there any way how to be notified when client changes this cvar? Or any cvar at all, just so I don't have to poll this information all the time?

psychonic 02-07-2018 13:24

Re: OnQueryCvarValueFinished never gets called
 
If the ConVar has the userinfo flag set on it, you can use GetClientConVarValue and watch for changed by hooking IServerGameClients::ClientSettingsChanged.

If it does not, you have to poll the way you're doing now, with no direct way to get notified of changes.

You can find a list of these vars by issuing "findflags userinfo" in the client console.

Backup 02-08-2018 05:48

Re: OnQueryCvarValueFinished never gets called
 
Thanks for the findflags userinfo hint. As expected, the cvar has not the flag set, but polling from time to time works just fine. :)


All times are GMT -4. The time now is 02:38.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.