Example #1
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 #2
0
        public static void SetVehicle(string handle, string plate)
        {
            Player p = GetPlayerByHandle(handle);

            // if no civilian exists
            if (GetCivilian(handle) == null)
            {
                SendMessage(p, "DispatchSystem", new[] { 0, 0, 0 }, "You must set your name before you can set your vehicle");
                return;
            }

            // checking if the plate already exists in the system
            if (GetCivilianVehByPlate(plate) != null && GetPlayerByIp(GetCivilianVeh(handle).SourceIP) != p)
            {
                SendMessage(p, "DispatchSystem", new[] { 0, 0, 0 }, "That vehicle already exists in the system!");
                return;
            }

            // checking if player already owns a vehicle
            if (GetCivilianVeh(handle) != null)
            {
                int index = CivVehs.IndexOf(GetCivilianVeh(handle)); // finding the existing index
                CivVehs[index] = new CivilianVeh(p.Identifiers["ip"])
                {
                    Plate = plate, Owner = GetCivilian(handle)
                };                                                                                                 // setting the index to a new vehicle item
                SendMessage(p, "DispatchSystem", new[] { 0, 0, 0 }, $"New vehicle set to {CivVehs[index].Plate}"); // msg of creation
            }
            else
            {
                CivilianVeh veh = new CivilianVeh(p.Identifiers["ip"])
                {
                    Plate = plate, Owner = GetCivilian(handle)
                };                                                                                      // creating the new vehicle
                CivVehs.Add(veh);                                                                       // adding the new vehicle to the list of vehicles

                SendMessage(p, "DispatchSystem", new[] { 0, 0, 0 }, $"New vehicle set to {veh.Plate}"); // msg
            }
        }
Example #3
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 #4
0
        public static void ToggleVehicleInsurance(string handle)
        {
            Player p = GetPlayerByHandle(handle);

            // checking for existing civ
            if (GetCivilian(handle) == null)
            {
                SendMessage(p, "DispatchSystem", new[] { 0, 0, 0 }, "You must set your name before you can set your vehicle insurance");
                return;
            }

            // checking if the vehicle exists
            if (GetCivilianVeh(handle) != null)
            {
                int index = CivVehs.IndexOf(GetCivilianVeh(handle));                                                      // finding the index
                CivVehs[index].Insured = !CivVehs[index].Insured;                                                         // toggle insurance

                SendMessage(p, "DispatchSystem", new[] { 0, 0, 0 }, $"Insurance status set to {CivVehs[index].Insured}"); // msg
            }
            else
            {
                SendMessage(p, "DispatchSystem", new[] { 0, 0, 0 }, "You must set your vehicle before you can set your Insurance");
            }
        }