AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Plugins (https://forums.alliedmods.net/forumdisplay.php?f=108)
-   -   [L4D & L4D2] Map-based Configs (https://forums.alliedmods.net/showthread.php?t=306525)

Chi_Nai 04-04-2018 07:15

[L4D & L4D2] Map-based Configs
 
2 Attachment(s)
I am sorry, my english is poor

Individually set cvar and plug-in instructions for each level

Can add cvar and other plug-in instructions in cfg

Add custom maps to map_cvars

Convars Configs File:
\left4dead2\cfg

thank Crasher_3637

Provide me better code

Mi.Cura 04-04-2018 14:08

Re: [L4D2]Level Difficulty Edit
 
it would be better if it were cvar configurations for each type of difficulty:
( would suit any campaign, including custom )

easy (cfg) / normal (cfg)/ advanced (cfg)/ expert (cfg).

But for each MAP..., why?

Psyk0tik 04-04-2018 16:54

Re: [L4D2]Level Difficulty Edit
 
Why not just code it to where a config is executed based on the map name instead of hard-coding all the official maps?

PHP Code:

public void OnAutoConfigsBuffered()
{
    
char sMapConfig[128];
    
GetCurrentMap(sMapConfigsizeof(sMapConfig));
    
Format(sMapConfigsizeof(sMapConfig), "cfg/sourcemod/map_cvars/%s.cfg"sMapConfig);
    if (
FileExists(sMapConfigtrue))
    {
        
strcopy(sMapConfigsizeof(sMapConfig), sMapConfig[4]);
        
ServerCommand("exec \"%s\""sMapConfig);
    }


If you have a .cfg file in left4dead2/cfg/sourcemod/map_cvars called "c1m1_hotel.cfg" then that config will be executed when you switch to the c1m1_hotel map. It's a lot easier and shorter than what you have now, and it works with custom maps as well.

Chi_Nai 04-04-2018 20:55

Re: [L4D2]Level Difficulty Edit
 
Quote:

Originally Posted by Crasher_3637 (Post 2586070)
Why not just code it to where a config is executed based on the map name instead of hard-coding all the official maps?

PHP Code:

public void OnAutoConfigsBuffered()
{
    
char sMapConfig[128];
    
GetCurrentMap(sMapConfigsizeof(sMapConfig));
    
Format(sMapConfigsizeof(sMapConfig), "cfg/sourcemod/map_cvars/%s.cfg"sMapConfig);
    if (
FileExists(sMapConfigtrue))
    {
        
strcopy(sMapConfigsizeof(sMapConfig), sMapConfig[4]);
        
ServerCommand("exec \"%s\""sMapConfig);
    }


If you have a .cfg file in left4dead2/cfg/sourcemod/map_cvars called "c1m1_hotel.cfg" then that config will be executed when you switch to the c1m1_hotel map. It's a lot easier and shorter than what you have now, and it works with custom maps as well.


Thanks This is a very early completion of the plugin Can I borrow your code Modify this plugin?

Psyk0tik 04-04-2018 21:18

Re: [L4D2]Level Difficulty Edit
 
Quote:

Originally Posted by Chi_Nai (Post 2586090)
Thanks This is a very early completion of the plugin Can I borrow your code Modify this plugin?

Sure! :) That code is all you really need to let end-users create .cfg files for each map, including custom maps.

Psyk0tik 04-05-2018 02:44

Re: [L4D2]Level Difficulty Edit
 
4 Attachment(s)
I looked at the source code of the latest version of your plugin and decided to fix it up for you by adding information about the plugin. This is how it looks:

PHP Code:

#include <sourcemod>
#pragma semicolon 1
#pragma newdecls required

public Plugin myinfo =
{
    
name "[L4D & L4D2] Map-based Configs",
    
author "Chi_Nai",
    
version "1.2",
    
description "Allows for custom settings for each map.",
    
url "https://forums.alliedmods.net/showthread.php?t=306525"
};

public 
void OnAutoConfigsBuffered()
{
    
char sMapConfig[128];
    
GetCurrentMap(sMapConfigsizeof(sMapConfig));
    
Format(sMapConfigsizeof(sMapConfig), "cfg/sourcemod/map_cvars/%s.cfg"sMapConfig);
    if (
FileExists(sMapConfigtrue))
    {
        
strcopy(sMapConfigsizeof(sMapConfig), sMapConfig[4]);
        
ServerCommand("exec \"%s\""sMapConfig);
    }



Chi_Nai 04-05-2018 04:11

Re: [L4D2]Level Difficulty Edit
 
Quote:

Originally Posted by Crasher_3637 (Post 2586112)
I looked at the source code of the latest version of your plugin and decided to fix it up for you by adding information about the plugin. This is how it looks:

PHP Code:

#include <sourcemod>
#pragma semicolon 1
#pragma newdecls required

public Plugin myinfo =
{
    
name "[L4D & L4D2] Map-based Configs",
    
author "Chi_Nai",
    
version "1.2",
    
description "Allows for custom settings for each map.",
    
url "https://forums.alliedmods.net/showthread.php?t=306525"
};

public 
void OnAutoConfigsBuffered()
{
    
char sMapConfig[128];
    
GetCurrentMap(sMapConfigsizeof(sMapConfig));
    
Format(sMapConfigsizeof(sMapConfig), "cfg/sourcemod/map_cvars/%s.cfg"sMapConfig);
    if (
FileExists(sMapConfigtrue))
    {
        
strcopy(sMapConfigsizeof(sMapConfig), sMapConfig[4]);
        
ServerCommand("exec \"%s\""sMapConfig);
    }




Thank you for updating

Lux 04-05-2018 04:23

Re: [L4D & L4D2] Map-based Configs
 
This already exists here https://forums.alliedmods.net/showthread.php?p=760501

however you could tailor it to l4d only with configs on special infected speed, health, bla bla lots of stuff :D

phoenix0001 04-05-2018 18:02

Re: [L4D & L4D2] Map-based Configs
 
How to disable a plugin?
E.g:
Plugin name aaa.smx
Enable aaa.smx in C1M1, C1M2, C1M4
Disabling aaa.smx in C1M3

Chi_Nai 04-05-2018 19:11

Re: [L4D & L4D2] Map-based Configs
 
Quote:

Originally Posted by phoenix0001 (Post 2586248)
How to disable a plugin?
E.g:
Plugin name aaa.smx
Enable aaa.smx in C1M1, C1M2, C1M4
Disabling aaa.smx in C1M3

刪除C1M3.cfg 或是cfg裡不填入任何指令


All times are GMT -4. The time now is 18:02.

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