Exemplo n.º 1
0
        public void Execute(IRocketPlayer caller, string[] command)
        {
            UnturnedPlayer Ucaller = (UnturnedPlayer)caller;
            DateTime       remainingCooldownDatetime;
            ushort         id          = (ushort)giveVehicle.instance.Configuration.Instance.ModHeliId;
            double         maxCooldown = (double)giveVehicle.instance.Configuration.Instance.SpawnCooldown;

            if (!(giveVehicle.IndividualCooldowns.ContainsKey(caller.DisplayName)))
            {
                giveVehicle.IndividualCooldowns.Add(caller.DisplayName, DateTime.Now);
            }

            if (giveVehicle.IndividualCooldowns.TryGetValue(caller.DisplayName, out remainingCooldownDatetime))
            {
                if ((DateTime.Now - remainingCooldownDatetime).TotalSeconds >= maxCooldown || giveVehicle.FirstCommandExecution[caller.DisplayName] == true)
                {
                    if (VehicleTool.giveVehicle(Ucaller.Player, id))
                    {
                        UnturnedChat.Say(Ucaller, giveVehicle.instance.Translations.Instance.Translate("Command_modheli_give_private"), UnityEngine.Color.yellow);
                        giveVehicle.IndividualCooldowns[caller.DisplayName] = DateTime.Now;
                        if (giveVehicle.FirstCommandExecution[caller.DisplayName])
                        {
                            giveVehicle.FirstCommandExecution[caller.DisplayName] = false;
                        }
                    }
                }
                else
                {
                    double cooldown = maxCooldown - (DateTime.Now - remainingCooldownDatetime).TotalSeconds;
                    UnturnedChat.Say(Ucaller, "you have to wait " + (int)cooldown + " seconds to use this command again", UnityEngine.Color.yellow);
                }
            }
        }
Exemplo n.º 2
0
        protected override async UniTask OnExecuteAsync()
        {
            if (Context.Parameters.Length != 1)
            {
                throw new CommandWrongUsageException(Context);
            }

            string vehicleSearchTerm = Context.Parameters[0];

            if (!UnturnedAssetHelper.GetVehicle(vehicleSearchTerm, out VehicleAsset vehicle))
            {
                throw new UserFriendlyException(m_StringLocalizer["vehicle:invalid",
                                                                  new { Vehicle = vehicleSearchTerm }]);
            }

            await UniTask.SwitchToMainThread();

            if (VehicleTool.giveVehicle(((UnturnedUser)Context.Actor).Player.Player, vehicle.id))
            {
                await Context.Actor.PrintMessageAsync(m_StringLocalizer["vehicle:success",
                                                                        new { Vehicle = vehicle.vehicleName }]);
            }
            else
            {
                throw new UserFriendlyException(m_StringLocalizer["vehicle:failure"]);
            }
        }
Exemplo n.º 3
0
        protected override async UniTask OnExecuteAsync()
        {
            if (Context.Parameters.Length != 2)
            {
                throw new CommandWrongUsageException(Context);
            }

            string playerSearchTerm = Context.Parameters[0];

            if (!PlayerTool.tryGetSteamPlayer(playerSearchTerm, out SteamPlayer recipient))
            {
                throw new UserFriendlyException(m_StringLocalizer["vehicle:invalid_player", new { Player = playerSearchTerm }]);
            }

            string vehicleSearchTerm = Context.Parameters[1];

            if (!UnturnedAssetHelper.GetVehicle(vehicleSearchTerm, out VehicleAsset vehicle))
            {
                throw new UserFriendlyException(m_StringLocalizer["vehicle:invalid",
                                                                  new { Vehicle = vehicleSearchTerm }]);
            }

            await UniTask.SwitchToMainThread();

            if (VehicleTool.giveVehicle(recipient.player, vehicle.id))
            {
                await Context.Actor.PrintMessageAsync(m_StringLocalizer["vehicle:success_given",
                                                                        new { Vehicle = vehicle.vehicleName, Player = recipient.playerID.characterName }]);
            }
            else
            {
                throw new UserFriendlyException(m_StringLocalizer["vehicle:failure"]);
            }
        }
Exemplo n.º 4
0
        public void Execute(IRocketPlayer caller, string[] command)
        {
            UnturnedPlayer player = (UnturnedPlayer)caller;

            if (command.Length != 1)
            {
                UnturnedChat.Say(caller, U.Translate("command_generic_invalid_parameter"));
                throw new WrongUsageOfCommandException(caller, this);
            }

            ushort?id = command.GetUInt16Parameter(0);

            if (!id.HasValue)
            {
                string itemString = command.GetStringParameter(0);

                if (itemString == null)
                {
                    UnturnedChat.Say(caller, U.Translate("command_generic_invalid_parameter"));
                    throw new WrongUsageOfCommandException(caller, this);
                }

                Asset[] assets = SDG.Unturned.Assets.find(EAssetType.VEHICLE);
                foreach (VehicleAsset ia in assets)
                {
                    if (ia != null && ia.vehicleName != null && ia.vehicleName.ToLower().Contains(itemString.ToLower()))
                    {
                        id = ia.id;
                        break;
                    }
                }
                if (!id.HasValue)
                {
                    UnturnedChat.Say(caller, U.Translate("command_generic_invalid_parameter"));
                    throw new WrongUsageOfCommandException(caller, this);
                }
            }

            Asset  a         = SDG.Unturned.Assets.find(EAssetType.VEHICLE, id.Value);
            string assetName = ((VehicleAsset)a).vehicleName;

            if (U.Settings.Instance.EnableVehicleBlacklist && !player.HasPermission("vehicleblacklist.bypass"))
            {
                if (player.HasPermission("vehicle." + id))
                {
                    UnturnedChat.Say(caller, U.Translate("command_v_blacklisted"));
                    return;
                }
            }

            if (VehicleTool.giveVehicle(player.Player, id.Value))
            {
                Logger.Log(U.Translate("command_v_giving_console", player.CharacterName, id));
                UnturnedChat.Say(caller, U.Translate("command_v_giving_private", assetName, id));
            }
            else
            {
                UnturnedChat.Say(caller, U.Translate("command_v_giving_failed_private", assetName, id));
            }
        }
Exemplo n.º 5
0
        public override CommandResult OnExecute(ICommandSource src, ICommandArgs args)
        {
            if (args.Length == 2)
            {
                var vehId = args[0];

                if (!args[1].IsValidPlayerIdentifier)
                {
                    return(CommandResult.LangError("PLAYER_NOT_FOUND", args[1]));
                }

                var target = args[1].ToPlayer;

                if (!vehId.IsUShort || !IsValidVehicleId(vehId.ToUShort))
                {
                    EssLang.Send(src, "INVALID_VEHICLE_ID", vehId);
                }
                else
                {
                    VehicleTool.giveVehicle(target.UnturnedPlayer, vehId.ToUShort);
                    EssLang.Send(src, "SPAWNED_VEHICLE_AT_PLAYER", args[1]);
                }
            }
            else if (args.Length == 4)
            {
                var pos   = args.GetVector3(1);
                var vehId = args[0];

                if (pos.HasValue)
                {
                    var pVal = pos.Value;

                    if (!vehId.IsUShort || !IsValidVehicleId(vehId.ToUShort))
                    {
                        return(CommandResult.LangError("INVALID_VEHICLE_ID", vehId));
                    }

                    SpawnVehicle(pVal, vehId.ToUShort);
                    EssLang.Send(src, "SPAWNED_VEHICLE_AT_POSITION", pVal.x, pVal.y, pVal.z);
                }
                else
                {
                    return(CommandResult.LangError("INVALID_COORDS", args[1], args[2], args[3]));
                }
            }
            else
            {
                return(CommandResult.ShowUsage());
            }

            return(CommandResult.Success());
        }
Exemplo n.º 6
0
        public override CommandResult OnExecute(ICommandSource src, ICommandArgs args)
        {
            if (args.Length == 2)
            {
                var target = UPlayer.From(args[1].ToString());
                var vehId  = args[0];

                if (target == null)
                {
                    return(CommandResult.Lang(EssLang.PLAYER_NOT_FOUND, args[1]));
                }

                if (!vehId.IsUshort || !IsValidVehicleId(vehId.ToUshort))
                {
                    EssLang.INVALID_VEHICLE_ID.SendTo(src, vehId);
                }
                else
                {
                    VehicleTool.giveVehicle(target.UnturnedPlayer, vehId.ToUshort);
                    EssLang.SPAWNED_VEHICLE_AT_PLAYER.SendTo(src, args[1]);
                }
            }
            else if (args.Length == 4)
            {
                var pos   = args.GetVector3(1);
                var vehId = args[0];

                if (pos.HasValue)
                {
                    var pVal = pos.Value;

                    if (!vehId.IsUshort || !IsValidVehicleId(vehId.ToUshort))
                    {
                        return(CommandResult.Lang(EssLang.INVALID_VEHICLE_ID, vehId));
                    }

                    SpawnVehicle(pVal, vehId.ToUshort);
                    EssLang.SPAWNED_VEHICLE_AT_POSITION.SendTo(src, pVal.x, pVal.y, pVal.z);
                }
                else
                {
                    return(CommandResult.Lang(EssLang.INVALID_COORDS, args[1], args[2], args[3]));
                }
            }
            else
            {
                return(CommandResult.ShowUsage());
            }

            return(CommandResult.Success());
        }
Exemplo n.º 7
0
        public void Execute(IRocketPlayer caller, string[] command)
        {
            UnturnedPlayer player = (UnturnedPlayer)caller;

            if (command.Length != 1)
            {
                UnturnedChat.Say(caller, U.Translate("command_generic_invalid_parameter"));
                return;
            }

            ushort?id = command.GetUInt16Parameter(0);

            if (!id.HasValue)
            {
                string itemString = command.GetStringParameter(0);

                if (itemString == null)
                {
                    UnturnedChat.Say(caller, U.Translate("command_generic_invalid_parameter"));
                    return;
                }

                Asset[] assets = SDG.Unturned.Assets.find(EAssetType.VEHICLE);
                foreach (VehicleAsset ia in assets)
                {
                    if (ia != null && ia.Name != null && ia.Name.ToLower().Contains(itemString.ToLower()))
                    {
                        id = ia.Id;
                        break;
                    }
                }
            }

            Asset  a         = SDG.Unturned.Assets.find(EAssetType.VEHICLE, id.Value);
            string assetName = ((VehicleAsset)a).Name;

            if (VehicleTool.giveVehicle(player.Player, id.Value))
            {
                Logger.Log(U.Translate("command_v_giving_console", player.CharacterName, id));
                UnturnedChat.Say(caller, U.Translate("command_v_giving_private", assetName, id));
            }
            else
            {
                UnturnedChat.Say(caller, U.Translate("command_v_giving_failed_private", assetName, id));
            }
        }
Exemplo n.º 8
0
        public void Execute(ICommandContext context)
        {
            ITranslationCollection translations = ((RocketUnturnedHost)context.Container.Resolve <IHost>()).ModuleTranslations;

            UnturnedPlayer player = (UnturnedPlayer)context.Player;

            if (context.Parameters.Length != 1)
            {
                throw new CommandWrongUsageException();
            }

            string param = context.Parameters.Get <string>(0);

            if (!ushort.TryParse(param, out ushort id))
            {
                bool    found  = false;
                Asset[] assets = SDG.Unturned.Assets.find(EAssetType.VEHICLE);
                foreach (VehicleAsset ia in assets)
                {
                    if (ia?.vehicleName == null || !ia.vehicleName.ToLower().Contains(param.ToLower()))
                    {
                        continue;
                    }

                    id    = ia.id;
                    found = true;
                    break;
                }

                if (!found)
                {
                    throw new CommandWrongUsageException();
                }
            }

            Asset  a         = Assets.find(EAssetType.VEHICLE, id);
            string assetName = ((VehicleAsset)a).vehicleName;

            context.User.SendLocalizedMessage(translations, VehicleTool.giveVehicle(player.NativePlayer, id)
                    ? "command_v_giving_private"
                    : "command_v_giving_failed_private", null, assetName, id);
        }
        public override void Execute(PointBlankPlayer executor, string[] args)
        {
            VehicleAsset vehicle;

            if (!ushort.TryParse(args[0], out ushort id))
            {
                VehicleAsset[] vehicles = Assets.find(EAssetType.VEHICLE) as VehicleAsset[];

                vehicle = vehicles.Where(a => a != null).OrderBy(a => a.vehicleName.Length).FirstOrDefault(a => a.vehicleName.ToLower().Contains(args[0].ToLower()));
            }
            else
            {
                vehicle = Assets.find(EAssetType.VEHICLE, id) as VehicleAsset;
            }
            if (vehicle == null)
            {
                UnturnedChat.SendMessage(executor, Translations["Vehicle_Invalid"], ConsoleColor.Red);
                return;
            }

            if (args.Length < 2 || UnturnedPlayer.TryGetPlayer(args[1], out UnturnedPlayer ply))
            {
                if (executor == null)
                {
                    UnturnedChat.SendMessage(executor, Translations["Base_InvalidPlayer"], ConsoleColor.Red);
                    return;
                }

                ply = (UnturnedPlayer)executor;
            }
            if (!VehicleTool.giveVehicle(ply.Player, vehicle.id))
            {
                UnturnedChat.SendMessage(executor, string.Format(Translations["Vehicle_Fail"], vehicle.vehicleName), ConsoleColor.Red);
                return;
            }
            UnturnedChat.SendMessage(executor, string.Format(Translations["Vehicle_Spawn"], vehicle.vehicleName), ConsoleColor.Green);
        }
Exemplo n.º 10
0
        public override void Execute(IRocketPlayer caller, CommandArgs args)
        {
            UnturnedPlayer player = (UnturnedPlayer)caller;

            if (args.Count != 1)
            {
                UnturnedChat.Say(caller, U.Translate("command_generic_invalid_parameter"));
                throw new WrongUsageOfCommandException(caller, this);
            }

            if (args[0].IsVehicle(out VehicleAsset vehicleAsset))
            {
                if (U.Settings.Instance.EnableVehicleBlacklist && !player.HasPermission("vehicleblacklist.bypass"))
                {
                    if (player.HasPermission("vehicle." + vehicleAsset.id))
                    {
                        UnturnedChat.Say(caller, U.Translate("command_v_blacklisted"));
                        return;
                    }
                }

                if (VehicleTool.giveVehicle(player.Player, vehicleAsset.id))
                {
                    Logger.Log(U.Translate("command_v_giving_console", player.CharacterName, vehicleAsset.id));
                    UnturnedChat.Say(caller, U.Translate("command_v_giving_private", vehicleAsset.vehicleName, vehicleAsset.id));
                }
                else
                {
                    UnturnedChat.Say(caller, U.Translate("command_v_giving_failed_private", vehicleAsset.vehicleName, vehicleAsset.id));
                }
            }
            else
            {
                UnturnedChat.Say(caller, U.Translate("command_generic_invalid_parameter"));
                throw new WrongUsageOfCommandException(caller, this);
            }
        }
Exemplo n.º 11
0
 public override bool GiveTo(UPlayer player, bool dropIfInventoryFull = true)
 {
     VehicleTool.giveVehicle(player.UnturnedPlayer, Id);
     return(true);
 }
Exemplo n.º 12
0
 public bool GiveVehicle(ushort id)
 {
     return(VehicleTool.giveVehicle(Player, id));
 }
Exemplo n.º 13
0
        private CommandResult VehicleCommand(ICommandSource src, ICommandArgs args, ICommand cmd)
        {
            switch (args.Length)
            {
            case 1:
                if (src.IsConsole)
                {
                    return(CommandResult.ShowUsage());
                }

                var optAsset = VehicleUtil.GetVehicle(args[0].ToString());

                if (optAsset.IsAbsent)
                {
                    return(CommandResult.Lang("INVALID_VEHICLE_ID", args[0]));
                }

                var id = optAsset.Value.id;

                if (UEssentials.Config.VehicleBlacklist.Contains(id) &&
                    !src.HasPermission("essentials.bypass.blacklist.vehicle"))
                {
                    return(CommandResult.Lang("BLACKLISTED_VEHICLE", $"{optAsset.Value.vehicleName} ({id})"));
                }

                VehicleTool.giveVehicle(src.ToPlayer().UnturnedPlayer, id);

                EssLang.Send(src, "RECEIVED_VEHICLE", optAsset.Value.vehicleName, id);
                break;

            case 2:
                if (!src.HasPermission($"{cmd.Permission}.other"))
                {
                    return(CommandResult.Lang("COMMAND_NO_PERMISSION"));
                }

                optAsset = VehicleUtil.GetVehicle(args[1].ToString());

                if (optAsset.IsAbsent)
                {
                    return(CommandResult.Lang("INVALID_VEHICLE_ID", args[1]));
                }

                var vehAsset = optAsset.Value;

                if (args[0].Equals("*"))
                {
                    UServer.Players.ForEach(p => {
                        VehicleTool.giveVehicle(p.UnturnedPlayer, vehAsset.id);
                    });

                    EssLang.Send(src, "GIVEN_VEHICLE_ALL", vehAsset.vehicleName, vehAsset.id);
                }
                else if (!args[0].IsValidPlayerIdentifier)
                {
                    return(CommandResult.Lang("PLAYER_NOT_FOUND", args[0]));
                }
                else
                {
                    var target = args[0].ToPlayer;
                    VehicleTool.giveVehicle(target.UnturnedPlayer, vehAsset.id);

                    EssLang.Send(src, "GIVEN_VEHICLE", vehAsset.vehicleName, vehAsset.id, target.DisplayName);
                }
                break;

            default:
                return(CommandResult.ShowUsage());
            }

            return(CommandResult.Success());
        }
Exemplo n.º 14
0
        public void Execute(IRocketPlayer caller, string[] command)
        {
            if (command.Length != 1)
            {
                UnturnedChat.Say(caller, Plugin.Inst.Translate("command_generic_v_invalid_parameter"), Plugin.MsgColor);
                return;
            }

            var    player      = (UnturnedPlayer)caller;
            var    msg         = command[0];
            string vehicleName = null;

            if (!ushort.TryParse(msg, out var id))
            {
                var array = Assets.find(EAssetType.VEHICLE);

                var vAsset = array.Cast <VehicleAsset>()
                             .FirstOrDefault(k => k?.vehicleName?.ToLower().Contains(command[0].ToLower()) == true);

                if (vAsset == null)
                {
                    UnturnedChat.Say(player, Plugin.Inst.Translate("command_generic_v_invalid_parameter"), Plugin.MsgColor);
                    return;
                }

                id          = vAsset.id;
                vehicleName = vAsset.vehicleName;
            }

            if (Assets.find(EAssetType.VEHICLE, id) == null)
            {
                UnturnedChat.Say(player, Plugin.Inst.Translate("command_generic_v_invalid_parameter"), Plugin.MsgColor);
                return;
            }

            if (vehicleName == null && id != 0)
            {
                vehicleName = ((VehicleAsset)Assets.find(EAssetType.VEHICLE, id)).vehicleName;
            }

            if (Plugin.Conf.Restrictions.Any(g => Plugin.Conf.UseGroupInsteadOfPermission ? Plugin.PlayerHasGroup(caller, g) : Plugin.PlayerHasPermission(caller, g) &&
                                             g.BlackListVehicles.Any(i => i.ID == id)) &&
                !player.HasPermission(Plugin.Conf.VehicleBlacklistBypassPermission))
            {
                UnturnedChat.Say(player, Plugin.Inst.Translate("command_v_blacklisted"), Plugin.MsgColor);
                return;
            }

            var playerCooldown = Plugin.Inst.Database.GetInternal(player.CSteamID.m_SteamID);

            if (!player.HasPermission(Plugin.Conf.VehicleCooldownBypassPermission) && playerCooldown.LastVehicleCommand.HasValue)
            {
                var cooldown = Plugin.Conf.Restrictions[0].VehicleCooldown;
                foreach (var g in Plugin.Conf.Restrictions.Where(g => Plugin.Conf.UseGroupInsteadOfPermission ? Plugin.PlayerHasGroup(caller, g) : Plugin.PlayerHasPermission(caller, g)).Where(g => g.ItemCooldown < cooldown))
                {
                    cooldown = g.VehicleCooldown;
                }
                var secondsElapsed = (DateTime.Now - playerCooldown.LastVehicleCommand.Value).TotalSeconds;
                var timeLeft       = Math.Round(cooldown - secondsElapsed);
                if (secondsElapsed < cooldown)
                {
                    UnturnedChat.Say(caller, Plugin.Inst.Translate("command_cooldown", timeLeft), Plugin.MsgColor);
                    return;
                }
            }

            if (VehicleTool.giveVehicle(player.Player, id))
            {
                Logger.Log(U.Translate("command_v_giving_console", player.CharacterName,
                                       id.ToString()));
                UnturnedChat.Say(caller, Plugin.Inst.Translate("command_v_giving_private",
                                                               vehicleName, id.ToString()), Plugin.MsgColor);
                playerCooldown.LastVehicleCommand = DateTime.Now;
                Plugin.Inst.Database.Update(player.CSteamID.m_SteamID);
            }
            else
            {
                UnturnedChat.Say(caller, Plugin.Inst.Translate("command_v_giving_failed_private",
                                                               vehicleName, id.ToString()), Plugin.MsgColor);
            }
        }
Exemplo n.º 15
0
        public void Execute(IRocketPlayer caller, string[] command)
        {
            UnturnedPlayer Player = (UnturnedPlayer)caller;

            if (command.Length != 1)
            {
                UnturnedChat.Say(caller, U.Translate("command_generic_invalid_parameter"));
                throw new WrongUsageOfCommandException(caller, this);
            }

            ushort?      VehicleID    = command.GetUInt16Parameter(0);
            VehicleAsset VehicleMatch = null;

            if (!VehicleID.HasValue)
            {
                string VehicleString = command.GetStringParameter(0);

                if (VehicleString == null)
                {
                    UnturnedChat.Say(caller, U.Translate("command_generic_invalid_parameter"));
                    throw new WrongUsageOfCommandException(caller, this);
                }

                VehicleMatch = Assets.find(EAssetType.VEHICLE).Cast <VehicleAsset>()
                               .Where(veh => !String.IsNullOrEmpty(veh.vehicleName))
                               .FirstOrDefault(veh => veh.vehicleName.ToUpperInvariant().Contains(VehicleString.ToUpperInvariant()));

                if (VehicleMatch != null)
                {
                    VehicleID = VehicleMatch.id;
                }

                if (!VehicleID.HasValue)
                {
                    UnturnedChat.Say(caller, U.Translate("command_generic_invalid_parameter"));
                    throw new WrongUsageOfCommandException(caller, this);
                }
            }

            VehicleMatch ??= (VehicleAsset)Assets.find(EAssetType.VEHICLE, VehicleID.Value);

            if (!SpawnPermissions.Instance.CheckPermission(false, VehicleMatch.id, Player, out bool WaiveCooldwons))
            {
                UnturnedChat.Say(caller, SpawnPermissions.Instance.Translate("vehicle_denied", VehicleMatch.id, VehicleMatch.vehicleName));

                if (WaiveCooldwons)
                {
                    throw new WrongUsageOfCommandException(caller, this);
                }

                return;
            }

            if (VehicleTool.giveVehicle(Player.Player, VehicleMatch.id))
            {
                Logger.Log(U.Translate("command_v_giving_console", Player.CharacterName, VehicleMatch.id));
                UnturnedChat.Say(caller, U.Translate("command_v_giving_private", VehicleMatch.vehicleName, VehicleMatch.id));
            }
            else
            {
                UnturnedChat.Say(caller, U.Translate("command_v_giving_failed_private", VehicleMatch.vehicleName, VehicleMatch.id));
            }
        }
Exemplo n.º 16
0
 public bool GiveVehicle(ushort vehicleId) => VehicleTool.giveVehicle(NativePlayer, vehicleId);
Exemplo n.º 17
0
        public void Execute(IRocketPlayer caller, string[] command)
        {
            if (command.Length == 0)
            {
                UnturnedChat.Say(caller, "incorrect usage! Correct usage: " + Syntax);
                return;
            }

            List <InteractableVehicle> foundVehicles = new List <InteractableVehicle>();
            UnturnedPlayer             player        = (UnturnedPlayer)caller;

            if (command.Length != 1)
            {
                UnturnedChat.Say(caller, U.Translate("command_generic_invalid_parameter"));
                throw new WrongUsageOfCommandException(caller, this);
            }

            ushort?id = command.GetUInt16Parameter(0);

            if (!id.HasValue)
            {
                string itemString = command.GetStringParameter(0);

                if (itemString == null)
                {
                    UnturnedChat.Say(caller, U.Translate("command_generic_invalid_parameter"));
                    throw new WrongUsageOfCommandException(caller, this);
                }

                Asset[] assets = SDG.Unturned.Assets.find(EAssetType.VEHICLE);
                foreach (VehicleAsset ia in assets)
                {
                    if (ia != null && ia.vehicleName != null && ia.vehicleName.ToLower().Contains(itemString.ToLower()))
                    {
                        id = ia.id;
                        break;
                    }
                }
                if (!id.HasValue)
                {
                    UnturnedChat.Say(caller, U.Translate("command_generic_invalid_parameter"));
                    throw new WrongUsageOfCommandException(caller, this);
                }
            }

            Asset  a         = SDG.Unturned.Assets.find(EAssetType.VEHICLE, id.Value);
            string assetName = ((VehicleAsset)a).vehicleName;

            // see if blacklist is enabled
            if (AutoClear.AutoClear.Instance.Configuration.Instance.BlacklistEnabled && !caller.HasPermission("bypassvehicleblacklist"))
            {
                //check if the entered vehicle is blacklisted
                if (AutoClear.AutoClear.Instance.Configuration.Instance.BlacklsitedVehicleIds.Contains(id.Value.ToString()))
                {
                    UnturnedChat.Say(caller, "The vehicle \"" + assetName + "\" ID: " + id.Value.ToString() + " is Blacklisted!");
                    return;
                }
            }

            if (VehicleTool.giveVehicle(player.Player, id.Value))
            {
                VehicleManager.getVehiclesInRadius(((UnturnedPlayer)caller).Position,
                                                   AutoClear.AutoClear.Instance.Configuration.Instance.Radius, foundVehicles);
                for (int j = foundVehicles.Count - 1; j >= 0; j--)
                {
                    if (!AutoClear.AutoClear.VehicleData.ContainsKey(foundVehicles[j]))
                    {
                        AutoClear.AutoClear.VehicleData.Add(foundVehicles[j], DateTime.Now);
                    }
                }
                Logger.Log(AutoClear.AutoClear.Instance.Translate("command_v_giving_console", player.CharacterName, id, assetName));
                UnturnedChat.Say(caller, U.Translate("command_v_giving_private", assetName, id));
            }
            else
            {
                UnturnedChat.Say(caller, U.Translate("command_v_giving_failed_private", assetName, id));
            }
        }
Exemplo n.º 18
0
 public bool GiveVehicle(ushort vehicleId)
 {
     return(VehicleTool.giveVehicle(player, vehicleId));
 }
Exemplo n.º 19
0
        public void Execute(IRocketPlayer caller, string[] command)
        {
            UnturnedPlayer player = (UnturnedPlayer)caller;

            if (command.Length != 1)
            {
                UnturnedChat.Say(caller, U.Translate("command_generic_invalid_parameter"));
                throw new WrongUsageOfCommandException(caller, (IRocketCommand)this);
            }
            ushort?nullable = command.GetUInt16Parameter(0);

            if (!nullable.HasValue)
            {
                string stringParameter = command.GetStringParameter(0);
                if (stringParameter == null)
                {
                    UnturnedChat.Say(caller, U.Translate("command_generic_invalid_parameter"));
                    throw new WrongUsageOfCommandException(caller, (IRocketCommand)this);
                }
                foreach (VehicleAsset vehicleAsset in Assets.find(EAssetType.VEHICLE))
                {
                    if (vehicleAsset != null && vehicleAsset.vehicleName != null && vehicleAsset.vehicleName.ToLower().Contains(stringParameter.ToLower()))
                    {
                        nullable = new ushort?(vehicleAsset.id);
                        break;
                    }
                }
                if (!nullable.HasValue)
                {
                    UnturnedChat.Say(caller, U.Translate("command_generic_invalid_parameter"));
                    throw new WrongUsageOfCommandException(caller, (IRocketCommand)this);
                }
            }
            string vehicleName = ((VehicleAsset)Assets.find(EAssetType.VEHICLE, nullable.Value)).vehicleName;

            //if (U.Settings.Instance.EnableVehicleBlacklist && !player.HasPermission("vehicleblacklist.bypass") && player.HasPermission("vehicle." + (object)nullable))
            //    UnturnedChat.Say(caller, U.Translate("command_v_blacklisted"));

            //foreach (var group in ItemRestrictor._instance.Configuration.Instance.Groups)// checking id for blacklist    OLD SCHOOL BY M22
            //{
            //    if (ItemRestrictor.IsPlayersGroup(caller, group) && group.BlackListVehicles.Contains((ushort)nullable))
            //    {
            //        UnturnedChat.Say((IRocketPlayer)player, U.Translate("command_v_blacklisted"));
            //        return;
            //    }
            //}

            if (ItemRestrictor._instance.Configuration.Instance.Groups.Any(g => ItemRestrictor.IsPlayersGroup(caller, g) && // NEW SCHOOL EXPLAINED BY DAEMONN
                                                                           g.BlackListVehicles.Contains((ushort)nullable)))
            {
                UnturnedChat.Say((IRocketPlayer)player, U.Translate("command_v_blacklisted"));
                return;
            }

            if (VehicleTool.giveVehicle(player.Player, nullable.Value))
            {
                Logger.Log(U.Translate("command_v_giving_console", (object)player.CharacterName, (object)nullable), ConsoleColor.White);
                UnturnedChat.Say(caller, U.Translate("command_v_giving_private", (object)vehicleName, (object)nullable));
            }
            else
            {
                UnturnedChat.Say(caller, U.Translate("command_v_giving_failed_private", (object)vehicleName, (object)nullable));
            }
        }