1
0
Fork 0
mirror of https://codeberg.org/spire/autoexec.git synced 2026-08-02 20:24:46 +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

Binary file not shown.

View file

@ -17,7 +17,9 @@ new StringMap:mapTypeMap;
new StringMap:gameModeMap; new StringMap:gameModeMap;
new StringMap:configOverwriteMap; new StringMap:configOverwriteMap;
bool inAutoExec = false; 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:CvarLeague = INVALID_HANDLE;
new Handle:CvarMode = 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) { public void OnReadyUp(Event event, const String:name[], bool:dontBroadcast) {
bool redReady = GameRules_GetProp("m_bTeamReady", 1, .element = 2) != 0; bool redReady = IsReady(2);
bool blueReady = GameRules_GetProp("m_bTeamReady", 1, .element = 3) != 0; bool blueReady = IsReady(3);
CheckWhitelist(); CheckWhitelist();
@ -272,6 +274,7 @@ public void CheckPlayerCount(int team) {
PrintToChatAll("Switching config to %s", expectedMode); PrintToChatAll("Switching config to %s", expectedMode);
SetConVarString(CvarMode, expectedMode); SetConVarString(CvarMode, expectedMode);
ExecMapCfg(); ExecMapCfg();
CreateTimer(0.5, ReadyTeamTimer, team);
return; return;
} }
} }
@ -281,13 +284,29 @@ public void CheckPlayerCount(int team) {
warned[team] = true; warned[team] = true;
PrintToChatAll("Warning, config is set to %s but you readied up with %d players", gameMode, playerCount); 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 { } else {
warned[team] = true; 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() { public void CheckWhitelist() {
decl String:whitelist[128]; decl String:whitelist[128];
GetConVarString(CvarWhitelist, whitelist, sizeof(whitelist)); GetConVarString(CvarWhitelist, whitelist, sizeof(whitelist));