Exemplo n.º 1
0
        private static void CheckForDrownedVehicles()
        {
            var vehicles = VehicleManager.vehicles;

            for (var i = vehicles.Count - 1; i >= 0; i--)
            {
                if (!VehicleUtil.VehicleHasOwner(vehicles[i]))
                {
                    continue;
                }
                if (!vehicles[i].isDrowned)
                {
                    continue;
                }
                var vName        = vehicles[i].asset.vehicleName;
                var vId          = vehicles[i].asset.id;
                var vOwner       = vehicles[i].lockedOwner;
                var vehicleCount = DbManager.GetVehicleCount(vOwner.m_SteamID.ToString(), "Drown");
                if (vehicleCount >= Conf.DrownGarageSlot && Conf.DrownGarageSlot != -1)
                {
                    continue;
                }
                var drownedVehicleRegion = BarricadeManager.getRegionFromVehicle(vehicles[i]);
                GarageUtil.SaveVgVehicleToSql(vOwner.m_SteamID, "Drown", "Drowned", vehicles[i],
                                              drownedVehicleRegion);
                if (UnturnedPlayer.FromCSteamID(vOwner) != null)
                {
                    UnturnedPlayer.FromCSteamID(vOwner).SendChat(
                        Inst.Translate("rfgarage_autogarage_drown_success", vName, vId), MsgColor,
                        Conf.AnnouncerIconUrl);
                }
                Logger.LogWarning(
                    $"[RFGarage] {vName} [{vId}] has been added automatically to {vOwner.m_SteamID}'s garage due to Drown");
            }
        }
Exemplo n.º 2
0
        public void Execute(IRocketPlayer caller, string[] command)
        {
            if (command.Length > 2 || command.Length == 0)
            {
                caller.SendChat(Plugin.Inst.Translate("rfgarage_command_invalid_parameter", Syntax), Plugin.MsgColor, Plugin.Conf.AnnouncerIconUrl);
                return;
            }

            var player = (UnturnedPlayer)caller;

            switch (command.Length)
            {
            case 1 when Plugin.Conf.VirtualGarages.Any(g => string.Equals(g.Name, command[0], StringComparison.CurrentCultureIgnoreCase)):
                caller.SendChat(Plugin.Inst.Translate("rfgarage_command_invalid_parameter", Syntax), Plugin.MsgColor, Plugin.Conf.AnnouncerIconUrl);

                return;

            case 1 when !Plugin.Conf.VirtualGarages.Any(g => string.Equals(g.Name, command[0], StringComparison.CurrentCultureIgnoreCase)):
            {
                if (!CheckResponse(player, command, out var vehicle, out var vehicleRegion))
                {
                    return;
                }
                var garage = Plugin.SelectedGarageDict[player.CSteamID];
                GarageUtil.SaveVgVehicleToSql(player.CSteamID.m_SteamID, garage.Name, command[0], vehicle, vehicleRegion);
                caller.SendChat(Plugin.Inst.Translate("rfgarage_command_gadd_success", vehicle.asset.vehicleName, vehicle.asset.id, garage.Name), Plugin.MsgColor, Plugin.Conf.AnnouncerIconUrl);
                return;
            }

            case 1:
                caller.SendChat(Plugin.Inst.Translate("rfgarage_command_invalid_parameter"), Plugin.MsgColor, Plugin.Conf.AnnouncerIconUrl);
                return;

            case 2:
            {
                if (!CheckResponse(player, command, out var vehicle, out var vehicleRegion))
                {
                    return;
                }
                var garage = GarageModel.Parse(command[0]);
                GarageUtil.SaveVgVehicleToSql(player.CSteamID.m_SteamID, garage.Name, command[1], vehicle, vehicleRegion);
                caller.SendChat(Plugin.Inst.Translate("rfgarage_command_gadd_success", vehicle.asset.vehicleName, vehicle.asset.id, garage.Name), Plugin.MsgColor, Plugin.Conf.AnnouncerIconUrl);
                return;
            }

            default:
                caller.SendChat(Plugin.Inst.Translate("rfgarage_command_invalid_parameter"), Plugin.MsgColor, Plugin.Conf.AnnouncerIconUrl);
                break;
            }
        }
        public void Execute(IRocketPlayer caller, string[] command)
        {
            if (command.Length != 3)
            {
                UnturnedChat.Say(caller, Plugin.Inst.Translate("rfgarage_command_invalid_parameter", Syntax), Plugin.MsgColor);
                return;
            }

            var player = (UnturnedPlayer)caller;

            if (!CheckResponse(player, command, out var vehicle, out var vehicleRegion))
            {
                return;
            }
            var garage = GarageModel.Parse(command[1]);

            GarageUtil.SaveVgVehicleToSql(ulong.Parse(command[0]), garage.Name, command[2], vehicle, vehicleRegion);
            UnturnedChat.Say(caller, Plugin.Inst.Translate("rfgarage_command_sgadd_success", vehicle.asset.vehicleName, vehicle.asset.id, garage.Name), Plugin.MsgColor);
        }
Exemplo n.º 4
0
        public void Execute(IRocketPlayer caller, string[] command)
        {
            if (command.Length > 1)
            {
                caller.SendChat(Plugin.Inst.Translate("rfgarage_command_invalid_parameter", Syntax), Plugin.MsgColor, Plugin.Conf.AnnouncerIconUrl);
                return;
            }

            var player = (UnturnedPlayer)caller;

            switch (command.Length)
            {
            case 0:
                Plugin.GarageAddAllQueueDict[player.CSteamID] = true;

                caller.SendChat(Plugin.Inst.Translate("rfgarage_command_gadd_all_ask_confirm"), Plugin.MsgColor, Plugin.Conf.AnnouncerIconUrl);
                return;

            case 1:
                switch (command[0].ToLower())
                {
                case "confirm" when !Plugin.GarageAddAllQueueDict[player.CSteamID]:
                    caller.SendChat(Plugin.Inst.Translate("rfgarage_command_all_no_queue"), Plugin.MsgColor, Plugin.Conf.AnnouncerIconUrl);
                    return;

                case "confirm":
                {
                    caller.SendChat(Plugin.Inst.Translate("rfgarage_command_gadd_all_confirm"), Plugin.MsgColor, Plugin.Conf.AnnouncerIconUrl);
                    // Tuple < availableGarage, availableSlot >
                    var passedVehicles      = new List <InteractableVehicle>();
                    var blacklistedVehicles = new List <InteractableVehicle>();
                    var availableGarages    = GarageUtil.GetAllGarages(player);
                    foreach (var interactableVehicle in VehicleManager.vehicles.Where(interactableVehicle => interactableVehicle.lockedOwner.m_SteamID == player.CSteamID.m_SteamID))
                    {
                        GarageUtil.GarageAddAllChecks(player, interactableVehicle, out var response, out _);
                        switch (response)
                        {
                        case EResponseType.BLACKLIST_BARRICADE:
                        case EResponseType.BLACKLIST_TRUNK_ITEM:
                        case EResponseType.BLACKLIST_VEHICLE:
                            blacklistedVehicles.Add(interactableVehicle);
                            break;

                        case EResponseType.SUCCESS:
                            passedVehicles.Add(interactableVehicle);
                            break;

                        default:
                            throw new ArgumentOutOfRangeException();
                        }
                    }

                    var tupleGarages    = (from garage in availableGarages let garageOccupiedSlot = Plugin.DbManager.GetVehicleCount(player.CSteamID.m_SteamID.ToString(), garage.Name) where garage.Slot > garageOccupiedSlot select new Tuple <GarageModel, uint>(garage, garageOccupiedSlot)).ToList();
                    var vehicleIndex    = 0;
                    var successVehicles = new List <InteractableVehicle>();
                    foreach (var(garage, occupiedSlot) in tupleGarages)
                    {
                        var i = 0;
                        while (i < (garage.Slot - occupiedSlot) && vehicleIndex < passedVehicles.Count)
                        {
                            GarageUtil.SaveVgVehicleToSql(player.CSteamID.m_SteamID, garage.Name,
                                                          passedVehicles[vehicleIndex].asset.name, passedVehicles[vehicleIndex],
                                                          BarricadeManager.getRegionFromVehicle(passedVehicles[vehicleIndex]));
                            successVehicles.Add(passedVehicles[vehicleIndex]);
                            vehicleIndex++;
                            i++;
                        }
                    }

                    caller.SendChat(Plugin.Inst.Translate("rfgarage_command_gadd_all_success",
                                                          vehicleIndex, passedVehicles.Count - vehicleIndex), Plugin.MsgColor, Plugin.Conf.AnnouncerIconUrl);
                    foreach (var vehicle in successVehicles)
                    {
                        caller.SendChat(Plugin.Inst.Translate("rfgarage_command_all_success_vehicle",
                                                              vehicle.asset.id, vehicle.asset.vehicleName), Plugin.MsgColor, Plugin.Conf.AnnouncerIconUrl);
                    }
                    foreach (var vehicle in blacklistedVehicles)
                    {
                        caller.SendChat(Plugin.Inst.Translate("rfgarage_command_gadd_all_blacklist_vehicle",
                                                              vehicle.asset.id, vehicle.asset.vehicleName), Plugin.MsgColor, Plugin.Conf.AnnouncerIconUrl);
                    }
                    passedVehicles.RemoveRange(0, vehicleIndex);
                    foreach (var vehicle in passedVehicles)
                    {
                        caller.SendChat(Plugin.Inst.Translate("rfgarage_command_all_fail_vehicle",
                                                              vehicle.asset.id, vehicle.asset.vehicleName), Plugin.MsgColor, Plugin.Conf.AnnouncerIconUrl);
                    }
                    Plugin.GarageAddAllQueueDict[player.CSteamID] = false;
                    return;
                }

                case "abort":
                    Plugin.GarageAddAllQueueDict[player.CSteamID] = false;

                    caller.SendChat(Plugin.Inst.Translate("rfgarage_command_all_abort"), Plugin.MsgColor, Plugin.Conf.AnnouncerIconUrl);
                    return;
                }

                break;
            }
        }