Skip to content

Commit c6d8081

Browse files
committedMar 9, 2024
2024-3-9 update
gamemode-based_configs v1.1
1 parent 35b30b0 commit c6d8081

File tree

3 files changed

+32
-4
lines changed

3 files changed

+32
-4
lines changed
 
Binary file not shown.

‎gamemode-based_configs/addons/sourcemod/scripting/gamemode-based_configs.sp

+27-2
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,18 @@ public Plugin myinfo =
66
{
77
name = "[L4D & L4D2] Gamemode-based configs",
88
author = "HarryPotter",
9-
version = "1.0",
9+
version = "1.1-2024/3/9",
1010
description = "Allows for custom settings for each gamemode and mutatuion.",
1111
url = "https://steamcommunity.com/profiles/76561198026784913/"
1212
};
1313

14+
bool bLate;
15+
public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
16+
{
17+
bLate = late;
18+
return APLRes_Success;
19+
}
20+
1421
ConVar g_hCvarMPGameMode;
1522
char g_sCvarMPGameMode[32];
1623

@@ -19,6 +26,11 @@ public void OnPluginStart()
1926
g_hCvarMPGameMode = FindConVar("mp_gamemode");
2027
g_hCvarMPGameMode.GetString(g_sCvarMPGameMode, sizeof(g_sCvarMPGameMode));
2128
g_hCvarMPGameMode.AddChangeHook(ConVarGameMode);
29+
30+
if(bLate)
31+
{
32+
ExecuteGamemodeCfg();
33+
}
2234
}
2335

2436
void ConVarGameMode(ConVar convar, const char[] oldValue, const char[] newValue)
@@ -32,7 +44,20 @@ void ConVarGameMode(ConVar convar, const char[] oldValue, const char[] newValue)
3244
ExecuteGamemodeCfg();
3345
}
3446

35-
public void OnConfigsExecuted() //execute on late load
47+
/**
48+
* This is called once, right after OnMapStart() but any time before
49+
* OnConfigsExecuted(). It is called after the "exec sourcemod.cfg"
50+
* command and all AutoExecConfig() exec commands have been added to
51+
* the ServerCommand() buffer.
52+
*
53+
* If you need to load per-map settings that override default values,
54+
* adding commands to the ServerCommand() buffer here will guarantee
55+
* that they're set before OnConfigsExecuted().
56+
*
57+
* Unlike OnMapStart() and OnConfigsExecuted(), this is not called on
58+
* late loads that occur after OnMapStart().
59+
*/
60+
public void OnAutoConfigsBuffered()
3661
{
3762
g_hCvarMPGameMode.GetString(g_sCvarMPGameMode, sizeof(g_sCvarMPGameMode));
3863
ExecuteGamemodeCfg();

‎gamemode-based_configs/readme.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Allows for custom settings for each gamemode and mutatuion.
1212
* Execute different cfg file based on gamemode or mutatuion when
1313
* Map change
1414
* Gamemode/Mutation change
15-
* It is called after the "exec sourcemod.cfg" command and after all AutoExecConfig() exec commands have been executed.
15+
* This is called right after OnMapStart() but any time before OnConfigsExecuted(). After the "exec sourcemod.cfg"command and all AutoExecConfig() exec commands have been added to the ServerCommand() buffer.
1616
* Cfg files are in ```cfg\sourcemod\gamemode_cvars\xxxxx.cfg```
1717
* xxxxx is gamemode or mutation name
1818
* [L4D2 all mutations](https://developer.valvesoftware.com/wiki/L4D2_Decrypted_mutations)
@@ -45,6 +45,9 @@ Allows for custom settings for each gamemode and mutatuion.
4545

4646
* <details><summary>Changelog | 版本日誌</summary>
4747

48+
* v1.1 (2024-3-9)
49+
* Initial Release
50+
4851
* v1.0 (2023-8-25)
4952
* Initial Release
5053
</details>
@@ -57,7 +60,7 @@ Allows for custom settings for each gamemode and mutatuion.
5760
* 根據當前的遊戲模式或突變模式執行不同的cfg文件,執行時間點為
5861
* 地圖載入時
5962
* 遊戲模式/突變模式改變時
60-
* Server.cfg 和 sourcemod.cfg 以及所有插件產生的cfg 執行之後
63+
* Server.cfg 和 sourcemod.cfg 以及所有插件產生的cfg 執行之後,```OnConfigsExecuted()``` 之前
6164
* cfg文件位於```cfg\sourcemod\gamemode_cvars\xxxxx.cfg```
6265
* xxxxx 是遊戲模式名稱或突變模式名稱
6366
* [L4D2 突變模式列表](https://developer.valvesoftware.com/wiki/L4D2_Decrypted_mutations)

0 commit comments

Comments
 (0)
Please sign in to comment.