Example #1
0
        public static void TicketCivilian(string invokerHandle, string first, string last, string reason, float amount)
        {
            Player   invoker = GetPlayerByHandle(invokerHandle); // getting the invoker
            Civilian civ     = GetCivilianByName(first, last);   // finding the civ

            // checking for civ
            if (civ != null)
            {
                int    index = Civs.IndexOf(civ);                    // finding the index of the civ
                Player p     = GetPlayerByIp(Civs[index].SourceIP);  // finding the player that the civ owns
                Civs[index].CitationCount++;                         // adding 1 to the citations
                Civs[index].Tickets.Add(new Ticket(reason, amount)); // adding a ticket to the existing tickets
                // msgs for the civs
                if (p != null)
                {
                    SendMessage(p, "Ticket", new[] { 255, 0, 0 },
                                $"{invoker.Name} tickets you for ${amount.ToString(CultureInfo.InvariantCulture)} because of {reason}");
                }
                SendMessage(invoker, "DispatchSystem", new[] { 0, 0, 0 },
                            $"You successfully ticketed {p?.Name ?? "NULL"} for ${amount.ToString(CultureInfo.InvariantCulture)}");
            }
            else
            {
                SendMessage(invoker, "DispatchSystem", new[] { 0, 0, 0 }, "That name doesn't exist in the system");
            }
        }
Example #2
0
        public static async void InitializeEmergency(string handle)
        {
            Player p = GetPlayerByHandle(handle);

            // checking for an existing emergency
            if (GetEmergencyCall(handle) != null)
            {
                SendMessage(p, "DispatchSystem", new[] { 0, 0, 0 }, "You already have a 911 call!");
                return;
            }

            if (GetCivilian(handle) != null)
            {
                Civilian civ = GetCivilian(handle); // finding the civ

                // checking how many active dispatchers there are
                if (Server.ConnectedDispatchers.Length == 0)
                {
                    SendMessage(p, "DispatchSystem", new[] { 0, 0, 0 }, "It seems like there is no connected dispatchers at this moment!");
                    return;
                }

                EmergencyCall call;
                CurrentCalls.Add(call = new EmergencyCall(p.Identifiers["ip"], $"{civ.First} {civ.Last}"));    // adding and creating the instance of the emergency
                SendMessage(p, "Dispatch911", new[] { 255, 0, 0 }, "Please wait for a dispatcher to respond"); // msging to wait for a dispatcher
                foreach (var peer in Server.ConnectedDispatchers)
                {
                    await peer.RemoteCallbacks.Events["911alert"].Invoke(civ, call); // notifying the dispatchers of the 911 call
                }
            }
            else
            {
                SendMessage(p, "DispatchSystem", new[] { 0, 0, 0 }, "You must set your name before start a 911 call");
            }
        }
Example #3
0
 public CivilianVeh(Player source, Civilian owner, String plate, Boolean stolen, Boolean regi, Boolean insur)
 {
     this.Source       = source;
     this.Plate        = plate;
     this.StolenStatus = stolen;
     this.Owner        = owner;
     this.Registered   = regi;
     this.Insured      = insur;
 }
Example #4
0
        public static void SetName(string handle, string first, string last)
        {
            Player p = GetPlayerByHandle(handle);

            if (GetOfficer(handle) != null) // checking if the civilian has an officer
            {
                SendMessage(p, "DispatchSystem", new[] { 0, 0, 0 }, "You cannot be an officer and a civilian at the same time!");
                return; // return if they do
            }

            if (GetCivilianByName(first, last) != null && GetPlayerByIp(GetCivilianVeh(handle).SourceIP) != p) // checking if the name already exists in the system
            {
                SendMessage(p, "DispatchSystem", new[] { 0, 0, 0 }, "That name already exists in the system!");
                return; // return if it does
            }

            // checking if the civilian already has a civ in the system
            if (GetCivilian(handle) != null)
            {
                int index = Civs.IndexOf(GetCivilian(handle)); // finding the index of the existing civ

                Civs[index] = new Civilian(p.Identifiers["ip"])
                {
                    First = first, Last = last
                };                                                                                                               // setting the index to an instance of a new civilian

                SendMessage(p, "DispatchSystem", new[] { 0, 0, 0 }, $"New name set to: {Civs[index].First} {Civs[index].Last}"); // saying the new name created
            }
            else // if the civ doesn't exist
            {
                Civs.Add(new Civilian(p.Identifiers["ip"])
                {
                    First = first, Last = last
                });                                                                                                              // add a new civilian to the system
                int index = Civs.IndexOf(GetCivilian(handle));                                                                   // find the index of the civ

                SendMessage(p, "DispatchSystem", new[] { 0, 0, 0 }, $"New name set to: {Civs[index].First} {Civs[index].Last}"); // say the new name was created
#if DEBUG
                SendMessage(p, "", new[] { 0, 0, 0 }, "Creating new civilian profile...");
#endif
            }
            if (GetCivilianVeh(handle) != null)
            {
                // below basically resets the vehicle if it exists

                int index = CivVehs.IndexOf(GetCivilianVeh(handle));

                CivVehs[index] = new CivilianVeh(p.Identifiers["ip"]);
            }
        }
Example #5
0
        public static void DisplayCurrentCivilian(string handle)
        {
            Player   p   = GetPlayerByHandle(handle);
            Civilian civ = GetCivilian(handle);

            if (civ != null)
            {
                SendMessage(p, "", new[] { 255, 255, 255 }, $"First: {civ.First} | Last: {civ.Last}");
                SendMessage(p, "", new[] { 255, 255, 255 }, $"Warrant: {civ.WarrantStatus}");
                SendMessage(p, "", new[] { 255, 255, 255 }, $"Citations: {civ.CitationCount}");
            }
            else
            {
                SendMessage(p, "DispatchSystem", new [] { 0, 0, 0 }, "You don't exist in the system");
            }
        }
Example #6
0
        public static void AddCivilianNote(string invokerHandle, string first, string last, string note)
        {
            Player   invoker = GetPlayerByHandle(invokerHandle); // getting the invoker
            Civilian civ     = GetCivilianByName(first, last);   // finding the civ

            // checking civ
            if (civ != null)
            {
                int index = Civs.IndexOf(civ);                                                                                   // finding the index
                Civs[index].Notes.Add(note);                                                                                     // adding the note to the civ
                SendMessage(invoker, "DispatchSystem", new[] { 0, 0, 0 }, $"Note of \"{note}\" has been added to the Civilian"); // msg
            }
            else
            {
                SendMessage(invoker, "DispatchSystem", new[] { 0, 0, 0 }, "That name doesn't exist in the system");
            }
        }
Example #7
0
        public static void SetCitations(string handle, int count)
        {
            Player p = GetPlayerByHandle(handle);

            if (GetCivilian(handle) != null)
            {
                int      index = civs.IndexOf(GetCivilian(handle));
                Civilian last  = civs[index];

                civs[index] = new Civilian(p, last.First, last.Last, last.WarrantStatus, count);

                SendMessage(p, "DispatchSystem", new[] { 0, 0, 0 }, $"Citation count set to {count.ToString()}");
            }
            else
            {
                SendMessage(p, "DispatchSystem", new[] { 0, 0, 0 }, "You must set your name before you can set your citations");
            }
        }
Example #8
0
        public static void ToggleWarrant(string handle)
        {
            Player p = GetPlayerByHandle(handle);

            if (GetCivilian(handle) != null)
            {
                int      index = civs.IndexOf(GetCivilian(handle));
                Civilian last  = civs[index];

                civs[index] = new Civilian(p, last.First, last.Last, !last.WarrantStatus, last.CitationCount);

                SendMessage(p, "DispatchSystem", new[] { 0, 0, 0 }, $"Warrant status set to {civs[index].WarrantStatus.ToString()}");
            }
            else
            {
                SendMessage(p, "DispatchSystem", new[] { 0, 0, 0 }, "You must set your name before you can toggle your warrant");
            }
        }
Example #9
0
        public static void RequestCivilian(string handle, string first, string last)
        {
            Player   invoker = GetPlayerByHandle(handle);
            Civilian civ     = GetCivilianByName(first, last);

            if (civ != null)
            {
                WriteChatLine(invoker);
                SendMessage(invoker, "DispatchSystem", new[] { 0, 0, 0 }, "Results: ");
                SendMessage(invoker, "DispatchSystem", new[] { 0, 0, 0 }, $"First: {civ.First} | Last: {civ.Last}");
                SendMessage(invoker, "DispatchSystem", new[] { 0, 0, 0 }, $"Warrant: {civ.WarrantStatus.ToString()}");
                SendMessage(invoker, "DispatchSystem", new[] { 0, 0, 0 }, $"Citations: {civ.CitationCount.ToString()}");
                WriteChatLine(invoker);
            }
            else
            {
                SendMessage(invoker, "DispatchSystem", new[] { 0, 0, 0 }, "That name doesn't exist in the system");
            }
        }
Example #10
0
        public static void RequestCivilian(string handle, string first, string last)
        {
            Player   invoker = GetPlayerByHandle(handle);      // getting the invoker
            Civilian civ     = GetCivilianByName(first, last); // finding the civ

            // checking if the civ is not null
            if (civ != null)
            {
                // results msg
                SendMessage(invoker, "DispatchSystem", new[] { 0, 0, 0 }, "Results: ");
                SendMessage(invoker, "DispatchSystem", new[] { 0, 0, 0 }, $"First: {civ.First} | Last: {civ.Last}");
                SendMessage(invoker, "DispatchSystem", new[] { 0, 0, 0 }, $"Warrant: {civ.WarrantStatus}");
                SendMessage(invoker, "DispatchSystem", new[] { 0, 0, 0 }, $"Citations: {civ.CitationCount}");
            }
            else
            {
                SendMessage(invoker, "DispatchSystem", new[] { 0, 0, 0 }, "That civilian doesn't exist in the system");
            }
        }
Example #11
0
        public static void DipslayCivilianNotes(string handle, string first, string last)
        {
            Player   invoker = GetPlayerByHandle(handle);      // getting the invoker
            Civilian civ     = GetCivilianByName(first, last); // finding the civ

            if (civ != null)
            {
                // sending the msgs
                if (!civ.Notes.Any())
                {
                    SendMessage(invoker, "", new[] { 0, 0, 0 }, "^7None");
                }
                else
                {
                    civ.Notes.ForEach(x => SendMessage(invoker, "", new[] { 0, 0, 0 }, x)); // big msgs
                }
            }
            else
            {
                SendMessage(invoker, "DispatchSystem", new[] { 0, 0, 0 }, "That name doesn't exist in the system");
            }
        }
Example #12
0
        public static void ToggleVehicleStolen(string handle)
        {
            Player p = GetPlayerByHandle(handle);

            // checking if player has a name
            if (GetCivilian(handle) == null)
            {
                SendMessage(p, "DispatchSystem", new[] { 0, 0, 0 }, "You must set your name before you can set your vehicle stolen");
                return;
            }

            // checking if vehicle exists
            if (GetCivilianVeh(handle) != null)
            {
                int index = CivVehs.IndexOf(GetCivilianVeh(handle));        // finding index of vehicle
                CivVehs[index].StolenStatus = !CivVehs[index].StolenStatus; // toggle stolen

                if (CivVehs[index].StolenStatus)                            // checking if it is stolen
                {
                    Civilian civ = Civilian.CreateRandomCivilian();         // creating a new random civ
                    CivVehs[index].Owner = civ;                             // setting the vehicle owner to the civ
                    Civs.Add(civ);                                          // adding the civ to the database
                }
                else
                {
                    Civilian civ = CivVehs[index].Owner;        // finding the existing civ
                    Civs.Remove(civ);                           // removing the civ from the database
                    CivVehs[index].Owner = GetCivilian(handle); // setting the owner to the person
                }


                SendMessage(p, "DispatchSystem", new[] { 0, 0, 0 }, $"Stolen status set to {CivVehs[index].StolenStatus}");
            }
            else
            {
                SendMessage(p, "DispatchSystem", new[] { 0, 0, 0 }, "You must set your vehicle before you can set your vehicle stolen");
            }
        }
Example #13
0
        public static void SetName(string handle, string first, string last)
        {
            Player p = GetPlayerByHandle(handle);

            if (p == null)
            {
                return;
            }

            if (GetCivilian(handle) != null)
            {
                int index = civs.IndexOf(GetCivilian(handle));

                civs[index] = new Civilian(p, first, last, false, 0);

                SendMessage(p, "DispatchSystem", new[] { 0, 0, 0 }, $"New name set to: {civs[index].First} {civs[index].Last}");
            }
            else
            {
                civs.Add(new Civilian(p, first, last, false, 0));
                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 ENABLE_VEH
            if (GetCivilianVeh(handle) != null)
            {
                int index = civVehs.IndexOf(GetCivilianVeh(handle));

                civVehs[index] = new CivilianVeh(p);
            }
#endif
        }
Example #14
0
        public static void DisplayCivilianTickets(string invokerHandle, string first, string last)
        {
            Player   invoker = GetPlayerByHandle(invokerHandle); // getting the invoker
            Civilian civ     = GetCivilianByName(first, last);   // finding the civ

            // checking for civ
            if (civ != null)
            {
                int index = Civs.IndexOf(civ); // finding the index of the civ
                // msgs if any tickets
                if (!Civs[index].Tickets.Any())
                {
                    SendMessage(invoker, "", new[] { 0, 0, 0 }, "^7None");
                }
                else
                {
                    Civs[index].Tickets.ForEach(x => SendMessage(invoker, "", new[] { 0, 0, 0 }, $"^7${x.Amount}: {x.Reason}")); // big msgs
                }
            }
            else
            {
                SendMessage(invoker, "DispatchSystem", new[] { 0, 0, 0 }, "That name doesn't exist in the system");
            }
        }