Querying ConVars from Server DLL

From Valve Developer Community
Jump to: navigation, search

With the Source Engine update on 11/29/2006 new functions were added to allow mod authors to query the values of particular convars set on the client. Since this functionality is greatly desired by the mod community and we are not currently ready for an SDK update we have created this page in order to demonstrate how to use this new functionality.

All of the required changes are in src\public\eiface.h.

If you have any questions about these new functions please feel free to contact mdurand@valvesoftware.com.

Step 1 - Add new function declaration to bottom of IVEngineServer

Add the following lines to the end of the public: section of IVEngineServer

  // Call this to find out the value of a cvar on the client.
  //
  // It is an asynchronous query, and it will call IServerGameDLL::OnQueryCvarValueFinished when 
  // the value comes in from the client.
  //
  // Store the return value if you want to match this specific query to the OnQueryCvarValueFinished call.
  // Returns InvalidQueryCvarCookie if the entity is invalid.
  virtual QueryCvarCookie_t StartQueryCvarValue( edict_t *pPlayerEntity, const char *pName ) = 0;

Step 2 - Add and modify #define's

Add the following lines beneath the declaration of IVEngineServer. You will be changing the value of INTERFACEVERSION_SERVERGAMEDLL which was previously defined.

  #define INTERFACEVERSION_SERVERGAMEDLL_VERSION_5	"ServerGameDLL005"
  #define INTERFACEVERSION_SERVERGAMEDLL		"ServerGameDLL006"

Step 3 - Add new function declaration to IServerGameDLL

Add the following four lines to the end of the public: section of IServerGameDLL

  // * This function is new with version 6 of the interface.
  //
  // This is called when a query from IServerPluginHelpers::StartQueryCvarValue is finished.
  // iCookie is the value returned by IServerPluginHelpers::StartQueryCvarValue.
  // Added with version 2 of the interface.
  virtual void OnQueryCvarValueFinished( QueryCvarCookie_t iCookie, edict_t *pPlayerEntity, EQueryCvarValueStatus eStatus, const char *pCvarName, const char *pCvarValue ) = 0;