Author Topic: Noob question --> setting a client var  (Read 5252 times)

SPK

  • Posts: 58
  • Turrets: +2/-0
Noob question --> setting a client var
« on: November 13, 2010, 03:41:22 pm »
Well I'm just learning to code basic things in QVMs, the only thing is that I dont know C, just the basic programming syntax...
I want to set a client var, and be able to change it on console by '/var value'

BTW I have this:

In g_local.h:    
---------------------------------------

typedef struct
{
...
lang_t           lang;  
...
}

---------------------------------------



In bg_public.h:
--------------------------------------

typedef enum
{
  LANG_ESP,
  LANG_ENG,
  LANG_DEF
} lang_t;

--------------------------------------


In g_client.c:
--------------------------------------

s = Info_ValueForKey( userinfo, "cl_lang" );

  if( !Q_stricmp( s, "esp" )  )
    client->pers.lang =   LANG_ESP;
  else if( !Q_stricmp( s, "eng" )  )
   client->pers.lang = LANG_ENG;
  else
   client->pers.lang = LANG_DEF;

-------------------------------------


Whats the noob thing I'm missing?
Thanks for reading : /

EDIT: Additional obvious info:
I can compile the qvm and check that the server loads it correctly, so dont think about this
« Last Edit: November 13, 2010, 03:47:16 pm by SPK »

F50

  • Posts: 740
  • Turrets: +16/-26
Re: Noob question --> setting a client var
« Reply #1 on: November 14, 2010, 01:38:35 am »
You're looking in the wrong place, try searching the files for the name of an already existing cvar like "cg_teamOverlayMaxPlayers" perhaps, or "cl_useMumble". It isn't that hard to add, don't try to write much code beyond variable declarations and the definition of the cvar (which gives it an initial value). In total it will be around 3 lines of code in a few different files.
"Any sufficiently advanced stupidity is indistinguishable from malice." -- Grey's Law


SPK

  • Posts: 58
  • Turrets: +2/-0
Re: Noob question --> setting a client var
« Reply #2 on: November 14, 2010, 10:46:05 am »
I dont find any of that vars in any file : /

F50

  • Posts: 740
  • Turrets: +16/-26
Re: Noob question --> setting a client var
« Reply #3 on: November 17, 2010, 10:40:47 pm »
My apologies, cg_* variables aren't in the file I'm thinking of. Here is a section of the diff from my build queue slowdown mod (src/game/g_main.c). Playing around with this should give you most of what you want.

Code: [Select]
Index: src/game/g_main.c
===================================================================
--- src/game/g_main.c   (revision 2048)
+++ src/game/g_main.c   (working copy)
@@ -74,6 +74,8 @@
 vmCvar_t  g_minNameChangePeriod;
 vmCvar_t  g_maxNameChanges;

+vmCvar_t  g_buildQueueSlowdown;
+
 vmCvar_t  g_alienBuildPoints;
 vmCvar_t  g_alienBuildQueueTime;
 vmCvar_t  g_humanBuildPoints;
@@ -196,6 +198,8 @@
   { &pmove_fixed, "pmove_fixed", "0", CVAR_SYSTEMINFO, 0, qfalse},
   { &pmove_msec, "pmove_msec", "8", CVAR_SYSTEMINFO, 0, qfalse},

+  { &g_buildQueueSlowdown, "g_buildQueueSlowdown", DEFAULT_BUILD_QUEUE_SLOWDOWN, 0, 0, qfalse  },
+
   { &g_alienBuildPoints, "g_alienBuildPoints", DEFAULT_ALIEN_BUILDPOINTS, 0, 0, qfalse  },
   { &g_alienBuildQueueTime, "g_alienBuildQueueTime", DEFAULT_ALIEN_QUEUE_TIME, CVAR_ARCHIVE, 0, qfalse  },
   { &g_humanBuildPoints, "g_humanBuildPoints", DEFAULT_HUMAN_BUILDPOINTS, 0, 0, qfalse  },
"Any sufficiently advanced stupidity is indistinguishable from malice." -- Grey's Law


David

  • Spam Killer
  • *
  • Posts: 3543
  • Turrets: +249/-273
Re: Noob question --> setting a client var
« Reply #4 on: November 17, 2010, 11:29:24 pm »
The client needs to have the cvar with CVAR_USERINFO, either from a custom cgame or the user setting it by setu cl_lang eng
Any maps not in the MG repo?  Email me or come to irc.freenode.net/#mg.
--
My words are mine and mine alone.  I can't speak for anyone else, and there is no one who can speak for me.  If I ever make a post that gives the opinions or positions of other users or groups, then they will be clearly labeled as such.
I'm disappointed that people's past actions have forced me to state what should be obvious.
I am not a dev.  Nothing I say counts for anything.

SPK

  • Posts: 58
  • Turrets: +2/-0
Re: Noob question --> setting a client var
« Reply #5 on: November 18, 2010, 10:56:02 am »
Thank you guys = )  If I get anything I'll post here

EDIT: David, you mean I cannot do anything just with the qvm code? : /
« Last Edit: November 18, 2010, 12:43:49 pm by SPK »

David

  • Spam Killer
  • *
  • Posts: 3543
  • Turrets: +249/-273
Re: Noob question --> setting a client var
« Reply #6 on: November 18, 2010, 01:37:11 pm »
You can, but the user will need to set it with setu instead of set.
Any maps not in the MG repo?  Email me or come to irc.freenode.net/#mg.
--
My words are mine and mine alone.  I can't speak for anyone else, and there is no one who can speak for me.  If I ever make a post that gives the opinions or positions of other users or groups, then they will be clearly labeled as such.
I'm disappointed that people's past actions have forced me to state what should be obvious.
I am not a dev.  Nothing I say counts for anything.