diff --git a/DeltaVFactionQuestLog/Data/Scripts/DeltaVQuestLog/QuestLogManager.cs b/DeltaVFactionQuestLog/Data/Scripts/DeltaVQuestLog/QuestLogManager.cs index 87eca7d..9b45d0f 100644 --- a/DeltaVFactionQuestLog/Data/Scripts/DeltaVQuestLog/QuestLogManager.cs +++ b/DeltaVFactionQuestLog/Data/Scripts/DeltaVQuestLog/QuestLogManager.cs @@ -17,7 +17,7 @@ public class QuestLogManager [ProtoMember(1)] public List Objectives = new List(); [ProtoMember(2)] public Dictionary TemporaryObjectives = new Dictionary(); [ProtoMember(3)] public long FactionId { get; private set; } - [ProtoMember(4)] public DateTime? ForceShowTime; // TODO + [ProtoMember(4)] public DateTime? ForceShowTime; /// /// All playerIds with notifications off. /// @@ -53,10 +53,10 @@ public void Update10() if (ForceShowTime != null) { if (ForceShowTime.Value > DateTime.UtcNow) - UpdateFactionQuestlog($"Faction Objectives [Force-Enabled for {(ForceShowTime.Value - DateTime.UtcNow).TotalSeconds:N0}s]", true); + UpdateFactionQuestlog($"Faction Objectives [Force-Enabled for {(ForceShowTime.Value - DateTime.UtcNow).TotalSeconds:N0}s]", true, true); else { - UpdateFactionQuestlog(); + UpdateFactionQuestlog(isNetworkUpdate: !MyAPIGateway.Session.IsServer); ForceShowTime = null; } } @@ -131,7 +131,8 @@ public void UpdateFactionQuestlog(string title = "Faction Objectives", bool forc if (MyAPIGateway.Session.IsServer) { foreach (var player in Players) - UpdatePlayerQuestlog(title, player, forceVisible); + if (player != -1) + UpdatePlayerQuestlog(title, player, forceVisible); } if (!isNetworkUpdate) diff --git a/DeltaVFactionQuestLog/Data/Scripts/DeltaVQuestLog/QuestLogNetworking.cs b/DeltaVFactionQuestLog/Data/Scripts/DeltaVQuestLog/QuestLogNetworking.cs index e67dcc4..184ab27 100644 --- a/DeltaVFactionQuestLog/Data/Scripts/DeltaVQuestLog/QuestLogNetworking.cs +++ b/DeltaVFactionQuestLog/Data/Scripts/DeltaVQuestLog/QuestLogNetworking.cs @@ -18,7 +18,10 @@ public void Close() public void SendMessageToAll(QuestLogManager manager) { - MyAPIGateway.Multiplayer.SendMessageToOthers(NetworkId, MyAPIGateway.Utilities.SerializeToBinary(manager)); + if (MyAPIGateway.Session.IsServer) + MyAPIGateway.Multiplayer.SendMessageToOthers(NetworkId, MyAPIGateway.Utilities.SerializeToBinary(manager)); + else + MyAPIGateway.Multiplayer.SendMessageToServer(NetworkId, MyAPIGateway.Utilities.SerializeToBinary(manager)); } private void MessageHandler(ushort handlerId, byte[] data, ulong senderId, bool fromServer) @@ -27,6 +30,9 @@ private void MessageHandler(ushort handlerId, byte[] data, ulong senderId, bool if (manager == null) return; PersistentFactionObjectives.I.UpdateManager(manager); + + if (MyAPIGateway.Session.IsServer && !fromServer) + MyAPIGateway.Multiplayer.SendMessageToOthers(NetworkId, MyAPIGateway.Utilities.SerializeToBinary(manager)); } } }