Mega-ZBlog

You are here.

Mega-ZBlog header image

Monitoring CVAR changes in the Source engine

July 5th, 2009 · 2 Comments · Games

If you want to create a script that toggles a setting in a Source engine game like Left 4 Dead, you need to know the console variable name that controls it, but sometimes you don’t know.  One way to figure it out is to blindly search using the “find” command to look for a command that looks like it controls what you need.  The other way is to dump the cvar list to disk, change the setting in the GUI, dump the list again, and compare the two lists.

However the latter approach is not easy.  There is a condump command but it only dumps a limited amount of text, and the cvarlist command displays too much text for the console to hold (or dump).

However, taking advantage of the fact that cvars always start with a letter, we can brute force this.  First, clear any condump*.txt files from your Source engine mod folder (For Left 4 Dead, it’s Steam\common\Left 4 Dead\left4dead) and then run the following three commands in sequence:

clear; cvarlist a; condump; clear; cvarlist b; condump; clear; cvarlist c; condump; clear; cvarlist d; condump; clear; cvarlist e; condump; clear; cvarlist f; condump; clear; cvarlist g; condump; clear; cvarlist h; condump; clear; cvarlist i; condump

clear; cvarlist j; condump; clear; cvarlist k; condump; clear; cvarlist l; condump; clear; cvarlist m; condump; clear; cvarlist n; condump; clear; cvarlist o; condump; clear; cvarlist p; condump; clear; cvarlist q; condump; clear; cvarlist r; condump

clear; cvarlist s; condump; clear; cvarlist t; condump; clear; cvarlist u; condump; clear; cvarlist v; condump; clear; cvarlist w; condump; clear; cvarlist x; condump; clear; cvarlist y; condump; clear; cvarlist z; condump

(Three lines of commands are needed since there is a limit to the length of one console command.)

Now you have 26 condump files in your Source mod folder.  Move them to an empty temporary folder on your desktop or somewhere.  Now change the setting you’re trying to find the cvar for and runt he console commands again to get another batch of 26 files.  Move these to a SECOND temporary folder.

Then, download WinMerge (or use a similar file/directory comparison tool) and point it at both folders.  Bam.  It will instantly show you which dumped files changed, and you can then go into the files and see the changed values side by side.

Tags: ·····

2 responses so far ↓

  • 1 Zahit Atacan // Jan 10, 2010 at 4:29 pm

    Very Good. Thank you for information.

  • 2 jay4 // Mar 26, 2014 at 1:25 pm

    what if you use con_log instead condump?

You must log in to post a comment.