public async Task Resync(bool skipTime) { if (((DateTime.Now - LastSyncTime).Seconds < 5 || IsCurrentlySyncing) && !skipTime) { MessageBox.Show($"You must wait 5 seconds before the last sync time \nSeconds to wait: {5 - (DateTime.Now - LastSyncTime).Seconds}", "DispatchSystem", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } LastSyncTime = DateTime.Now; IsCurrentlySyncing = true; if (string.IsNullOrWhiteSpace(plateView.Text)) { return; } Tuple <NetRequestResult, CivilianVeh> result = await Program.Client.TryTriggerNetFunction <CivilianVeh>("GetCivilianVeh", data.Plate); if (result.Item2 != null) { Invoke((MethodInvoker) delegate { data = result.Item2; UpdateCurrentInformation(); }); } else { MessageBox.Show("That plate doesn't exist in the system!", "DispatchSystem", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } IsCurrentlySyncing = false; }
private async Task <object> GetCivilianVeh(ConnectedPeer sender, object[] args) { await Task.FromResult(0); if (CheckAndDispose(sender)) { return(null); } #if DEBUG Log.WriteLine($"[{sender.RemoteIP}] Get civilian veh Request Recieved"); #else Log.WriteLineSilent($"[{sender.RemoteIP}] Get civilian veh Request Recieved"); #endif string plate = (string)args[0]; CivilianVeh civVeh = Common.GetCivilianVehByPlate(plate); if (civVeh != null) { #if DEBUG Log.WriteLine($"[{sender.RemoteIP}] Sending Civilian Veh information to Client"); #else Log.WriteLineSilent($"[{sender.RemoteIP}] Sending Civilian Veh information to Client"); #endif return(civVeh); } #if DEBUG Log.WriteLine($"[{sender.RemoteIP}] Civilian Veh not found, sending null"); #else Log.WriteLineSilent($"[{sender.RemoteIP}] Civilian Veh not found, sending null"); #endif return(CivilianVeh.Empty); }
public CivVehView(CivilianVeh civVehData) { Icon = Icon.ExtractAssociatedIcon("icon.ico"); InitializeComponent(); data = civVehData; UpdateCurrentInformation(); }
public static void SetName(string handle, string first, string last) { Player p = GetPlayerByHandle(handle); if (p == null) { return; } if (GetOfficer(handle) != null) { SendMessage(p, "DispatchSystem", new[] { 0, 0, 0 }, "You cannot be an officer and a civilian at the same time!"); return; } if (GetCivilianByName(first, last) != null && GetPlayerByIp(GetCivilianVeh(handle).SourceIP) != p) { SendMessage(p, "DispatchSystem", new[] { 0, 0, 0 }, $"That name already exists in the system!"); return; } if (GetCivilian(handle) != null) { int index = civs.IndexOf(GetCivilian(handle)); civs[index] = new Civilian(p.Identifiers["ip"]) { First = first, Last = last }; SendMessage(p, "DispatchSystem", new[] { 0, 0, 0 }, $"New name set to: {civs[index].First} {civs[index].Last}"); } else { civs.Add(new Civilian(p.Identifiers["ip"]) { First = first, Last = last }); int index = civs.IndexOf(GetCivilian(handle)); SendMessage(p, "DispatchSystem", new[] { 0, 0, 0 }, $"New name set to: {civs[index].First} {civs[index].Last}"); #if DEBUG SendMessage(p, "", new[] { 0, 0, 0 }, "Creating new civilian profile..."); #endif } if (GetCivilianVeh(handle) != null) { int index = civVehs.IndexOf(GetCivilianVeh(handle)); civVehs[index] = new CivilianVeh(p.Identifiers["ip"]); } }
private CivilianVeh GetCivilianVeh(ConnectedPeer sender, string plate) { #if DEBUG Log.WriteLine($"[{sender.RemoteIP}] Get civilian veh Request Received"); #else Log.WriteLineSilent($"[{sender.RemoteIP}] Get civilian veh Request Received"); #endif // tryna find the vehicle CivilianVeh civVeh = Common.GetCivilianVehByPlate(plate); #if DEBUG Log.WriteLine($"[{sender.RemoteIP}] Sending Civilian Veh information to Client"); #else Log.WriteLineSilent($"[{sender.RemoteIP}] Sending Civilian Veh information to Client"); #endif return(civVeh); }
public static RequestData SetVehicle(string handle, string plate) { Player p = Common.GetPlayerByHandle(handle); var civ = Common.GetCivilian(handle); var veh = Common.GetCivilianVeh(handle); // if no civilian exists if (civ == null) { return(new RequestData("civ_not_exist", new EventArgument[] { Common.GetPlayerId(p) })); } // checking if the plate already exists in the system if (Common.GetCivilianVehByPlate(plate) != null && Common.GetPlayerByIp(veh.SourceIP) != p) { return(new RequestData("veh_plate_exist", new EventArgument[] { Common.GetPlayerId(p), plate })); } EventArgument[] old = null; // checking if player already owns a vehicle if (veh != null) { int index = CivilianVehs.IndexOf(Common.GetCivilianVeh(handle)); // finding the existing index old = CivilianVehs[index].ToArray(); // setting the index to a new vehicle item veh = new CivilianVeh(p.Identifiers["ip"]) { Plate = plate, Owner = Common.GetCivilian(handle) }; CivilianVehs[index] = veh; } else { veh = new CivilianVeh(p.Identifiers["ip"]) { Plate = plate, Owner = Common.GetCivilian(handle) }; // creating the new vehicle CivilianVehs.Add(veh); // adding the new vehicle to the list of vehicles } return(new RequestData(null, new EventArgument[] { Common.GetPlayerId(p), veh.ToArray(), old })); }
public static void RequestCivilianVeh(string handle, string plate) { Player invoker = GetPlayerByHandle(handle); CivilianVeh civVeh = GetCivilianVehByPlate(plate); if (civVeh != null) { SendMessage(invoker, "DispatchSystem", new[] { 0, 0, 0 }, "Results: "); SendMessage(invoker, "DispatchSystem", new[] { 0, 0, 0 }, $"Plate: {civVeh.Plate.ToUpper()}"); SendMessage(invoker, "DispatchSystem", new[] { 0, 0, 0 }, $"Stolen: {civVeh.StolenStatus.ToString()}"); SendMessage(invoker, "DispatchSystem", new[] { 0, 0, 0 }, $"Registered: {civVeh.Registered.ToString()}"); SendMessage(invoker, "DispatchSystem", new[] { 0, 0, 0 }, $"Insured: {civVeh.Insured.ToString()}"); if (civVeh.Registered) { SendMessage(invoker, "DispatchSystem", new[] { 0, 0, 0 }, $"R/O: {civVeh.Owner.First} {civVeh.Owner.Last}"); } } else { SendMessage(invoker, "DispatchSystem", new[] { 0, 0, 0 }, "That vehicle doesn't exist in the system"); } }
public static void SetVehicle(string handle, string plate) { Player p = GetPlayerByHandle(handle); if (GetCivilian(handle) == null) { SendMessage(p, "DispatchSystem", new[] { 0, 0, 0 }, "You must set your name before you can set your vehicle"); return; } if (GetCivilianVehByPlate(plate) != null && GetPlayerByIp(GetCivilianVeh(handle).SourceIP) != p) { SendMessage(p, "DispatchSystem", new[] { 0, 0, 0 }, $"That vehicle already exists in the system!"); return; } if (GetCivilianVeh(handle) != null) { Int32 index = civVehs.IndexOf(GetCivilianVeh(handle)); civVehs[index] = new CivilianVeh(p.Identifiers["ip"]) { Plate = plate, Owner = GetCivilian(handle) }; SendMessage(p, "DispatchSystem", new[] { 0, 0, 0 }, $"New vehicle set to {civVehs[index].Plate}"); } else { civVehs.Add(new CivilianVeh(p.Identifiers["ip"]) { Plate = plate, Owner = GetCivilian(handle) }); Int32 index = civVehs.IndexOf(GetCivilianVeh(handle)); SendMessage(p, "DispatchSystem", new[] { 0, 0, 0 }, $"New vehicle set to {civVehs[index].Plate}"); } }
public static void ToggleVehicleInsurance(string handle) { Player p = GetPlayerByHandle(handle); if (GetCivilian(handle) == null) { SendMessage(p, "DispatchSystem", new[] { 0, 0, 0 }, "You must set your name before you can set your vehicle insurance"); return; } if (GetCivilianVeh(handle) != null) { int index = civVehs.IndexOf(GetCivilianVeh(handle)); CivilianVeh last = civVehs[index]; civVehs[index].Insured = !civVehs[index].Insured; SendMessage(p, "DispatchSystem", new[] { 0, 0, 0 }, $"Insurance status set to {civVehs[index].Insured.ToString()}"); } else { SendMessage(p, "DispatchSystem", new[] { 0, 0, 0 }, "You must set your vehicle before you can set your Insurance"); } }
public static RequestData RequestCivilianVeh(string handle) { CivilianVeh civVeh = Common.GetCivilianVeh(handle); // finding the vehicle return(civVeh != null ? new RequestData(null, civVeh.ToArray()) : new RequestData("veh_not_exist")); }