Beispiel #1
0
 private void RemoveFF(int sourceID, List <dynamic> args, string rawCommand)
 {
     if (args.Count == 1)
     {
         Firefighter cop = null;
         if (firefighters.Count > Convert.ToInt32(args[0]))
         {
             cop = firefighters[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!");
         }
         firefighters.Remove(cop);
         DatabaseSave();
         Debug.WriteLine("Cop Deleted!");
     }
     else
     {
         Debug.WriteLine("Invalid Syntax, use: pmremoveff <Cop ID>");
         return;
     }
 }
Beispiel #2
0
        private void ClearFFs(int sourceID, List <dynamic> args, string rawCommand)
        {
            firefighters.Clear();
            Firefighter department = new Firefighter
            {
                Hex = "test"
            };

            firefighters.Add(department);
            DatabaseSave();
        }
Beispiel #3
0
        private Firefighter GetFireFromID(int id)
        {
            Firefighter department = null;

            foreach (Firefighter dep in firefighters)
            {
                if (dep.Hex == GetPlayerFromSID(id).Identifiers.First().ToString())
                {
                    department = dep;
                }
            }
            return(department);
        }
Beispiel #4
0
        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);
        }
Beispiel #5
0
 private void AddFF(int sourceID, List <dynamic> args, string rawComamnd)
 {
     if (args.Count >= 3)
     {
         if (GetPlayerFromSID(Convert.ToInt32(args[0])) != null)
         {
             if (GetFDepartmentFromID(Convert.ToInt32(args[1])) != null)
             {
                 string[]    splitArgs = args.Select(x => (string)x).ToArray();
                 Firefighter cop       = new Firefighter();
                 Player      player    = GetPlayerFromSID(Convert.ToInt32(args[0]));
                 cop.Name       = player.Name;
                 cop.Department = GetFDepartmentFromID(Convert.ToInt32(args[1]));
                 cop.Callsign   = string.Join(" ", splitArgs).Replace(splitArgs[0] + " ", "").Replace(splitArgs[1] + " ", "");
                 cop.Hex        = player.Identifiers.First().ToString();
                 firefighters.Add(cop);
                 cop.Department.firefighters.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: pmaddff <Player ID> <Department ID> <Callsign>");
     }
 }
Beispiel #6
0
 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;
     }
 }