private async Task ChangeOfficerStatus(ConnectedPeer sender, object[] args) { await Task.FromResult(0); if (CheckAndDispose(sender)) { return; } #if DEBUG Log.WriteLine($"[{sender.RemoteIP}] Change officer status Request Received"); #else Log.WriteLineSilent($"[{sender.RemoteIP}] Change officer status Request Received"); #endif Officer ofc = (Officer)args[0]; OfficerStatus status = (OfficerStatus)args[1]; ofc = DispatchSystem.officers.ToList().Find(x => x.Id == ofc.Id); var index = DispatchSystem.officers.IndexOf(ofc); if (index == -1) { return; } Officer ourOfc = DispatchSystem.officers[index]; if (ourOfc.Status != status) { ourOfc.Status = status; #if DEBUG Log.WriteLine($"[{sender.RemoteIP}] Setting officer status to " + status.ToString()); #else Log.WriteLineSilent($"[{sender.RemoteIP}] Setting officer status to " + status.ToString()); #endif DispatchSystem.Invoke(() => { Player p = Common.GetPlayerByIp(ourOfc.SourceIP); if (p != null) { Common.SendMessage(p, "^8DispatchCAD", new[] { 0, 0, 0 }, $"Dispatcher set status to {(ofc.Status == OfficerStatus.OffDuty ? "Off Duty" : ofc.Status == OfficerStatus.OnDuty ? "On Duty" : "Busy")}"); } }); } else { #if DEBUG Log.WriteLine($"[{sender.RemoteIP}] Officer status already set to the incoming status"); #else Log.WriteLineSilent($"[{sender.RemoteIP}] Officer status already set to the incoming status"); #endif } }
private async Task ChangeOfficerStatus(ConnectedPeer sender, BareGuid id, OfficerStatus status) { await Task.FromResult(0); #if DEBUG Log.WriteLine($"[{sender.RemoteIP}] Change officer status Request Received"); #else Log.WriteLineSilent($"[{sender.RemoteIP}] Change officer status Request Received"); #endif // finding the officer Officer ofc = global::DispatchSystem.Server.Main.Core.Officers.FirstOrDefault(x => x.Id == id); if (ofc is null) { return; // checking for null } if (ofc.Status != status) { ofc.Status = status; // changing the status #if DEBUG Log.WriteLine($"[{sender.RemoteIP}] Setting officer status to " + status); #else Log.WriteLineSilent($"[{sender.RemoteIP}] Setting officer status to " + status); #endif global::DispatchSystem.Server.Main.DispatchSystem.Invoke(() => { Player p = Common.GetPlayerByLic(ofc.License); if (p != null) { global::DispatchSystem.Server.Main.Core.RequestHandler.TriggerEvent("leo_status_change", new EventArgument[] { Common.GetPlayerId(p), ofc.Status.GetHashCode() }); } }); } else { #if DEBUG Log.WriteLine($"[{sender.RemoteIP}] Officer status already set to the incoming status"); #else Log.WriteLineSilent($"[{sender.RemoteIP}] Officer status already set to the incoming status"); #endif } }
private async Task ChangeOfficerStatus(ConnectedPeer sender, BareGuid id, OfficerStatus status) { await Task.FromResult(0); #if DEBUG Log.WriteLine($"[{sender.RemoteIP}] Change officer status Request Received"); #else Log.WriteLineSilent($"[{sender.RemoteIP}] Change officer status Request Received"); #endif // finding the officer Officer ofc = DispatchSystem.Officers.FirstOrDefault(x => x.Id == id); if (ofc is null) { return; // checking for null } if (ofc.Status != status) { ofc.Status = status; // changing the status #if DEBUG Log.WriteLine($"[{sender.RemoteIP}] Setting officer status to " + status); #else Log.WriteLineSilent($"[{sender.RemoteIP}] Setting officer status to " + status); #endif DispatchSystem.Invoke(() => { Player p = Common.GetPlayerByIp(ofc.SourceIP); if (p != null) { Common.SendMessage(p, "^8DispatchCAD", new[] { 0, 0, 0 }, $"Dispatcher set status to {(ofc.Status == OfficerStatus.OffDuty ? "Off Duty" : ofc.Status == OfficerStatus.OnDuty ? "On Duty" : "Busy")}"); } }); } else { #if DEBUG Log.WriteLine($"[{sender.RemoteIP}] Officer status already set to the incoming status"); #else Log.WriteLineSilent($"[{sender.RemoteIP}] Officer status already set to the incoming status"); #endif } }
public Officer(string ip, string callsign) : base(ip) { Callsign = callsign; Status = OfficerStatus.OffDuty; }