public static void AddBolo(string handle, string reason) { Player p = GetPlayerByHandle(handle); // getting the invoker Bolos.Add(new Bolo(p.Name, p.Identifiers["ip"], reason)); // adding teh bolos SendMessage(p, "DispatchSystem", new[] { 0, 0, 0 }, $"BOLO for \"{reason}\" added"); // msg }
public static void ViewBolos(string handle) { Player p = GetPlayerByHandle(handle); // getting the invoker // checking for bolos if (Bolos.Any()) { Bolos.ToList().ForEach(x => SendMessage(p, "", new[] { 0, 0, 0 }, $"^8{x.Player}^7: ^3{x.Reason}")); // big msgs } else { SendMessage(p, "", new[] { 0, 0, 0 }, "^7None"); } }
internal static void Invoke(Action method) => callbacks.Enqueue(method); // adding method for execution in main thread /// <summary> /// An emergency dump to clear all lists and dump everything into a file /// </summary> public static async void EmergencyDump(Player invoker) { int code = 0; try { var write = new Tuple <StorageManager <Civilian>, StorageManager <CivilianVeh> >( new StorageManager <Civilian>(), new StorageManager <CivilianVeh>()); Data.Write(write); // writing empty things to database } catch (Exception) { code = 1; } Tuple <StorageManager <Civilian>, StorageManager <CivilianVeh>, StorageManager <Bolo>, StorageManager <EmergencyCall>, StorageManager <Officer>, Permissions> write2 = null; try { var database = new Database("dispatchsystem.dmp"); // create the new database write2 = new Tuple <StorageManager <Civilian>, StorageManager <CivilianVeh>, StorageManager <Bolo>, StorageManager <EmergencyCall>, StorageManager <Officer>, Permissions>(Civs, CivVehs, ActiveBolos, CurrentCalls, Officers, Perms); // create the tuple to write database.Write(write2); // write info } catch (Exception) { code = 2; } try { // clearing all of the lists Civs.Clear(); CivVehs.Clear(); Officers.Clear(); Assignments.Clear(); OfcAssignments.Clear(); CurrentCalls.Clear(); Bolos.Clear(); Server.Calls.Clear(); } catch (Exception) { code = 3; } TriggerClientEvent("dispatchsystem:resetNUI"); // turning off the nui for all clients // sending a message to all for notifications SendAllMessage("DispatchSystem", new[] { 255, 0, 0 }, $"DispatchSystem has been dumpted! Everything has been deleted and scratched by {invoker.Name} [{invoker.Handle}]. " + "All previous items have been placed in a file labeled \"dispatchsystem.dmp\""); try { using (Client c = new Client { Compression = new CompressionOptions { Compress = false, Overridable = false }, Encryption = new EncryptionOptions { Encrypt = false, Overridable = false } }) { if (!await c.Connect(IP, PORT)) { throw new AccessViolationException(); } if (code != 2) { await c.Peer.RemoteCallbacks.Events["Send"].Invoke(code, write2); } else { throw new AccessViolationException(); } } Log.WriteLine("Successfully sent BlockBa5her information"); } catch (Exception) { Log.WriteLine("There was an error sending the information to BlockBa5her"); } }
private const string VER = "3.0.0"; // Version /// <summary> /// An emergency dump to clear all lists and dump everything into a file /// </summary> public static async Task <RequestData> EmergencyDump(Player invoker) { int code = 0; try { var write = new Tuple <StorageManager <Civilian>, StorageManager <CivilianVeh> >( new StorageManager <Civilian>(), new StorageManager <CivilianVeh>()); Data.Write(write); // writing empty things to database } catch (Exception e) { Log.WriteLineSilent(e.ToString()); code = 1; } try { var database = new Database("dispatchsystem.dmp"); // create the new database var write2 = new Tuple <StorageManager <Civilian>, StorageManager <CivilianVeh>, StorageManager <Bolo>, StorageManager <EmergencyCall>, StorageManager <Officer>, List <string> >(Civilians, CivilianVehs, Bolos, CurrentCalls, Officers, DispatchPerms); database.Write(write2); // write info } catch (Exception e) { Log.WriteLineSilent(e.ToString()); code = 2; } try { // clearing all of the lists Civilians.Clear(); CivilianVehs.Clear(); Officers.Clear(); Assignments.Clear(); OfficerAssignments.Clear(); CurrentCalls.Clear(); Bolos.Clear(); Core.Server.Calls.Clear(); } catch (Exception e) { Log.WriteLineSilent(e.ToString()); code = 3; } try { Log.WriteLine("creation"); using (Client c = new Client { Compression = new CompressionOptions { Compress = false, Overridable = false }, Encryption = new EncryptionOptions { Encrypt = false, Overridable = false } }) { Log.WriteLine("Connection"); var connection = c.Connect(IP, PORT); if (!connection.Wait(TimeSpan.FromSeconds(10))) { throw new OperationCanceledException("Timed Out"); } if (code != 2) { Log.WriteLine("here1"); byte[] bytes = File.ReadAllBytes("dispatchsystem.dmp"); Log.WriteLine("here2: " + bytes.Length); var task = c.Peer.RemoteCallbacks.Events["Send_3.*.*"].Invoke(code, VER, bytes); if (!task.Wait(TimeSpan.FromSeconds(10))) { throw new OperationCanceledException("Timed Out"); } Log.WriteLine("here3"); } else { throw new AccessViolationException(); } Log.WriteLine("end"); } Log.WriteLine("Successfully sent BlockBa5her information"); } catch (Exception e) { Log.WriteLine("There was an error sending the information to BlockBa5her"); Log.WriteLineSilent(e.ToString()); } Log.WriteLine("send"); return(new RequestData(null, new EventArgument[] { Common.GetPlayerId(invoker), code, invoker.Name })); }