I did this tut for q2, so I'm doing it again for q3. Enjoy (Not actually tested, let me know if this works properly]
This is a fairly easy one. No new files. It does require a few changes to a few files though. The cvar I will be adding will be called s_disableweapons Simply chage it to whatever you want your cvar to be
The first file anything will be added to is g_local.h Big surprise isn't it?.
Find the line which reads
extern vmCvar_t g_filterBan;And just under it put
extern vmCvar_t s_disableweapons;extern means it isn't defined here but that it exists and can be used. As this is in g_local.h it can be used anywhere in the source.
Next open up g_main.c and find the line that reads
vmCvar_t g_filterBan;just under it insert
vmCvar_t s_disableweapons;Thats it defined. now we need to initilize it. Find the line below
{ &g_allowVote, "g_allowVote", "1", 0, 0, qfalse }
Insert { &s_disableweapons, "s_disableweapons", "0", CVAR_SERVERINFO | CVAR_LATCH, 0, qfalse } just after it, before the };. Then add a comma (,) to the end of the line before the one you just added (oops missed this first time out. Thanks Assassin{SH})
The CVAR_SERVERINFO | CVAR_LATCH means that the cvar will be server side only, and will stick at a certain value till the map changes. The final field determines whether it's annouced that the cvar is changed. The "0" is the default value (it's stored as a string, so set it as a string)
Thats the basics of adding a cvar, heres how to use it
Check the value of s_disableweapons.integer in code where you want to check the cvar. easy don't you think?( You can also check s_disableweapons.value [for floating point values] and s_disableweapons.string [for strings. default max length is 265 characters])