1
0
Fork 0
mirror of https://codeberg.org/spire/autoexec.git synced 2026-08-02 12:14:52 +02:00

re-ready after auto switching config

This commit is contained in:
Robin Appelman 2026-07-23 22:36:01 +02:00
commit 35cdf93fa2
2 changed files with 23 additions and 4 deletions

View file

@ -17,7 +17,9 @@ new StringMap:mapTypeMap;
new StringMap:gameModeMap;
new StringMap:configOverwriteMap;
bool inAutoExec = false;
bool warned[4] = {false, false, false, false}; // size 4 so we can use team indexes
// size 4 so we can use team indexes
bool warned[4] = {false, false, false, false};
new Handle:CvarLeague = INVALID_HANDLE;
new Handle:CvarMode = INVALID_HANDLE;
@ -238,8 +240,8 @@ public Action clearInAutoExec(Handle timer) {
}
public void OnReadyUp(Event event, const String:name[], bool:dontBroadcast) {
bool redReady = GameRules_GetProp("m_bTeamReady", 1, .element = 2) != 0;
bool blueReady = GameRules_GetProp("m_bTeamReady", 1, .element = 3) != 0;
bool redReady = IsReady(2);
bool blueReady = IsReady(3);
CheckWhitelist();
@ -272,6 +274,7 @@ public void CheckPlayerCount(int team) {
PrintToChatAll("Switching config to %s", expectedMode);
SetConVarString(CvarMode, expectedMode);
ExecMapCfg();
CreateTimer(0.5, ReadyTeamTimer, team);
return;
}
}
@ -281,13 +284,29 @@ public void CheckPlayerCount(int team) {
warned[team] = true;
PrintToChatAll("Warning, config is set to %s but you readied up with %d players", gameMode, playerCount);
GameRules_SetProp("m_bTeamReady", 0, _ , team, true);
UnReadyTeam(team);
} else {
warned[team] = true;
}
}
}
public bool IsReady(int team) {
return GameRules_GetProp("m_bTeamReady", 1, .element = team) != 0;
}
public void ReadyTeamTimer(Handle _timer, int team) {
ReadyTeam(team);
}
public void ReadyTeam(int team) {
GameRules_SetProp("m_bTeamReady", 1, _ , team, true);
}
public void UnReadyTeam(int team) {
GameRules_SetProp("m_bTeamReady", 0, _ , team, true);
}
public void CheckWhitelist() {
decl String:whitelist[128];
GetConVarString(CvarWhitelist, whitelist, sizeof(whitelist));