From 405bd533f8c01f1dac6350f32e4a52eff78c588b Mon Sep 17 00:00:00 2001 From: Beu Date: Tue, 8 Mar 2022 17:38:33 +0100 Subject: [PATCH] Check if map is compatible to avoid script crash --- LastManStanding.Script.txt | 92 ++++++++++++++++++++++---------------- 1 file changed, 53 insertions(+), 39 deletions(-) diff --git a/LastManStanding.Script.txt b/LastManStanding.Script.txt index b33d932..03d7404 100644 --- a/LastManStanding.Script.txt +++ b/LastManStanding.Script.txt @@ -221,48 +221,62 @@ Net_CurrentRoundNb = Map_ValidRoundsNb + 1; declare Text[] AccountIdsOfPlayers for This = []; declare CMapLandmark[] Landmarks = Map::GetFinishesAndMultilaps(); -declare CMapLandmark PlayerLM; -declare Integer LandmarkIndex for This = 0; -AccountIdsOfPlayers = []; -// Suffle Players list to randomise spawn -declare CSmPlayer[] ShuffledPlayers = Players; -declare Integer i=0; -while(i Landmarks.count - 1 ) { - LandmarkIndex = 0; - } - if (Map::IsMultilap(Landmarks[LandmarkIndex])) { - PlayerLM = Landmarks[LandmarkIndex]; - } - LandmarkIndex = LandmarkIndex + 1 ; +declare Boolean MapIsCompatible; +foreach (Landmark in Landmarks) { + if (Map::IsMultilap(Landmark)) { + MapIsCompatible = True; + break; } - Race::Start(Player, PlayerLM , StartTime); - AccountIdsOfPlayers.add(Player.User.WebServicesUserId); } - -Net_NBPlayers = AccountIdsOfPlayers.count; - -UpdateCustomRanking(Null, -1); -StateMgr::ForcePlayersStates([StateMgr::C_State_Playing]); -CarRank::Update(CarRank::C_SortCriteria_BestRace); -Race::EnableIntroDuringMatch(False); -UIManager.UIAll.SendChat("$<$ff3$> Stay the most time on the structure. $<$ff9GL HF!$>"); +if (!MapIsCompatible) { + UIManager.UIAll.QueueMessage(3000, 1, CUIConfig::EMessageDisplay::Big, _("This map is not valid")); + MB_Sleep(3000); + MB_StopMap(); +} else { + declare CMapLandmark PlayerLM; + declare Integer LandmarkIndex for This = 0; + AccountIdsOfPlayers = []; + + // Suffle Players list to randomise spawn + declare CSmPlayer[] ShuffledPlayers = Players; + declare Integer i=0; + while(i Landmarks.count - 1 ) { + LandmarkIndex = 0; + } + if (Map::IsMultilap(Landmarks[LandmarkIndex])) { + PlayerLM = Landmarks[LandmarkIndex]; + } + LandmarkIndex = LandmarkIndex + 1 ; + } + Race::Start(Player, PlayerLM , StartTime); + AccountIdsOfPlayers.add(Player.User.WebServicesUserId); + } + + Net_NBPlayers = AccountIdsOfPlayers.count; + + UpdateCustomRanking(Null, -1); + StateMgr::ForcePlayersStates([StateMgr::C_State_Playing]); + CarRank::Update(CarRank::C_SortCriteria_BestRace); + Race::EnableIntroDuringMatch(False); + UIManager.UIAll.SendChat("$<$ff3$> Stay the most time on the structure. $<$ff9GL HF!$>"); +} *** ***Match_PlayLoop***