diff --git a/plugin/autoexec.smx b/plugin/autoexec.smx index be2c161..df92512 100644 Binary files a/plugin/autoexec.smx and b/plugin/autoexec.smx differ diff --git a/plugin/autoexec.sp b/plugin/autoexec.sp index a75a578..693ced8 100644 --- a/plugin/autoexec.sp +++ b/plugin/autoexec.sp @@ -122,6 +122,11 @@ public Action:HandleExecAction(args) { SetConVarString(CvarMode, "4v4"); } + if (StrContains(cfg, "ultiduo") > 0) { + PrintToChatAll("Setting game mode to 2v2"); + SetConVarString(CvarMode, "2v2"); + } + return Plugin_Continue; } @@ -233,8 +238,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 = GameRules_GetProp("m_bTeamReady", 1, .element = 2) != 0; + bool blueReady = GameRules_GetProp("m_bTeamReady", 1, .element = 3) != 0; CheckWhitelist(); @@ -248,19 +253,35 @@ public void OnReadyUp(Event event, const String:name[], bool:dontBroadcast) { public void CheckPlayerCount(int team) { int playerCount = GetTeamClientCount(team); + int otherPlayerCount = GetTeamClientCount(OtherTeam(team)); + decl String:gameMode[8]; + GetConVarString(CvarMode, gameMode, sizeof(gameMode)); - decl String:gamemode[8]; - GetConVarString(CvarMode, gamemode, sizeof(gamemode)); + int expected = ExpectedPlayerCount(gameMode); + + if (playerCount != expected) { + decl String:expectedMode[8]; + decl String:expectedModeOther[8]; + + ExpectedGameMode(playerCount, expectedMode); + ExpectedGameMode(otherPlayerCount, expectedModeOther); + + bool gotExpectedMode = !(strncmp("unknown", expectedMode, sizeof(expectedMode)) == 0); + + if (gotExpectedMode && strncmp(expectedMode, expectedModeOther, strlen(expectedMode)) == 0) { + PrintToChatAll("Switching config to %s", expectedMode); + SetConVarString(CvarMode, expectedMode); + ExecMapCfg(); + return; + } + } + + if (expected != 0 && !warned[team]) { + if (playerCount != expected) { - if (!warned[team]) { - if (strcmp(gamemode, "9v9") == 0 && playerCount != 9) { warned[team] = true; - PrintToChatAll("Warning, config is set to 9v9 but you readied up with %d players", playerCount); + PrintToChatAll("Warning, config is set to %s but you readied up with %d players", gameMode, playerCount); GameRules_SetProp("m_bTeamReady", 0, _ , team, true); - } else if (strcmp(gamemode, "6v6") == 0 && playerCount != 6) { - warned[team] = true; - GameRules_SetProp("m_bTeamReady", 0, _ , team, true); - PrintToChatAll("Warning, config is set to 6v6 but you readied up with %d players", playerCount); } else { warned[team] = true; } @@ -287,14 +308,50 @@ public GetExpectedWhitelist(String:whitelist[128]) { if (strncmp("ugc", league, strlen(league)) == 0) { if (strncmp("9v9", gamemode, strlen(gamemode)) == 0) { whitelist = "cfg/item_whitelist_ugc_HL.txt"; - } else if (strncmp("6v6", gamemode, strlen(gamemode)) == 0) { { + } else if (strncmp("6v6", gamemode, strlen(gamemode)) == 0) { whitelist = "cfg/item_whitelist_ugc_6v6.txt"; } } else if (strncmp("etf2l", league, strlen(league)) == 0) { if (strncmp("9v9", gamemode, strlen(gamemode)) == 0) { whitelist = "cfg/etf2l_whitelist_9v9.txt"; - } else if (strncmp("6v6", gamemode, strlen(gamemode)) == 0) { { + } else if (strncmp("6v6", gamemode, strlen(gamemode)) == 0) { whitelist = "cfg/etf2l_whitelist_6v6.txt"; } } } + +public int OtherTeam(int team) { + if (team == 2) { + return 3; + } else { + return 2; + } +} + +public int ExpectedPlayerCount(String:gamemode[8]) { + if (strcmp(gamemode, "9v9") == 0) { + return 9; + } else if (strcmp(gamemode, "6v6") == 0) { + return 6; + } else if (strcmp(gamemode, "4v4") == 0) { + return 4; + } else if (strcmp(gamemode, "2v2") == 0) { + return 2; + } else { + return 0; + } +} + +public void ExpectedGameMode(int count, String:mode[8]) { + if (count == 9 || count == 8) { + mode = "9v9"; + } else if (count == 5 || count == 6) { + mode = "6v6"; + } else if (count == 3 || count == 4) { + mode = "4v4"; + } else if (count == 2) { + mode = "2v2"; + } else { + mode = "unknown"; + } +}