From ZDoom Wiki
Jump to: navigation, search

Warning: This feature has at least one use case where the outcome is indeterminate. This feature can break demo and multiplayer sync if an indeterminate result is used to modify the playsim (anything that uses the random number generator, modify level geometry, spawn obstacles, monsters, or powerups, and so on). Usage of the feature in conjunction with non-playsim related features, such as displaying a HudMessage, is safe.

Using non-playsim CVARs such as screenblocks or invertmouse will cause indeterminate behavior. Using Server or User variables, either internal or defined via CVARINFO, is however perfectly safe.

int GetCVar (str cvar)


Returns the value of a particular cvar.


Return value

The value of the specified console variable. This is only useful for cvars that can be represented as integers. Also note that you can create your own console variables by using the CVARINFO lump.

If the console variable is a user CVAR, it will check the activator of the script. To check the user CVAR of a specific player, you can use GetUserCVar.

If no such console variable exists, it will return 0.


This script will spawn Imps only if sv_nomonsters is false:

if (!GetCVar ("sv_nomonsters"))
    SpawnSpot ("DoomImp", 66);
    SpawnSpot ("TeleportFog", 66);

One possible use for this is if you are making additions to the HUD, you can check if the player is using the status bar or not and act accordingly:

int screenblocks = GetCVar ("screenblocks");

if (screenblocks < 10)
    // The status bar is visible
else if (screenblocks == 10)
    // The fullscreen HUD is visible instead
    // No HUD of any sort is visible

See also

Console variable functions
GetCVar SetCVar
GetCVarString SetCVarString
GetUserCVar SetUserCVar
GetUserCVarString SetUserCVarString