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"]); } }
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"); } }