Query client cvar

Please post any questions about developing your plugin here. Please use the search function before posting!
marcowmadeira
Junior Member
Posts: 11
Joined: Wed Apr 27, 2016 11:54 am

Query client cvar

Postby marcowmadeira » Thu Nov 03, 2016 12:04 am

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?
User avatar
iPlayer
Developer
Posts: 590
Joined: Sat Nov 14, 2015 8:37 am
Location: Moscow
Contact:

Re: Query client cvar

Postby iPlayer » Thu Nov 03, 2016 1:01 am

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
Image /id/its_iPlayer
My plugins: Map Cycle • Killstreaker • DeadChat • Infinite Jumping • TripMines • AdPurge • Bot Damage • PLRBots • Entity AntiSpam

Hail, Companion. [...] Hands to yourself, sneak thief. Image
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: Query client cvar

Postby L'In20Cible » Thu Nov 03, 2016 6:56 am

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.
marcowmadeira
Junior Member
Posts: 11
Joined: Wed Apr 27, 2016 11:54 am

Re: Query client cvar

Postby marcowmadeira » Thu Nov 03, 2016 9:43 am

Thank you, this is it. :smile:
User avatar
iPlayer
Developer
Posts: 590
Joined: Sat Nov 14, 2015 8:37 am
Location: Moscow
Contact:

Re: Query client cvar

Postby iPlayer » Thu Nov 03, 2016 2:55 pm

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. :smile:

No problem, and welcome to the community :smile:
Last edited by iPlayer on Thu Nov 03, 2016 3:04 pm, edited 1 time in total.
Image /id/its_iPlayer
My plugins: Map Cycle • Killstreaker • DeadChat • Infinite Jumping • TripMines • AdPurge • Bot Damage • PLRBots • Entity AntiSpam

Hail, Companion. [...] Hands to yourself, sneak thief. Image
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: Query client cvar

Postby L'In20Cible » Thu Nov 03, 2016 3:02 pm

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.

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 31 guests