AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Plugins (https://forums.alliedmods.net/forumdisplay.php?f=108)
-   -   [L4D & L4D2] Game Mode Config Loader 1.6 (https://forums.alliedmods.net/showthread.php?t=93212)

zero4u 05-30-2009 05:50

Re: [L4D] Game Mode Config Loader
 
Quote:

Originally Posted by Thraka (Post 836285)
:( It seems the server is caching the motd content for the clients. So if you change motdfile after server has started and someone has connected, it doesn't seem to load the new page content :(

I think u wanna change motd on every config switch ?..
This plugin enables u to load different configs but motd and host file changes arent a part of it me gueses

DJ Tsunami 05-30-2009 08:34

Re: [L4D] Game Mode Config Loader
 
The motdfile cvar specified which file to use as MOTD, you can change that cvar with this plugin.

Thraka 06-01-2009 12:50

Re: [L4D] Game Mode Config Loader
 
yeah, you can change the var with those configs loaded by the plugin. I think that the server reads the MOTD at map change, and since this fires at map start, it doesn't respect the change.

Dionys 06-04-2009 06:45

Re: [L4D] Game Mode Config Loader
 
good addition to the plugin - to add hook event convar change mp_gamemode and z_difficulty
for example:
Code:

public OnPluginStart()
{
    decl String:ModName[50];
    GetGameFolderName(ModName, sizeof(ModName));
    if (!StrEqual(ModName, "left4dead", false))
    {
        SetFailState("Use this Left 4 Dead only.");
    }

    g_hGameMode = FindConVar("mp_gamemode");        //coop, versus, survival
    g_hDifficulty = FindConVar("z_difficulty");        //Easy, Normal, Hard, Impossible
   
    g_hConVar_ConfigCoop_Easy = CreateConVar("l4d_autoexec_coop_easy", "coop_easy.cfg", "CFG file to execute when game mode is coop and the difficulty is Easy.", CVAR_FLAGS);
    g_hConVar_ConfigCoop_Normal = CreateConVar("l4d_autoexeccoop_normal", "coop_normal.cfg", "CFG file to execute when game mode is coop and the difficulty is Normal.", CVAR_FLAGS);
    g_hConVar_ConfigCoop_Hard = CreateConVar("l4d_autoexec_coop_hard", "coop_hard.cfg", "CFG file to execute when game mode is coop and the difficulty is Advanced.", CVAR_FLAGS);
    g_hConVar_ConfigCoop_Impossible = CreateConVar("l4d_autoexec_coop_impossible", "coop_impossible.cfg", "CFG file to execute when game mode is coop and the difficulty is Expert.", CVAR_FLAGS);
    g_hConVar_ConfigVersus = CreateConVar("l4d_autoexec_versus", "versus.cfg", "CFG file to execute when game mode is versus.", CVAR_FLAGS);
    g_hConVar_ConfigSurvival = CreateConVar("l4d_autoexec_survival", "survival.cfg", "CFG file to execute when game mode is survival.", CVAR_FLAGS);
   
    HookConVarChange(g_hGameMode, ConVarChange_GameMode);
    HookConVarChange(g_hDifficulty, ConVarChange_Difficulty);
}

public OnMapStart()
{
    AutoexecCFG();
}

public ConVarChange_GameMode(Handle:convar, const String:oldValue[], const String:newValue[])
{
    if (strcmp(oldValue, newValue) != 0)
    {
        AutoexecCFG();
    }
}

public ConVarChange_Difficulty(Handle:convar, const String:oldValue[], const String:newValue[])
{
    if (strcmp(oldValue, newValue) != 0)
    {
        AutoexecCFG();
    }
}

AutoexecCFG()
{
    decl String:sGameMode[32];
    decl String:sGameDifficulty[32];
    decl String:sConfigName[256];
   
    GetConVarString(g_hGameMode, sGameMode, sizeof(sGameMode));
    GetConVarString(g_hDifficulty, sGameDifficulty, sizeof(sGameDifficulty));

    if (StrEqual(sGameMode, "coop", false))
    {
        if (StrEqual(sGameDifficulty, "Easy", false))
        {
            GetConVarString(g_hConVar_ConfigCoop_Easy, sConfigName, sizeof(sConfigName));
            TrimString(sConfigName);
            ServerCommand("exec %s", sConfigName);
        }
        else if (StrEqual(sGameDifficulty, "Normal", false))
        {
            GetConVarString(g_hConVar_ConfigCoop_Normal, sConfigName, sizeof(sConfigName));
            TrimString(sConfigName);
            ServerCommand("exec %s", sConfigName);
        }
        else if (StrEqual(sGameDifficulty, "Hard", false))
        {
            GetConVarString(g_hConVar_ConfigCoop_Hard, sConfigName, sizeof(sConfigName));
            TrimString(sConfigName);
            ServerCommand("exec %s", sConfigName);
        }
        else if (StrEqual(sGameDifficulty, "Impossible", false))
        {
            GetConVarString(g_hConVar_ConfigCoop_Impossible, sConfigName, sizeof(sConfigName));
            TrimString(sConfigName);
            ServerCommand("exec %s", sConfigName);
        }
    }
    else if (StrEqual(sGameMode, "survival", false))
    {
        GetConVarString(g_hConVar_ConfigSurvival, sConfigName, sizeof(sConfigName));
        TrimString(sConfigName);
        ServerCommand("exec %s", sConfigName);
    }
    else if (StrEqual(sGameMode, "versus", false))
    {
        GetConVarString(g_hConVar_ConfigVersus, sConfigName, sizeof(sConfigName));
        TrimString(sConfigName);
        ServerCommand("exec %s", sConfigName);
    }
}

so need add check FileExists(ConfigFile):
for example:
Code:

...
new String:ConfigFile[PLATFORM_MAX_PATH];
...
FormatEx(ConfigFile, sizeof(ConfigFile), "cfg\\%s", sConfigName);
if(FileExists(ConfigFile))
{
      PrintToServer("[SM] Execute %s file", sConfigName);
      ServerCommand("exec %s", sConfigName);
}
...


Thraka 06-10-2009 12:54

Re: [L4D] Game Mode Config Loader
 
Are you sure the game respects the convar changes? I've changed the game type from coop to versus before, and it doesn't let infected players spawn. I think you need to start on the level with those settings, which is what the lobby system is for. I'll add this into my script if you can verify that when you change difficulty from easy to expert mid-level, it will work. For example, on expert, the regular zombies only need to hit you four times to take you down.

ColdnessCalms 06-10-2009 17:38

Re: [L4D] Game Mode Config Loader
 
Thanks so much for this plugin, it was exactly what I was looking for :)
couple questions though...

first, can I set a folder? for example:
gamemode_config_coop sourcemod/coop.cfg

and second, do you know when the file is executed? Specifically, after server.cfg?

I have the contents of warmode_on in my versus.cfg and off are in both coop and survival. could this possibly cause any problems? Warmode turns on and off all plugins, which could obviously cause some problems :/

Dionys 06-11-2009 04:16

Re: [L4D] Game Mode Config Loader
 
Quote:

Originally Posted by Thraka (Post 845694)
Are you sure the game respects the convar changes? I've changed the game type from coop to versus before, and it doesn't let infected players spawn. I think you need to start on the level with those settings, which is what the lobby system is for. I'll add this into my script if you can verify that when you change difficulty from easy to expert mid-level, it will work. For example, on expert, the regular zombies only need to hit you four times to take you down.

Of course I am sure.
Strange that you have a this question :)

Such difficulty can change at the voting of players and more than once for the map!
Then from the plug-in your version there is no sense, because it will check the difficulty only when loading the next map.

2ColdnessCalms
path for config file - %gamepath%\cfg
config file is executed at map start (in Thraka version)
or
at map start and at convar mp_gamemode or z_difficulty change event (in my version)

Thraka 06-11-2009 13:04

Re: [L4D] Game Mode Config Loader
 
I'll work on migrating your changes into the release Dionys.

Coldness, specifically I didn't configure it to execute a path for scripts. It's really just calling the console command exec directly. So wherever the Source engine and L4D specficially are going to look for files to execute when you call "exec" normally, is where your scripts need to be.

Dionys 06-11-2009 14:45

Re: [L4D] Game Mode Config Loader
 
hmm

FileExists(sConfigName) always will be false
need
FormatEx(ConfigFile, sizeof(ConfigFile), "cfg\\%s", sConfigName);
FileExists(ConfigFile)

I think there is no point to argue :)
I showed variant which have long been working on my server

froggz19 06-15-2009 07:16

Re: [L4D] Game Mode Config Loader
 
must add

gamemode_config_coop "coop.cfg"
gamemode_config_versus "versus.cfg"
gamemode_config_survival "survival.cfg"

in server.cfg?

and create 3 cfg's with coop versus survival?


All times are GMT -4. The time now is 13:44.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.