示例#1
0
        public void Execute(IRocketPlayer caller, string[] command)
        {
            if (command.Length < 1 || command.Length > 2)
            {
                UnturnedChat.Say(caller, Plugin.Inst.Translate("rfgarage_command_invalid_parameter"), Plugin.MsgColor);
                return;
            }

            var player = (UnturnedPlayer)caller;

            switch (command.Length)
            {
            case 1 when !CheckResponse(player, command[0], null):
                return;

            case 1:
            {
                var target  = UnturnedPlayer.FromName(command[0]);
                var garages = GarageUtil.GetAllGarages(target);
                var list    = string.Join(", ", (from t in garages let count = Plugin.DbManager.GetVehicleCount(command[0], t.Name) select $"{t.Name} ({count}/{t.Slot})").ToArray());
                if (!garages.Any())
                {
                    list = "None";
                }
                UnturnedChat.Say(caller, Plugin.Inst.Translate("rfgarage_command_glist_garages_success", list), Plugin.MsgColor);
                return;
            }

            case 2 when !CheckResponse(player, command[0], GarageModel.Parse(command[1])):
                return;

            case 2:
            {
                var garage           = GarageModel.Parse(command[1]);
                var vgVehicles       = Plugin.DbManager.ReadVgVehicleByGarageName(command[0], garage.Name);
                var playerVgVehicles = vgVehicles as PlayerSerializableVehicleModel[] ?? vgVehicles.ToArray();
                foreach (var vgVehicle in playerVgVehicles)
                {
                    var vg    = vgVehicle.Info.ToVgVehicle();
                    var asset = (VehicleAsset)Assets.find(EAssetType.VEHICLE, vg.ID);
                    var list  = $"[Name] {vgVehicle.VehicleName}, [VName] {asset.vehicleName}, [ID] {asset.id}";
                    UnturnedChat.Say(caller, Plugin.Inst.Translate("rfgarage_command_glist_garage_success", garage.Name, list), Plugin.MsgColor);
                }

                break;
            }
            }
        }
        public void Execute(IRocketPlayer caller, string[] command)
        {
            if (command.Length > 1)
            {
                caller.SendChat(Plugin.Inst.Translate("rfgarage_command_invalid_parameter"), Plugin.MsgColor, Plugin.Conf.AnnouncerIconUrl);
                return;
            }

            var player = (UnturnedPlayer)caller;

            switch (command.Length)
            {
            case 0:
            {
                var garages = GarageUtil.GetAllGarages(player);
                var list    = !garages.Any() ? "None" : string.Join(", ", (from t in garages let count = Plugin.DbManager.GetVehicleCount(player.CSteamID.m_SteamID.ToString(), t.Name) select $"{t.Name} ({count}/{t.Slot})").ToArray());
                caller.SendChat(Plugin.Inst.Translate("rfgarage_command_glist_garages_success", list), Plugin.MsgColor, Plugin.Conf.AnnouncerIconUrl);
                return;
            }

            case 1:
            {
                if (!CheckResponse(player, GarageModel.Parse(command[0])))
                {
                    return;
                }
                var garage           = GarageModel.Parse(command[0]);
                var vgVehicles       = Plugin.DbManager.ReadVgVehicleByGarageName(player.CSteamID.m_SteamID.ToString(), garage.Name);
                var playerVgVehicles = vgVehicles as PlayerSerializableVehicleModel[] ?? vgVehicles.ToArray();
                foreach (var vgVehicle in playerVgVehicles)
                {
                    var vg    = vgVehicle.Info.ToVgVehicle();
                    var asset = (VehicleAsset)Assets.find(EAssetType.VEHICLE, vg.ID);
                    var list  = $"[Name] {vgVehicle.VehicleName}, [VName] {asset.vehicleName}, [ID] {asset.id}";
                    caller.SendChat(Plugin.Inst.Translate("rfgarage_command_glist_garage_success", garage.Name, list), Plugin.MsgColor, Plugin.Conf.AnnouncerIconUrl);
                }

                return;
            }

            default:
                caller.SendChat(Plugin.Inst.Translate("rfgarage_command_invalid_parameter"), Plugin.MsgColor, Plugin.Conf.AnnouncerIconUrl);
                break;
            }
        }
示例#3
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;
            }
        }