Skip to content

Commit

Permalink
Remember to reload teams if not changing map
Browse files Browse the repository at this point in the history
  • Loading branch information
nickdnk committed Mar 20, 2023
1 parent 6640d4f commit ad91f27
Showing 1 changed file with 25 additions and 22 deletions.
47 changes: 25 additions & 22 deletions scripting/get5/matchconfig.sp
Original file line number Diff line number Diff line change
Expand Up @@ -169,35 +169,38 @@ bool LoadMatchConfig(const char[] config, char[] error, bool restoreBackup = fal
// If we do the veto, game mode and map change is done post-veto instead.
SetCorrectGameMode();
ChangeMap(mapName);
} else {
CheckTeamsPostMatchConfigLoad();
}
} else if (g_CheckAuthsCvar.BoolValue) {
// ExecuteMatchConfigCvars must be executed before we place players, as it might have
// get5_check_auths 1. We must also have called SetStartingTeams to get the sides right. When
// restoring from backup, assigning to teams is done after loading the match config as it
// depends on the sides being set correctly by the backup, so we put it inside this "if" here.
// When the match is loaded, we do not want to assign players on no team, as they may be in the
// process of joining the server, which is the reason for the timer callback. This has caused
// problems with players getting stuck on no team when using match config autoload, essentially
// recreating the "coaching bug". Adding a few seconds seems to solve this problem. We cannot just
// skip team none, as players may also just be on the team selection menu when the match is
// loaded, meaning they will never have a joingame hook, as it already happened, and we still
// want those players placed.
// Move players to their right teams during veto.
LOOP_CLIENTS(i) {
if (IsPlayer(i)) {
if (GetClientTeam(i) == CS_TEAM_NONE) {
CreateTimer(2.0, Timer_PlacePlayerFromTeamNone, i, TIMER_FLAG_NO_MAPCHANGE);
} else {
CheckClientTeam(i);
}
}
}
} else {
CheckTeamsPostMatchConfigLoad();
}
}
strcopy(g_LoadedConfigFile, sizeof(g_LoadedConfigFile), config);
return true;
}

static void CheckTeamsPostMatchConfigLoad() {
if (!g_CheckAuthsCvar.BoolValue) {
return;
}
// When the match is loaded, we do not want to assign players on no team, as they may be in the
// process of joining the server, which is the reason for the timer callback. This has caused
// problems with players getting stuck on no team when using match config autoload, essentially
// recreating the "coaching bug". Adding a few seconds seems to solve this problem. We cannot just
// skip team none, as players may also just be on the team selection menu when the match is
// loaded, meaning they will never have a joingame hook, as it already happened, and we still
// want those players placed.
LOOP_CLIENTS(i) {
if (IsPlayer(i)) {
if (GetClientTeam(i) == CS_TEAM_NONE) {
CreateTimer(2.0, Timer_PlacePlayerFromTeamNone, i, TIMER_FLAG_NO_MAPCHANGE);
} else {
CheckClientTeam(i);
}
}
}
}
static Action Timer_PlacePlayerFromTeamNone(Handle timer, int client) {
if (g_GameState != Get5State_None && IsPlayer(client)) {
CheckClientTeam(client);
Expand Down

0 comments on commit ad91f27

Please sign in to comment.