Page 1 of 1
Query client cvar
Posted: Thu Nov 03, 2016 12:04 am
by marcowmadeira
Is it possible to query a client cvar? In sourcemod the command is
QueryClientConVar, i tried to find in the documentation, but i don't think there is a function for it. Is there any alternative to do it?
Re: Query client cvar
Posted: Thu Nov 03, 2016 1:01 am
by iPlayer
This might work?Syntax: Select all
from engines.server import engine_server
from entities.helpers import edict_from_index
from listeners import OnQueryCvarValueFinished
def query_player_convar(index, cvar_name):
edict = edict_from_index(index)
engine_server.start_query_cvar_value(edict, cvar_name)
@OnQueryCvarValueFinished
def on_query_cvar_value_finished(cookie, index, status, cvar_name, cvar_value):
print("Value: {}".format(cvar_value))
Edit: fixed my misunderstanding of how convar querying works
Re: Query client cvar
Posted: Thu Nov 03, 2016 6:56 am
by L'In20Cible
iPlayer wrote:Edit: fixed my misunderstanding of how convar querying works
Not your fault, the docstring of that method is very mis-leading. I will try to update it soon.
Re: Query client cvar
Posted: Thu Nov 03, 2016 9:43 am
by marcowmadeira
Thank you, this is it.

Re: Query client cvar
Posted: Thu Nov 03, 2016 2:55 pm
by iPlayer
L'In20Cible wrote:iPlayer wrote:Edit: fixed my misunderstanding of how convar querying works
Not your fault, the docstring of that method is very mis-leading. I will try to update it soon.
What does that method return though? An integer called "cookie"? If so, I believe this cookie might prove very useful to determine what query we are serving in
OnQueryCvarValueFinished listener.
marcowmadeira wrote:Thank you, this is it.

No problem, and welcome to the community

Re: Query client cvar
Posted: Thu Nov 03, 2016 3:02 pm
by L'In20Cible
Yup, the cookie returned is to be compared into the listener. Only useful if the tasks you want to achieve need to be performed only once otherwise comparing the convar name does it just fine even though your code runs whenever any plugin is querying the said convar name.
We may consider adding a Player.query_convar(<cvar name>, <callback>) in the future.
Re: Query client cvar
Posted: Thu Nov 03, 2016 3:03 pm
by satoon101