From 1e017b925dd4a3a6f140268bdf928729b2b5b629 Mon Sep 17 00:00:00 2001 From: Beu Date: Sat, 2 Dec 2023 18:13:23 +0100 Subject: [PATCH] allow to update teams when playing --- TM_WaitYourMate.Script.txt | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/TM_WaitYourMate.Script.txt b/TM_WaitYourMate.Script.txt index 5a19c69..191b835 100644 --- a/TM_WaitYourMate.Script.txt +++ b/TM_WaitYourMate.Script.txt @@ -47,10 +47,12 @@ foreach (Player in AllPlayers) { } declare Text[] Map_LoginsToRespawn; +declare Text Map_TeamsConfig; *** ***Match_StartMap*** *** +Map_TeamsConfig = S_TeamsConfig; if (S_TeamsConfig != "") { declare Integer[Text] TeamsConfig ; TeamsConfig.fromjson(S_TeamsConfig); @@ -117,6 +119,33 @@ foreach (LoginToRespawn in Map_LoginsToRespawn) { RespawnPlayer(Player); } } + +if (Map_TeamsConfig != S_TeamsConfig) { + Map_TeamsConfig = S_TeamsConfig; + + if (S_TeamsConfig != "") { + declare Integer[Text] TeamsConfig ; + TeamsConfig.fromjson(S_TeamsConfig); + + foreach (Player in AllPlayers) { + declare Integer ClanId = TeamsConfig.get(Player.User.WebServicesUserId, 0); + Player.Score.LadderClan = ClanId; + + if (Player.SpawnStatus == CSmPlayer::ESpawnStatus::NotSpawned) { + log("Attributing Player "^ Player.User.Name ^" to the clan " ^ ClanId); + SetPlayerClan(Player, ClanId); + } else { + log("Can't apply Player "^ Player.User.Name ^" to the clan " ^ ClanId ^ " because they is playing"); + } + + UpdateClanStates(Player.Score.LadderClan); + + declare CUIConfig UI <=> UIManager.GetUI(Player); + if (UI == Null) continue; + UI.SendChat("$ff3You play for the team $fff"^ ClanId); + } + } +} *** Void ApplyModeToPlayer(CSmPlayer _Player, Boolean _Lock) {