Get value of a variable from q3config.cfg


Hey :grin:!
I’m trying to add a piece of code in ioquake3. It will change value of gui in terms of the tongue of the user. A kind of translation module.
So I want to add a new variable in the q3config.cfg file (in /home/user/.q3a/baseq3/q3config.cfg) called “langage”, I want it to be settable and I want to read the value of it.
So, there are my questions:roll_eyes: :

  • How to read the value of a variable written in q3config.cfg ?
  • How to modify the value of a (…) ?

A big thank, I have been searching for hours without finding answers :disappointed:


It depends whether the cvar is in the engine, renderer, game, cgame, or ui.

In game, cgame, or ui add the cvar to the appropriate cvar table (with CVAR_ARCHIVE flag) to create cvar in q3config.cfg with initial value:

  • Game: gameCvarTable in code/cgame/cg_main.c
  • CGame: cvarTable in code/cgame/cg_main.c
  • UI (Quake 3): cvarTable in code/q3_ui/ui_main.c
  • UI (Team Arena): cvarTable in code/ui/ui_main.c

To access cvar value use vmCvar_t variable (i.e., g_gametype) which are listed in the cvarTable. g_gametype.value (decimal number), g_gametype.interger (whole number), g_gametype.string (text).

Change cvar using trap_Cvar_Set( "g_gametype", "4" ). Note however that g_gametype.interger is not immediately updated; it’s only updated at the beginning of the frame.


You are awesome !
It works like a charm !

Thank you !:kissing_closed_eyes: :grin: