Raised This Month: $32 Target: $400
 8% 

Retrieving a cvar value in the server code (MP)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Ko2bnt
New Member
Join Date: Mar 2016
Old 08-05-2017 , 11:47   Retrieving a cvar value in the server code (MP)
Reply With Quote #1

Hi there! Maybe I'm wrong with choosing the forum thread, if so, I'm sorry.

First of all, I'm writing HL2: DM server from Valve Source SDK 2013 so I can't edit client code, I'm working only with server code.

Now I'm trying to get cvar's value from the server side (not a plugin, I don't want to build a plugin just to getting cvar values). ATM I use engine->StartQueryCvarValue like that ('cl_playermodel' just for example):

Code:
int nQueryResult = (int)engine->StartQueryCvarValue(pPlayer->edict(), "cl_playermodel");
I'm trying to catch the result on CServerGameDLL::OnQueryCvarValueFinished that declared as:

Code:
virtual void			OnQueryCvarValueFinished(QueryCvarCookie_t iCookie, edict_t *pPlayerEntity, EQueryCvarValueStatus eStatus, const char *pCvarName, const char *pCvarValue);
But! I get negative values in the nQueryResult (as far as I know, that means the engine consider it as a query from a server and should respond something to IServerGameDLL::OnQueryCvarValueFinished) and... nothing happens. No errors, no values got.

Can somebody explain me how I can get convar values from the server code? Thanks a lot for any help!

Last edited by Ko2bnt; 08-05-2017 at 11:49.
Ko2bnt is offline
Fyren
FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren
Join Date: Feb 2106
Old 08-06-2017 , 07:06   Re: Retrieving a cvar value in the server code (MP)
Reply With Quote #2

When you say the return is negative, do you mean it's -1? That's a special value to tell you that the edict you passed is bad and you won't get a callback.
Fyren is offline
Ko2bnt
New Member
Join Date: Mar 2016
Old 08-06-2017 , 08:31   Re: Retrieving a cvar value in the server code (MP)
Reply With Quote #3

Quote:
Originally Posted by Fyren View Post
When you say the return is negative, do you mean it's -1? That's a special value to tell you that the edict you passed is bad and you won't get a callback.
I know about that (the sdk says "Returns InvalidQueryCvarCookie if the entity is invalid.") But I mean -1, -2, -3 etc values. I had take a look into engine code and I found that in case of StartQueryCvarValue call from the server dll the engine returns values as negative:

Code:
// Send a message to the client asking for the value.
SVC_GetCvarValue msg;
msg.m_iCookie = g_iQueryCvarCookie++;
msg.m_szCvarName = pCvarName;

// If the query came from the game DLL instead of from a plugin, then we negate the cookie
// so it knows who to callback on when the value arrives back from the client.
if ( !bPluginQuery )
	msg.m_iCookie = -msg.m_iCookie;
	
client->SendNetMsg( msg );
return msg.m_iCookie;
Besides, the edict I sent absolutely cannot be bad, I can say it for sure. I've read that post, I do the same, but it does not work:


Code:
mp\src\game\server\gameinterface.cpp

void CServerGameDLL::OnQueryCvarValueFinished(QueryCvarCookie_t iCookie, edict_t *pPlayerEntity, EQueryCvarValueStatus eStatus, const char *pCvarName, const char *pCvarValue)
{
	Msg("CServerGameDLL::OnQueryCvarValueFinished : %s, %s\n", pCvarName, pCvarValue);
}

void CC_TestCvar(const CCommand& args)
{
	CBasePlayer *pPlayer = UTIL_GetCommandClient();

	if (!pPlayer)
		return;

	int nQueryResult = engine->StartQueryCvarValue(pPlayer->edict(), "cl_playermodel");
	Msg("nQueryResult : %d\n", nQueryResult);
}
static ConCommand test_cvar("test_cvar", CC_TestCvar, "", FCVAR_NONE);
Message from CServerGameDLL::OnQueryCvarValueFinished does not appear and I don't see any error messages in server or client console.

Last edited by Ko2bnt; 08-06-2017 at 08:38.
Ko2bnt is offline
Fyren
FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren
Join Date: Feb 2106
Old 08-06-2017 , 10:16   Re: Retrieving a cvar value in the server code (MP)
Reply With Quote #4

Since cl_playermodel in the base SDK appears to have the userinfo flag, I think you should be able to use GetClientConVarValue on the engine. I don't know why the async query wouldn't work, though.

If no one else has any ideas, you can try asking for help in #hlcoders on GameSurge.
Fyren is offline
Ko2bnt
New Member
Join Date: Mar 2016
Old 08-06-2017 , 10:56   Re: Retrieving a cvar value in the server code (MP)
Reply With Quote #5

cl_playermodel is just an example. I want to get cvars like mat_wireframe etc. So GetClientConVarValue can't help me. But thank you anyway.
Ko2bnt 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 10:55.


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