View Single Post
Author Message
Thraka
AlliedModders Donor
Join Date: Aug 2005
Old 05-25-2009 , 18:52   [L4D & L4D2] Game Mode Config Loader 1.6
Reply With Quote #1

This plugin will execute a config file based on the current game play mode. Because I like Versus tweaked for a higher difficulty than a coop game, I use this to do that, but leave coop up to the lobby settings. Also, the survivor mode, I think, shouldn't have any adjustments made to it. This plugin gives me that ability.

Notes
Left 4 Dead will change the game type automatically when someone hosts a lobby for a specific game type and then ends up connecting to your server.

The z_difficulty CVAR used to determine the difficulty for co-op uses the values Easy, Normal, Hard, Impossible. While the UI in the game uses Easy, Normal, Advanced, Expert. I set the names of the config files (default) to match the z_difficulty CVAR value, while the description of the coop - difficulty script CVARs matches the UI text.

If a game mode is selected which is not used by the hardcoded cfg files (see the cvars) it will automatically look for a .cfg file that matches the game mode text. To figure this out, configure your lobby as desired, start the game in the server then check the hidden mp_gamemode cvar for the value. Then create a .cfg file with the same file name as cvar value.

Version History
1.8:
  • Created gamemode_resetconvars cvar. Defaults to on and when on, before executing the cfg file for the game mode, the reset_gameconvars console command will execute which resets all the cvars.
  • Executes a .cfg file with the same file name as the value of the mp_gamemode cvar if the mp_gamemode is not coded into the plugin directly. This is a fallback system to execute .cfg files when Valve implements new mutations or game modes.
  • Logs what it excutes.
1.6:
  • Supports modes added by L4D2
1.5:
  • Supports teamversus mode.
1.4:
  • Added suggestions\code from Dionys to re-execute the cfg when mp_gamemode and z_difficulty change mid game.
  • Added plugin version cvar for tracking.
1.3:
  • Added the ability to auto-execute a config script based on coop difficulty.
1.2:
  • Changed meta data (URL and TITLE).
1.1:
  • Removed bad code line.
  • Changed all references from survivor to survival
1.0
  • Initial release.

CVARs
gamemode_config_ver - Version of this plugin.

gamemode_resetconvars - Resets the console vars () before executing the config
gamemode_config_coop - CFG file to execute when game mode is coop - Default: coop.cfg
gamemode_config_versus - CFG file to execute when game mode is versus - Default: versus.cfg
gamemode_config_teamversus - CFG file to execute when game mode is teamversus. - Default teamversus.cfg
gamemode_config_survival - CFG file to execute when game mode is survival - Default survival.cfg
gamemode_config_realism - CFG file to execute when game mode is realism. - Default realism.cfg
gamemode_config_scavenge - CFG file to execute when game mode is scavenge. - Default scavenge.cfg
gamemode_config_teamscavenge - CFG file to execute when game mode is teamscavenge. - Default teamscavenge.cfg

gamemode_config_coop_easy - CFG file to execute when game mode is coop and the difficulty is Easy. - Default: coop_easy.cfg
gamemode_config_coop_normal - CFG file to execute when game mode is coop and the difficulty is Normal. - Default: coop_normal.cfg
gamemode_config_coop_hard - CFG file to execute when game mode is coop and the difficulty is Advanced. - Default: coop_hard.cfg
gamemode_config_coop_impossible - CFG file to execute when game mode is coop and the difficulty is Expert. - Default: coop_impossible.cfg

The values are used by the plugin to call the exec console command: exec [value].

Thanks to DJ Tsunami for getting me started.
Attached Files
File Type: sp Get Plugin or Get Source (l4d_gamemode_scripts.sp - 9319 views - 7.4 KB)

Last edited by Thraka; 05-24-2011 at 15:35. Reason: Updated version.
Thraka is offline