Detect when a player change from Player to Spectator
This commit is contained in:
		| @@ -380,9 +380,17 @@ foreach (Event in PendingEvents) { | |||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
| if (PlayersNbAlive <= 1 && AccountIdsOfPlayers.count >= 2) { //TODO just respawn in case of 1 player | // Detect when a players count changed without having triggered any of Event (when becoming spectator for example) | ||||||
| 	Net_TimeBeforeMalus = -1; | if (!ThrottleUpdate && Net_PlayersNbAlive != PlayersNbAlive) { | ||||||
| 	MB_StopRound(); | 	log("Trying to detect why the player count changed"); | ||||||
|  | 	foreach (Player in AllPlayers) { | ||||||
|  | 		if (Player.User == Null || Player.Score == Null) continue; | ||||||
|  | 		if (!AccountIdsOfPlayers.exists(Player.User.WebServicesUserId)) continue; | ||||||
|  | 		if (Player.SpawnStatus != CSmPlayer::ESpawnStatus::NotSpawned) continue; | ||||||
|  | 		if (IsEliminated(Player.User, Player.Score)) continue; | ||||||
|  | 		UpdateCustomRanking(Player.User, True); | ||||||
|  | 		ThrottleUpdate = True; | ||||||
|  | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
| if (ThrottleUpdate) { | if (ThrottleUpdate) { | ||||||
| @@ -397,6 +405,11 @@ if (ThrottleUpdate) { | |||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
|  | if (PlayersNbAlive <= 1 && AccountIdsOfPlayers.count >= 2) { //TODO just respawn in case of 1 player | ||||||
|  | 	Net_TimeBeforeMalus = -1; | ||||||
|  | 	MB_StopRound(); | ||||||
|  | } | ||||||
|  |  | ||||||
|  |  | ||||||
| // Update the map duration setting | // Update the map duration setting | ||||||
| if (Map_TimeBeforeMalus != S_TimeBeforeMalus || Map_TimeBeforeMalus != S_TimeBeforeNightmare || Map_MalusEveryNSecs != S_MalusEveryNSecs || Map_NextMalusPreparationTime != S_NextMalusPreparationTime || Map_MalusDuration != S_MalusDuration || Map_RoundsPerMap != S_RoundsPerMap) { | if (Map_TimeBeforeMalus != S_TimeBeforeMalus || Map_TimeBeforeMalus != S_TimeBeforeNightmare || Map_MalusEveryNSecs != S_MalusEveryNSecs || Map_NextMalusPreparationTime != S_NextMalusPreparationTime || Map_MalusDuration != S_MalusDuration || Map_RoundsPerMap != S_RoundsPerMap) { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user