This document aims to inform you of how you may cause the value of a cvar to appear as text in the HUD. This is useful for several kinds of scripts. Think of a display for what you will disguise to as an agent when you do so, or how many seconds a H.E Charge will be when you lay it.
This is actually very simple, you just make use of the cvar keyword in an itemDef. The format is as in:
cvar "<cvarname>"
The easiest way to really show you how this works is to show you what I have in my own HUD for the Agent class:
menuDef { name "agent_scripting" fullscreen MENU_FALSE rect 0 405 146 16 visible MENU_TRUE ownerDrawFlag CG_SHOW_PLAYER_IS_AGENT ownerDrawFlag CG_SHOW_NO_SCOREBOARD itemDef { visible MENU_TRUE rect 4 0 70 16 decoration textscale .27 forecolor 1 1 1 .6 textaligny 13 cvar "disguiseskin" } itemDef { visible MENU_TRUE rect 97 0 5 16 decoration textscale .27 forecolor 1 1 1 .6 textaligny 13 text "|" } itemDef { visible MENU_TRUE rect 102 0 70 16 decoration textscale .27 forecolor 1 1 1 .6 textaligny 13 cvar "disguisecolour" } itemDef { visible MENU_TRUE rect 0 0 146 16 decoration background "ui/gfx/hud/fill_center_grey.tga" style WINDOW_STYLE_SHADER } }I've highlighted one itemDef which displays the contents of the "disguisecolour" cvar. My Agent script has this:
set colourdisguise "echo_q3f Select Enemy Team Colour" set colourcycle "vstr teamcolour1" set teamcolour1 "set colourdisguise disguise team blue;set colourcycle vstr teamcolour2;echo_q3f Disguise colour - Blue;set disguisecolour Blue" set teamcolour2 "set colourdisguise disguise team red;set colourcycle vstr teamcolour3;echo_q3f Disguise colour - Red;set disguisecolour Red" set teamcolour3 "set colourdisguise disguise team yellow;set colourcycle vstr teamcolour4;echo_q3f Disguise colour - Yellow;set disguisecolour Yellow" set teamcolour4 "set colourdisguise disguise team green;set colourcycle vstr teamcolour1;echo_q3f Disguise colour - Green;set disguisecolour Green" bind leftarrow "vstr colourcycle" bind uparrow "vstr colourdisguise"As you should be able to see this has the left arrow key cycle around the four team colours, each time using echo_q3f to display on the console the current one. It also sets the disguisecolour cvar to be that same team colour. Thus I have displayed on my HUD the colour I'll disguise to when I press the up arrow key.