From f5499b972d7522dd0f4086e34f04aed8f19e7053 Mon Sep 17 00:00:00 2001 From: JensForstmann Date: Sat, 12 Oct 2024 11:24:26 +0200 Subject: [PATCH] Don't write error message in chat if players try to join the team they are force into --- backend/src/match.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/backend/src/match.ts b/backend/src/match.ts index 203271b..e9cdaf3 100644 --- a/backend/src/match.ts +++ b/backend/src/match.ts @@ -834,11 +834,13 @@ export const sayWhatTeamToJoin = async (match: Match) => { const onTeamCommand: commands.CommandHandler = async ({ match, player, parameters }) => { const firstParameter = parameters[0]?.toUpperCase(); if (firstParameter === 'A' || firstParameter === 'B') { - if (Player.getForcedTeam(match, player.steamId64)) { + const forcedTeam = Player.getForcedTeam(match, player.steamId64); + const wantedTeam: TTeamAB = firstParameter === 'A' ? 'TEAM_A' : 'TEAM_B'; + if (forcedTeam && forcedTeam !== wantedTeam) { await say(match, `PLAYER ${escapeRconString(player.name)} CANNOT CHANGE THEIR TEAM`); return; } - player.team = firstParameter === 'A' ? 'TEAM_A' : 'TEAM_B'; + player.team = wantedTeam; MatchService.scheduleSave(match); const team = getTeamByAB(match, player.team); await say(