allow to update teams when playing

This commit is contained in:
Beu 2023-12-02 18:13:23 +01:00
parent dac6f3916f
commit 1e017b925d
1 changed files with 29 additions and 0 deletions

View File

@ -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) {