Raised This Month: $12 Target: $400
 3% 

[L4D & L4D2] Game Mode Config Loader 1.6


Post New Thread Reply   
 
Thread Tools Display Modes
zero4u
Junior Member
Join Date: Jul 2005
Old 05-30-2009 , 05:50   Re: [L4D] Game Mode Config Loader
Reply With Quote #11

Quote:
Originally Posted by Thraka View Post
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
zero4u is offline
DJ Tsunami
DJ Post Spammer
Join Date: Feb 2008
Location: The Netherlands
Old 05-30-2009 , 08:34   Re: [L4D] Game Mode Config Loader
Reply With Quote #12

The motdfile cvar specified which file to use as MOTD, you can change that cvar with this plugin.
__________________
Advertisements | REST in Pawn - HTTP client for JSON REST APIs
Please do not PM me with questions. Post in the plugin thread.
DJ Tsunami is offline
Thraka
AlliedModders Donor
Join Date: Aug 2005
Old 06-01-2009 , 12:50   Re: [L4D] Game Mode Config Loader
Reply With Quote #13

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.
Thraka is offline
Dionys
Senior Member
Join Date: Sep 2008
Location: Terra, Russia
Old 06-04-2009 , 06:45   Re: [L4D] Game Mode Config Loader
Reply With Quote #14

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);
}
...

Last edited by Dionys; 06-11-2009 at 05:55.
Dionys is offline
Thraka
AlliedModders Donor
Join Date: Aug 2005
Old 06-10-2009 , 12:54   Re: [L4D] Game Mode Config Loader
Reply With Quote #15

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.
Thraka is offline
ColdnessCalms
Junior Member
Join Date: Jun 2009
Location: Seattle
Old 06-10-2009 , 17:38   Re: [L4D] Game Mode Config Loader
Reply With Quote #16

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 :/

Last edited by ColdnessCalms; 06-10-2009 at 21:50.
ColdnessCalms is offline
Dionys
Senior Member
Join Date: Sep 2008
Location: Terra, Russia
Old 06-11-2009 , 04:16   Re: [L4D] Game Mode Config Loader
Reply With Quote #17

Quote:
Originally Posted by Thraka View Post
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)

Last edited by Dionys; 06-11-2009 at 06:01.
Dionys is offline
Thraka
AlliedModders Donor
Join Date: Aug 2005
Old 06-11-2009 , 13:04   Re: [L4D] Game Mode Config Loader
Reply With Quote #18

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.
Thraka is offline
Dionys
Senior Member
Join Date: Sep 2008
Location: Terra, Russia
Old 06-11-2009 , 14:45   Re: [L4D] Game Mode Config Loader
Reply With Quote #19

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
Dionys is offline
froggz19
Junior Member
Join Date: Oct 2006
Old 06-15-2009 , 07:16   Re: [L4D] Game Mode Config Loader
Reply With Quote #20

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?
froggz19 is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 16:55.


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