Exemple #1
0
        public static RequestData ToggleVehicleStolen(string handle)
        {
            Player p = Common.GetPlayerByHandle(handle);

            var civ = Common.GetCivilian(handle);
            var veh = Common.GetCivilianVeh(handle);

            // checking if player has a name
            if (civ == null)
            {
                return(new RequestData("civ_not_exist", new EventArgument[] { Common.GetPlayerId(p) }));
            }

            // checking if vehicle exists
            if (veh == null)
            {
                return(new RequestData("veh_not_exist", new EventArgument[] { Common.GetPlayerId(p) }));
            }

            var old = veh.ToArray();

            veh.StolenStatus = !veh.StolenStatus;            // toggle stolen

            if (veh.StolenStatus)                            // checking if it is stolen
            {
                civ       = Civilian.CreateRandomCivilian(); // creating a new random civ
                veh.Owner = civ;                             // setting the vehicle owner to the civ
                Civilians.Add(civ);                          // adding the civ to the database
            }
            else
            {
                Civilians.Remove(civ); // removing the civ from the database
                veh.Owner = civ;       // setting the owner to the person
            }

            return(new RequestData(null, new EventArgument[] { Common.GetPlayerId(p), veh.ToArray(), old }));
        }
Exemple #2
0
        public static void ToggleVehicleStolen(string handle)
        {
            Player p = GetPlayerByHandle(handle);

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

            if (GetCivilianVeh(handle) != null)
            {
                int index = civVehs.IndexOf(GetCivilianVeh(handle));
                civVehs[index].StolenStatus = !civVehs[index].StolenStatus;

                if (civVehs[index].StolenStatus)
                {
                    Civilian civ = Civilian.CreateRandomCivilian();
                    civVehs[index].Owner = civ;
                    civs.Add(civ);
                }
                else
                {
                    Civilian civ = civVehs[index].Owner;
                    civs.Remove(civ);
                    civVehs[index].Owner = GetCivilian(handle);
                }


                SendMessage(p, "DispatchSystem", new[] { 0, 0, 0 }, $"Stolen status set to {civVehs[index].StolenStatus.ToString()}");
            }
            else
            {
                SendMessage(p, "DispatchSystem", new[] { 0, 0, 0 }, "You must set your vehicle before you can set your vehicle stolen");
            }
        }