Skip to content

Commit

Permalink
Fix server always restarting in TDM mode #30
Browse files Browse the repository at this point in the history
Fixed server always restarting in TDM mode, regardless of what was set in startup_server.cfg. This happens because the startup_server.cfg is being executed before AG CVars are even registered. Now we reload the .cfg to solve this.
  • Loading branch information
rtxa committed Sep 3, 2024
1 parent 4d31281 commit 15da00f
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions valve/addons/amxmodx/scripting/agmodx.sma
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,12 @@ public plugin_precache() {
gCvarMatchRunning = create_cvar("sv_ag_match_running", "0");
set_pcvar_string(gCvarMatchRunning, "0");

if (!IsPluginFirstLoad()) {
// startup_server.cfg is executed before AG CVars are registered, so we need to reload the .cfg to reflect changes.
LoadStartupServerCfg();
set_localinfo("ag_first_load", "1");
}

new fwPreConfig, fwPostConfig, fwReturnTemp;

fwPreConfig = CreateMultiForward("agmodx_pre_config", ET_IGNORE);
Expand Down Expand Up @@ -484,6 +490,23 @@ public plugin_init() {
BanGamemodeEnts();
}

bool:IsPluginFirstLoad() {
new isPluginFirstLoad[2];
get_localinfo("ag_first_load", isPluginFirstLoad, charsmax(isPluginFirstLoad));
return isPluginFirstLoad[0] ? true : false;
}

// TODO: allow to load startup_server.cfg from subfolders to match BHL behaviour
LoadStartupServerCfg() {
new serverCfg[256];
get_cvar_string("servercfgfile", serverCfg, charsmax(serverCfg));
if (!serverCfg[0]) {
return;
}
server_cmd("exec startup_%s", serverCfg); // no need to add .cfg at the end
server_exec();
}

public FwChargersUse() {
if (get_pcvar_bool(gCvarBanChargers))
return HAM_SUPERCEDE;
Expand Down

0 comments on commit 15da00f

Please sign in to comment.