private void RemoveCop(int sourceID, List <dynamic> args, string rawCommand) { if (args.Count == 1) { Cop cop = null; if (cops.Count > Convert.ToInt32(args[0])) { cop = cops[Convert.ToInt32(args[0])]; } if (cop == null) { Debug.WriteLine("Invalid Cop ID!"); return; } if (GetPlayerFromHex(cop.Hex) != null) { TriggerClientEvent(GetPlayerFromHex(cop.Hex), "chatMessage", "", new[] { 255, 0, 0 }, "You are no longer a cop!"); } cops.Remove(cop); DatabaseSave(); Debug.WriteLine("Cop Deleted!"); } else { Debug.WriteLine("Invalid Syntax, use: pmremovecop <Cop ID>"); return; } }
private void ClearCops(int sourceID, List <dynamic> args, string rawCommand) { cops.Clear(); Cop department = new Cop { Hex = "test" }; cops.Add(department); DatabaseSave(); }
private Cop GetCopFromID(int id) { Cop department = null; foreach (Cop dep in cops) { if (dep.Hex == GetPlayerFromSID(id).Identifiers.First().ToString()) { department = dep; } } return(department); }
private void ClearDB() { cops.Clear(); admins.Clear(); departments.Clear(); fdepartments.Clear(); firefighters.Clear(); Cop cop = new Cop { Hex = "test" }; Admin admin = new Admin { Hex = "test" }; Firefighter ff = new Firefighter { Hex = "test" }; Department department = new Department { Name = "test" }; FDepartment fdepartment = new FDepartment { Name = "test" }; cops.Add(cop); admins.Add(admin); firefighters.Add(ff); departments.Add(department); fdepartments.Add(fdepartment); Tuple <List <Cop>, List <Admin>, List <Firefighter>, List <Department>, List <FDepartment> > write = new Tuple <List <Cop>, List <Admin>, List <Firefighter>, List <Department>, List <FDepartment> >(cops, admins, firefighters, departments, fdepartments); database.Write(write); }
private void AddCop(int sourceID, List <dynamic> args, string rawComamnd) { if (args.Count >= 3) { if (GetPlayerFromSID(Convert.ToInt32(args[0])) != null) { if (GetDepartmentFromID(Convert.ToInt32(args[1])) != null) { string[] splitArgs = args.Select(x => (string)x).ToArray(); Cop cop = new Cop(); Player player = GetPlayerFromSID(Convert.ToInt32(args[0])); cop.Name = player.Name; cop.Department = GetDepartmentFromID(Convert.ToInt32(args[1])); cop.Callsign = string.Join(" ", splitArgs).Replace(splitArgs[0] + " ", "").Replace(splitArgs[1] + " ", ""); cop.Hex = player.Identifiers.First().ToString(); cops.Add(cop); cop.Department.officers.Add(cop); DatabaseSave(); Debug.WriteLine("\"" + cop.Name + "\" (" + cop.Callsign + ") was added to \"" + cop.Department.Name + "\""); TriggerClientEvent(GetPlayerFromSID(Convert.ToInt32(args[0])), "chatMessage", "", new[] { 0, 255, 0 }, "Welcome to " + cop.Department.Name + ", your callsign is: " + cop.Callsign); } else { Debug.WriteLine("Invalid Department"); } } else { Debug.WriteLine("Invalid Player ID"); } } else { Debug.WriteLine("Invalid syntax, use: pmaddcop <Player ID> <Department ID> <Callsign>"); } }
private void ChatMessage([FromSource] int sourceCID, int sourceSID, string sourceName, string message) { string[] splitMessage = message.Split(' '); if (splitMessage[0] == "/odc" || splitMessage[0] == "/ondutycop") { if (IsCop(sourceSID)) { if (GetFireFromID(sourceSID) != null) { GetFireFromID(sourceSID).OnDuty = false; } Cop cop = GetCopFromID(sourceSID); if (cop.OnDuty) { TriggerClientEvent(GetPlayerFromSID(sourceSID), "chatMessage", "DISPATCH", new[] { 255, 0, 0 }, "You are already on-duty as a Police Officer!"); CancelEvent(); return; } GetCopFromID(sourceSID).OnDuty = true; TriggerClientEvent(GetPlayerFromSID(sourceSID), "chatMessage", "DISPATCH", new[] { 255, 0, 0 }, "You are now on-duty as a Police Officer!"); } else { TriggerClientEvent(GetPlayerFromSID(sourceSID), "chatMessage", "", new[] { 255, 0, 0 }, "You are not a Police Officer!"); } } else if (splitMessage[0] == "/ofd" || splitMessage[0] == "/offduty") { if (IsCop(sourceSID)) { Cop cop = GetCopFromID(sourceSID); if (!cop.OnDuty) { TriggerClientEvent(GetPlayerFromSID(sourceSID), "chatMessage", "DISPATCH", new[] { 255, 0, 0 }, "You are already off-duty!"); CancelEvent(); return; } cop.OnDuty = false; TriggerClientEvent(GetPlayerFromSID(sourceSID), "chatMessage", "DISPATCH", new[] { 255, 0, 0 }, "You are now off-duty!"); } else if (IsFire(sourceSID)) { Firefighter cop = GetFireFromID(sourceSID); if (!cop.OnDuty) { TriggerClientEvent(GetPlayerFromSID(sourceSID), "chatMessage", "DISPATCH", new[] { 255, 0, 0 }, "You are already off-duty!"); CancelEvent(); return; } cop.OnDuty = false; TriggerClientEvent(GetPlayerFromSID(sourceSID), "chatMessage", "DISPATCH", new[] { 255, 0, 0 }, "You are now off-duty!"); } else { TriggerClientEvent(GetPlayerFromSID(sourceSID), "chatMessage", "", new[] { 255, 0, 0 }, "You are not on-duty!"); } } else if (splitMessage[0] == "/odf" || splitMessage[0] == "/ondutyfire") { if (IsFire(sourceSID)) { if (GetCopFromID(sourceSID) != null) { GetCopFromID(sourceSID).OnDuty = false; } Firefighter cop = GetFireFromID(sourceSID); if (cop.OnDuty) { TriggerClientEvent(GetPlayerFromSID(sourceSID), "chatMessage", "DISPATCH", new[] { 255, 0, 0 }, "You are already on-duty as a Firefighter!"); CancelEvent(); return; } GetFireFromID(sourceSID).OnDuty = true; TriggerClientEvent(GetPlayerFromSID(sourceSID), "chatMessage", "DISPATCH", new[] { 255, 0, 0 }, "You are now on-duty as a Firefighter!"); } else { TriggerClientEvent(GetPlayerFromSID(sourceSID), "chatMessage", "", new[] { 255, 0, 0 }, "You are not a Firefighter!"); } } else if (splitMessage[0] == "/cops") { List <Cop> onDCops = new List <Cop>(); foreach (Cop cop in cops) { if (cop.Hex != "test" && cop.OnDuty) { onDCops.Add(cop); } } if (onDCops.Count != 0) { TriggerClientEvent(GetPlayerFromSID(sourceSID), "chatMessage", "DISPATCH", new[] { 255, 0, 0 }, "The Following Officer(s) Are On-Duty:"); foreach (Cop cop in onDCops) { TriggerClientEvent(GetPlayerFromSID(sourceSID), "chatMessage", "", new[] { 255, 0, 0 }, cop.Name + " (" + cop.Callsign + ") - " + cop.Department.Acronym); } } else { TriggerClientEvent(GetPlayerFromSID(sourceSID), "chatMessage", "DISPATCH", new[] { 255, 0, 0 }, "No Cops On-Duty!"); } } else if (splitMessage[0] == "/firefighters") { List <Firefighter> onDCops = new List <Firefighter>(); foreach (Firefighter cop in firefighters) { if (cop.Hex != "test" && cop.OnDuty) { onDCops.Add(cop); } } if (onDCops.Count != 0) { TriggerClientEvent(GetPlayerFromSID(sourceSID), "chatMessage", "DISPATCH", new[] { 255, 0, 0 }, "The Following Officer(s) Are On-Duty:"); foreach (Firefighter cop in onDCops) { TriggerClientEvent(GetPlayerFromSID(sourceSID), "chatMessage", "", new[] { 255, 0, 0 }, cop.Name + " (" + cop.Callsign + ") - " + cop.Department.Acronym); } } else { TriggerClientEvent(GetPlayerFromSID(sourceSID), "chatMessage", "DISPATCH", new[] { 255, 0, 0 }, "No Cops On-Duty!"); } } else if (splitMessage[0] == "/funitid") { if (IsFire(sourceSID)) { firefighters[firefighters.IndexOf(GetFireFromID(sourceSID))].Callsign = message.Replace("/funitid ", ""); DatabaseSave(); } else { TriggerClientEvent(GetPlayerFromSID(sourceSID), "chatMessage", "", new[] { 255, 0, 0 }, "You are not a Firefighter!"); } } else if (splitMessage[0] == "/punitid") { if (IsCop(sourceSID)) { cops[cops.IndexOf(GetCopFromID(sourceSID))].Callsign = message.Replace("/punitid ", ""); DatabaseSave(); } else { TriggerClientEvent(GetPlayerFromSID(sourceSID), "chatMessage", "", new[] { 255, 0, 0 }, "You are not a Cop!"); } } else if (message.StartsWith("/")) { CancelEvent(); return; } }