Raised This Month: $51 Target: $400
 12% 

Difference between QueryClientConVar and GetClientInfo


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ImACow
AlliedModders Donor
Join Date: Feb 2015
Old 12-18-2019 , 11:47   Difference between QueryClientConVar and GetClientInfo
Reply With Quote #1

What is the difference between QueryClientConVar and GetClientInfo and?

I'm trying to understand the difference between the two, and possibly the underlying difference.



API QueryClientConVar
API GetClientInfo

Source for QueryClientConVar

PHP Code:
static cell_t sm_QueryClientConVar(IPluginContext *pContext, const cell_t *params)
{
    
CPlayer *pPlayer;
    
char *name;
    
IPluginFunction *pCallback;

    if (!
g_ConVarManager.IsQueryingSupported())
    {
        if (!
s_QueryAlreadyWarned)
        {
            
s_QueryAlreadyWarned true;
            return 
pContext->ThrowNativeError("Game does not support client convar querying (one time warning)");
        }

        return 
0;
    }

    
pPlayer g_Players.GetPlayerByIndex(params[1]);

    if (!
pPlayer)
    {
        return 
pContext->ThrowNativeError("Client index %d is invalid"params[1]);
    }

    if (!
pPlayer->IsConnected())
    {
        return 
pContext->ThrowNativeError("Client %d is not connected"params[1]);
    }

    
/* Trying a query on a bot results in callback not be fired, so don't bother */
    
if (pPlayer->IsFakeClient())
    {
        return 
0;
    }

    
pContext->LocalToString(params[2], &name);
    
pCallback pContext->GetFunctionById(params[3]);

    if (!
pCallback)
    {
        return 
pContext->ThrowNativeError("Invalid function id (%X)"params[3]);
    }

    return 
g_ConVarManager.QueryClientConVar(pPlayer->GetEdict(), namepCallbackparams[4]);

Source for GetClientInfo

PHP Code:
static cell_t sm_GetClientInfo(IPluginContext *pContext, const cell_t *params)
{
    
int client params[1];
    
IGamePlayer *pPlayer playerhelpers->GetGamePlayer(client);
    if (!
pPlayer)
    {
        return 
pContext->ThrowNativeError("Client index %d is invalid"client);
    }
    if (!
pPlayer->IsConnected())
    {
        return 
pContext->ThrowNativeError("Client %d is not connected"client);
    }

    
char *key;
    
pContext->LocalToString(params[2], &key);

    const 
char *val engine->GetClientConVarValue(clientkey);
    if (!
val)
    {
        return 
false;
    }

    
pContext->StringToLocalUTF8(params[3], params[4], valNULL);
    return 
1;

QueryClientConVar calls QueryClientConVar with a callback
GetClientInfo calls GetClientConVarValue without callback
__________________

Last edited by ImACow; 12-18-2019 at 11:48.
ImACow is offline
MAGNAT2645
Senior Member
Join Date: Nov 2015
Location: AlliedMods.net
Old 12-18-2019 , 12:08   Re: Difference between QueryClientConVar and GetClientInfo
Reply With Quote #2

Maybe GetClientInfo works only with replicated (or with FCVAR_USERINFO flag) convars while QueryClientConVar allows you to check most client convars?

EDIT:
So, i think, better to use GetClientInfo for convars with FCVAR_USERINFO flag (ex. "cl_language", "cl_cmdrate" etc.)
and QueryClientConVar in every other case.

Also, i think QueryClientConVar uses callback because this function is delayed (like query to Database) and can return error.
while GetClientInfo can get prefetched (not sure 100%) values, so no callback needed.
__________________

Last edited by MAGNAT2645; 12-19-2019 at 08:41.
MAGNAT2645 is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 07:14.


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