private void SendOverheatedMessageToPlayer(string message, string color, int warningLevel) { try { foreach (var item in Core.Instance.playerWeaponWarningLevels[m_cubeBlock.CubeGrid.EntityId].blockWarnings.ToList()) { if (item.Key != m_cubeBlock.EntityId && warningLevel <= item.Value) { return; } } MyAPIGateway.Utilities.InvokeOnGameThread(() => Core.Instance.playerWeaponWarningLevels[m_cubeBlock.CubeGrid.EntityId].blockWarnings[m_cubeBlock.EntityId] = warningLevel); var players = new List <IMyPlayer>(); MyAPIGateway.Players.GetPlayers(players, x => x != null && x.Controller != null && x.Controller.ControlledEntity != null && x.Client != null && Debug.Write("Found a valid, online player", 2, debug)); foreach (var player in players) { var playerEntity = player.Controller.ControlledEntity.Entity; IMyShipController SC; if (Debug.Write($"playerEntity == null ? {playerEntity == null}", 2, debug) && playerEntity != null && playerEntity.IsOfType(out SC) && SC.CubeGrid == m_cubeBlock.CubeGrid) { MyAPIGateway.Utilities.InvokeOnGameThread(() => { try { if (Debug.Write($"player == null ? {player == null}", 2, debug) && player != null) { /* WORK ON THIS ADD CUSTOM GUI PLEASE * if (!Core.Instance.LastWeaponHeatNoteSentToPlayer.ContainsKey(player.IdentityId)) * Core.Instance.LastWeaponHeatNoteSentToPlayer.Add(player.IdentityId, MyVisualScriptLogicProvider.AddNotification(message, color, player.IdentityId)); * else * { * MyVisualScriptLogicProvider.RemoveNotification(Core.Instance.LastWeaponHeatNoteSentToPlayer[player.IdentityId], player.IdentityId); * Core.Instance.LastWeaponHeatNoteSentToPlayer[player.IdentityId] = MyVisualScriptLogicProvider.AddNotification(message, color, player.IdentityId); * } * * if (!Core.Instance.TimeWeaponNoteWasSentToPlayer.ContainsKey(player.IdentityId)) * Core.Instance.TimeWeaponNoteWasSentToPlayer.Add(player.IdentityId, Core.Instance.Timer); * else Core.Instance.TimeWeaponNoteWasSentToPlayer[player.IdentityId] = Core.Instance.Timer; */ MyVisualScriptLogicProvider.ClearNotifications(player.IdentityId); MyVisualScriptLogicProvider.ShowNotification(message, 3000, color, player.IdentityId); } // TO DO: play some audio // make sure the audio is on a cooldown so we dont get spam } catch (Exception e) { Debug.HandleException(e); } }); } } } catch (Exception e) { Debug.HandleException(e); } }