Example #1
0
        public ushort GetMagId(UnturnedPlayer player, SDG.Unturned.ItemGunAsset gun, string[] command)
        {
            ushort magId = 0;

            if (command.Length == 2 || command.Length == 1)
            {
                if (command.Length == 1)
                {
                    if (command[0].ToLower() == "c")
                    {
                        magId = player.Player.equipment.state[8];
                    }
                }
                else if (command.Length == 2)
                {
                    if (command[1].ToLower() == "c")
                    {
                        magId = player.Player.equipment.state[8];
                    }
                }
            }

            if (magId == 0 || UnturnedItems.GetItemAssetById(magId).type != EItemType.MAGAZINE)
            {
                magId = gun.getMagazineID();
            }

            return(magId);
        }
Example #2
0
        private void IR_ItemAdded(UnturnedPlayer player, InventoryGroup inventoryGroup, byte inventoryIndex, ItemJar P)
        {
            if ((!player.IsAdmin ? true : !Configuration.Instance.IRIgnoreAdmin))
            {
                foreach (UItem item in Configuration.Instance.Items)
                {
                    if (item.ID == P.item.id)
                    {
                        ExecuteDependencyCode("Uconomy", (IRocketPlugin plugin) =>
                        {
                            Uconomy Uconomy = (Uconomy)plugin;
                            Uconomy.Database.IncreaseBalance(player.CSteamID.ToString(), item.Money.Value);
                        });

                        while (true)
                        {
                            if (!RemoveItem(player, P.item.id))
                            {
                                break;
                            }
                        }
                        UnturnedChat.Say(player, Translate("item_notPermitted", UnturnedItems.GetItemAssetById(item.ID).itemName, item.Money.Value), UnturnedChat.GetColorFromName(Configuration.Instance.ItemRemoveColor, UnityEngine.Color.red));
                    }
                }
            }
        }
Example #3
0
        public void DropMagsWithLimit(ushort ammoAmountToSpawn, IRocketPlayer caller, SDG.Unturned.ItemGunAsset currentWeapon, UnturnedPlayer Uplayer, string[] command)
        {
            if (ammoAmountToSpawn <= (ushort)EasyAmmo.Instance.Configuration.Instance.ClipLimit || caller.HasPermission("easyammo.bypasslimit"))
            {
                UnturnedChat.Say(caller, EasyAmmo.Instance.Translate("dropping_mags", ammoAmountToSpawn.ToString(), UnturnedItems.GetItemAssetById(GetMagId(Uplayer, currentWeapon, command)).name, GetMagId(Uplayer, currentWeapon, command).ToString()));

                for (int ii = 0; ii < (int)ammoAmountToSpawn; ii++)
                {
                    ItemManager.dropItem(new Item(GetMagId(Uplayer, currentWeapon, command), true), Uplayer.Position, true, true, true);
                }
            }
            else
            {
                UnturnedItems.GetItemAssetById(1);
                ushort amountoverlimit = ammoAmountToSpawn;
                ammoAmountToSpawn = (ushort)EasyAmmo.Instance.Configuration.Instance.ClipLimit;

                UnturnedChat.Say(caller, EasyAmmo.Instance.Translate("over_clip_spawn_limit_dropping", amountoverlimit.ToString(), EasyAmmo.Instance.Configuration.Instance.ClipLimit, UnturnedItems.GetItemAssetById(GetMagId(Uplayer, currentWeapon, command)).name, GetMagId(Uplayer, currentWeapon, command).ToString()));

                for (int ii = 0; ii < (int)ammoAmountToSpawn; ii++)
                {
                    ItemManager.dropItem(new Item(GetMagId(Uplayer, currentWeapon, command), true), Uplayer.Position, true, true, true);
                }
            }
        }
        public void Execute(IRocketPlayer caller, string[] command)
        {
            ushort AmountToSpawn = (ushort)0;

            SDG.Unturned.ItemAsset currentEquiped;
            UnturnedPlayer         Uplayer = (UnturnedPlayer)caller;

            currentEquiped = Uplayer.Player.equipment.asset;
            if (currentEquiped == null)
            {
                UnturnedChat.Say(caller, EasyAmmo.Instance.Translate("nothing_equipped"));
                return;
            }

            if (checkIfBlacklisted(caller, currentEquiped))
            {
                UnturnedChat.Say(EasyAmmo.Instance.Translate("Clonei_item_blacklisted", currentEquiped.name));
                return;
            }

            var state = Uplayer.Player.equipment.state;

            /* for (int count = 0; count <= state.Length - 1; count++)
             * {
             *   Logger.Log("State " + count.ToString() + " : " + state[count].ToString());
             *   //state[count] = 17;
             * }  */
            /*
             * state[0] is a sight
             * state[8] is a magazine
             * state[10] is ammo count
             */

            SDG.Unturned.Item newItem = new SDG.Unturned.Item(currentEquiped.id, 100, 100, state);

            if (AmountToSpawn == 0)
            {
                AmountToSpawn = 1;
            }

            if (caller.HasPermission("clonei.amount"))
            {
                for (int ii = 0; ii < AmountToSpawn; ii++)
                {
                    Uplayer.GiveItem(newItem);
                }
            }
            else
            {
                Uplayer.GiveItem(newItem);
            }

            UnturnedChat.Say(caller, EasyAmmo.Instance.Translate("cloned_item",
                                                                 UnturnedItems.GetItemAssetById(currentEquiped.id).itemName, AmountToSpawn.ToString()));
            return;
        }
        public void Execute(IRocketPlayer caller, string[] command)
        {
            UnturnedPlayer uplayer = (UnturnedPlayer)caller;
            //bool enterNumber = false;
            //int enteredAmount = 0;
            int       magsRemoved = 0;
            ItemAsset uItem       = null;

            /*   if (command.Length == 1)
             * {
             *     if (int.TryParse(command[0], out enteredAmount))
             *     {
             *         enterNumber = true;
             *     }
             * } */

            // this section of code is referenced from LeeIzaZombie's itemRestriction plugin here - https://dev.rocketmod.net/plugins/item-restrictions/
            //original code  - https://bitbucket.org/LeeIzaZombie/rocketmod_itemrestrictions/src/9646f79a3c4f051551cd209a9c86e8ee0ea0e829/RocketMod_ItemRestriction/IR_Plugin.cs?at=master&fileviewer=file-view-default

            PlayerInventory inventory = uplayer.Player.inventory;

            for (byte page = 0; page < 8; page++)
            {
                byte amountOfItems = inventory.getItemCount(page);
                for (int index = amountOfItems - 1; index >= 0; index--)
                {
                    try
                    {
                        uItem = UnturnedItems.GetItemAssetById(inventory.getItem(page, (byte)index).item.id);
                    }
                    catch (Exception)
                    {
                        //Logger.LogError("Error trying to get item at Page: " + page + " Index: " + index);
                    }

                    if (uItem != null)
                    {
                        if (uItem.type == EItemType.MAGAZINE)
                        {
                            // Logger.Log("removing id " + uItem.Id.ToString());
                            inventory.removeItem(page, (byte)index);

                            /* Logger.LogWarning("removed: " + uItem.id.ToString() + "from: " + "Page-" + page.ToString()
                             + " index-" + index.ToString()); */
                            magsRemoved++;
                        }
                    }

                    uItem = null;
                }
            }

            UnturnedChat.Say(caller, EasyAmmo.Instance.Translate("removed_mags", magsRemoved.ToString()));
        }
        public void DropMags(ushort ammoAmountToSpawn, IRocketPlayer caller, ItemGunAsset currentWeapon,
                             UnturnedPlayer uPlayer, string[] command)
        {
            UnturnedChat.Say(caller,
                             EasyAmmo.Instance.Translate("dropping_mags", ammoAmountToSpawn.ToString(),
                                                         UnturnedItems.GetItemAssetById(GetMagId(uPlayer, currentWeapon, command)).name,
                                                         GetMagId(uPlayer, currentWeapon, command).ToString()));

            for (int ii = 0; ii < (int)ammoAmountToSpawn; ii++)
            {
                ItemManager.dropItem(new Item(GetMagId(uPlayer, currentWeapon, command), true), uPlayer.Position, true,
                                     true, true);
            }
        }
        private void IR_ItemAdded(UnturnedPlayer player, InventoryGroup inventoryGroup, byte inventoryIndex, ItemJar p)
        {
            WriteTraceMessage("in event handler");

            WriteTraceMessage(string.Format("Player {0}, IsAdmin = {1}", player.DisplayName, player.IsAdmin));

            if (player.IsAdmin && Configuration.Instance.IgnoreAdmin)
            {
                return;
            }

            var permissions = player.GetPermissions();

            foreach (var permission in permissions)
            {
                if (permission.Name == PermissionIgnoreRetrictions)
                {
                    WriteTraceMessage(string.Format("Player {0}, HasPermission {1}",
                                                    player.DisplayName,
                                                    PermissionIgnoreRetrictions));
                    return;
                }
            }

            foreach (Item item in Configuration.Instance.RestrictedItems)
            {
                if (item.ID == p.Item.ItemID)
                {
                    WriteTraceMessage(string.Format("Player just received forbidden item {0}", item.ID));

                    while (true)
                    {
                        /*  If we remove an item, we may blow up if we keep rummaging because the
                         *  items in the pages may shift position/count in their data structures.
                         *  best to rescan until no more contraband is found.
                         */
                        if (!RemoveContraband(player, p.item.ItemID))
                        {
                            break;
                        }
                    }
                    UnturnedChat.Say(
                        player,
                        Translate("item_notPermitted", UnturnedItems.GetItemAssetById(p.item.ItemID).name),
                        Color.red
                        );
                }
            }
        }
Example #8
0
 public void SpawnMags(ushort ammoAmountToSpawn, IRocketPlayer caller, ItemGunAsset currentWeapon,
                       UnturnedPlayer uPlayer, string[] command)
 {
     if (uPlayer.GiveItem(GetMagId(uPlayer, currentWeapon, command), (byte)ammoAmountToSpawn))
     {
         UnturnedChat.Say(caller,
                          EasyAmmo.Instance.Translate("giving_mags", ammoAmountToSpawn.ToString(),
                                                      UnturnedItems.GetItemAssetById(GetMagId(uPlayer, currentWeapon, command)).name,
                                                      GetMagId(uPlayer, currentWeapon, command).ToString()));
     }
     else
     {
         UnturnedChat.Say(caller, EasyAmmo.Instance.Translate("failed_to_spawn_mags"));
     }
 }
Example #9
0
 public void FixedUpdate()
 {
     if (Level.isLoaded && Provider.clients.Count > 0 && Instance.Configuration.Instance.EnableInvRestrictedItemCheck)
     {
         // begin restricted inv item check block.
         if ((DateTime.Now - CurTime).TotalSeconds > Instance.Configuration.Instance.CheckFrequency)
         {
             CurTime = DateTime.Now;
             for (int i = 0; i < Provider.clients.Count; i++)
             {
                 UnturnedPlayer player = UnturnedPlayer.FromSteamPlayer(Provider.clients[i]);
                 if (player == null)
                 {
                     continue;
                 }
                 if (!R.Permissions.HasPermission(player, "ir.safe"))
                 {
                     for (int invi = 0; invi < Instance.Configuration.Instance.ItemInvRestrictedList.Count; invi++)
                     {
                         ushort restrictedItemID = Instance.Configuration.Instance.ItemInvRestrictedList[invi];
                         for (byte page = 0; page < PlayerInventory.PAGES && player.Inventory.items != null && player.Inventory.items[page] != null; page++)
                         {
                             for (byte itemI = 0; itemI < player.Inventory.getItemCount(page); itemI++)
                             {
                                 if (player.Inventory.getItem(page, itemI).item.id == restrictedItemID)
                                 {
                                     ItemAsset itemAsset = UnturnedItems.GetItemAssetById(restrictedItemID);
                                     if (itemAsset == null)
                                     {
                                         continue;
                                     }
                                     UnturnedChat.Say(player, Translate("antigrief_inv_restricted", itemAsset.itemName, itemAsset.id));
                                     player.Inventory.removeItem(page, itemI);
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Example #10
0
        public void SpawnMagsWithLimit(ushort ammoAmountToSpawn, IRocketPlayer caller, ItemGunAsset currentWeapon,
                                       UnturnedPlayer uPlayer, string[] command)
        {
            if (ammoAmountToSpawn <= (ushort)EasyAmmo.Instance.Configuration.Instance.ClipLimit ||
                caller.HasPermission("easyammo.bypasslimit"))
            {
                if (uPlayer.GiveItem(GetMagId(uPlayer, currentWeapon, command), (byte)ammoAmountToSpawn))
                {
                    UnturnedChat.Say(caller,
                                     EasyAmmo.Instance.Translate("giving_mags", ammoAmountToSpawn.ToString(),
                                                                 UnturnedItems.GetItemAssetById(GetMagId(uPlayer, currentWeapon, command)).name,
                                                                 GetMagId(uPlayer, currentWeapon, command).ToString()));
                }
                else
                {
                    UnturnedChat.Say(caller, EasyAmmo.Instance.Translate("failed_to_spawn_mags"));
                }
            }
            else
            {
                ushort amountoverlimit = ammoAmountToSpawn;
                ammoAmountToSpawn = (ushort)EasyAmmo.Instance.Configuration.Instance.ClipLimit;

                if (uPlayer.GiveItem(GetMagId(uPlayer, currentWeapon, command), (byte)ammoAmountToSpawn))
                {
                    UnturnedChat.Say(caller,
                                     EasyAmmo.Instance.Translate("over_clip_spawn_limit_giving", amountoverlimit.ToString(),
                                                                 EasyAmmo.Instance.Configuration.Instance.ClipLimit,
                                                                 UnturnedItems.GetItemAssetById(GetMagId(uPlayer, currentWeapon, command)).name,
                                                                 GetMagId(uPlayer, currentWeapon, command).ToString()));
                }
                else
                {
                    UnturnedChat.Say(caller, EasyAmmo.Instance.Translate("failed_to_spawn_mags"));
                }
            }
        }
Example #11
0
        public void Execute(IRocketPlayer caller, string[] command)
        {
            UnturnedPlayer callr = (UnturnedPlayer)caller;

            string kitName    = Plugin.CustomKitsPlugin.Instance.Configuration.Instance.DefaultKitName;
            string presetName = "ADMIN_KIT";

            List <InventoryManager.Item> itemList = InventoryManager.ListItems(callr);
            int inventoryCount = itemList.Count;

            if (!caller.IsAdmin || !caller.HasPermission("ck.admin"))
            {
                string[] blackList = new string[] { };
                int      itemLimit = int.MaxValue;

                foreach (Plugin.CustomKitsConfig.Preset Preset in Plugin.CustomKitsPlugin.Instance.Configuration.Instance.Presets)
                {
                    if (caller.HasPermission(Plugin.CustomKitsPlugin.PERMISSION + Preset.Name))
                    {
                        presetName = Preset.Name;

                        if (Preset.Blacklist != "")
                        {
                            blackList = Preset.Blacklist.Split(',');
                            break;
                        }
                    }
                    else
                    {
                        UnturnedChat.Say(caller, Plugin.CustomKitsPlugin.Instance.Translate("set_permissions"), Color.red);
                        return;
                    }
                }

                if (KitManager.KitCount(callr, KitManager.Kits) >= SlotManager.SlotCount(callr))
                {
                    UnturnedChat.Say(caller, Plugin.CustomKitsPlugin.Instance.Translate("no_kits_left"), Color.red);
                    return;
                }

                var v    = KitManager.KitCount(callr, KitManager.Kits);
                var slot = SlotManager.Slots[callr.CSteamID.m_SteamID][v];

                itemLimit = slot.itemLimit;

                if (blackList.Length > 0)
                {
                    foreach (InventoryManager.Item item in itemList)
                    {
                        List <int> bList = new List <int>();
                        foreach (var itemID in blackList)
                        {
                            bList.Add(int.Parse(itemID));
                        }

                        if (bList.Contains(item.id))
                        {
                            UnturnedChat.Say(caller, Plugin.CustomKitsPlugin.Instance.Translate("blacklisted", UnturnedItems.GetItemAssetById(item.id)), Color.red);
                        }
                    }
                }

                if (inventoryCount > itemLimit)
                {
                    UnturnedChat.Say(caller, Plugin.CustomKitsPlugin.Instance.Translate("item_limit", itemLimit), Color.red);
                    return;
                }
            }

            if (Plugin.CustomKitsPlugin.Instance.Configuration.Instance.DefaultKitName == "preset_name")
            {
                kitName = presetName;
            }

            if (command.Length == 1)
            {
                kitName = command[0];
            }

            if (kitName == "*")
            {
                UnturnedChat.Say(caller, Plugin.CustomKitsPlugin.Instance.Translate("unsupported_character", "*"), Color.red);
                return;
            }

            if (inventoryCount < 1 || itemList == null)
            {
                UnturnedChat.Say(caller, Plugin.CustomKitsPlugin.Instance.Translate("empty_inventory"), Color.red);
                return;
            }

            if (KitManager.HasKit(callr, kitName, KitManager.Kits))
            {
                KitManager.DeleteKit(callr, kitName, KitManager.Kits);
            }

            KitManager.SaveKit(callr, callr, kitName, KitManager.Kits);

            UnturnedChat.Say(caller, Plugin.CustomKitsPlugin.Instance.Translate("kit_saved", kitName), Color.green);
        }
Example #12
0
        internal static void AutoSave(UnturnedPlayer player)
        {
            string kitName = Commands.Command_AutoSave.AutoSave[player.CSteamID];

            InventoryManager.Inventory inventory = AutoSaveKits[player.CSteamID.m_SteamID][kitName];
            int inventoryCount = inventory.items.Count;

            if (!player.IsAdmin)
            {
                string[] blackList = new string[0];
                foreach (Plugin.CustomKitsConfig.Preset Preset in Plugin.CustomKitsPlugin.Instance.Configuration.Instance.Presets)
                {
                    if (player.HasPermission(Plugin.CustomKitsPlugin.PERMISSION + Preset.Name) && Preset.Blacklist != "")
                    {
                        blackList = Preset.Blacklist.Split(',');
                        break;
                    }
                    UnturnedChat.Say(player, Plugin.CustomKitsPlugin.Instance.Translate("set_permissions"), Color.red);
                    return;
                }

                if (KitCount(player, Kits) >= SlotManager.SlotCount(player))
                {
                    UnturnedChat.Say(player, Plugin.CustomKitsPlugin.Instance.Translate("no_kits_left"), Color.red);
                    return;
                }

                var v    = KitCount(player, Kits);
                var slot = SlotManager.Slots[player.CSteamID.m_SteamID][v];

                int itemLimit = slot.itemLimit;
                if (blackList.Length > 0)
                {
                    foreach (InventoryManager.Item item in inventory.items)
                    {
                        List <int> bList = new List <int>();
                        foreach (var itemID in blackList)
                        {
                            bList.Add(int.Parse(itemID));
                        }

                        if (bList.Contains(item.id))
                        {
                            UnturnedChat.Say(player, Plugin.CustomKitsPlugin.Instance.Translate("blacklisted", UnturnedItems.GetItemAssetById(item.id)), Color.red);
                        }
                    }
                }

                if (inventoryCount > itemLimit)
                {
                    UnturnedChat.Say(player, Plugin.CustomKitsPlugin.Instance.Translate("item_limit", itemLimit), Color.red);
                    return;
                }
            }

            if (inventoryCount < 1 || inventory.items == null)
            {
                UnturnedChat.Say(player, Plugin.CustomKitsPlugin.Instance.Translate("empty_inventory"), Color.red);
                return;
            }

            if (HasKit(player, kitName, KitManager.Kits))
            {
                DeleteKit(player, kitName, KitManager.Kits);
            }

            SaveKit(player, player, kitName, KitManager.Kits);
            UnturnedChat.Say(player, Plugin.CustomKitsPlugin.Instance.Translate("kit_saved", kitName), Color.green);

            // Auto off
            Commands.Command_AutoSave.AutoSave.Remove(player.CSteamID);
            UnturnedChat.Say(player, Plugin.CustomKitsPlugin.Instance.Translate("autosave_off"), Color.green);
        }
Example #13
0
        public void SpawnMagsWithLimit_Uconomy(ushort ammoAmountToSpawn, IRocketPlayer caller, SDG.Unturned.ItemGunAsset currentWeapon, UnturnedPlayer Uplayer, string[] command)
        {
            int costMultiplier = EasyAmmo.Instance.Configuration.Instance.PerBulletCostMultiplier;

            SDG.Unturned.ItemMagazineAsset magazine = (SDG.Unturned.ItemMagazineAsset)UnturnedItems.GetItemAssetById(GetMagId(Uplayer, currentWeapon, command));

            if (ammoAmountToSpawn <= (ushort)EasyAmmo.Instance.Configuration.Instance.ClipLimit || caller.HasPermission("easyammo.bypasslimit"))
            {
                if (Uconomy.Instance.Database.GetBalance(caller.Id) >= GetCost(false, ammoAmountToSpawn, currentWeapon, magazine))
                {
                    if (Uplayer.GiveItem(GetMagId(Uplayer, currentWeapon, command), (byte)ammoAmountToSpawn))
                    {
                        Uconomy.Instance.Database.IncreaseBalance(caller.Id, GetCost(true, ammoAmountToSpawn, currentWeapon, magazine));

                        UnturnedChat.Say(caller, EasyAmmo.Instance.Translate("giving_mags", ammoAmountToSpawn.ToString(), UnturnedItems.GetItemAssetById(GetMagId(Uplayer, currentWeapon, command)).name, GetMagId(Uplayer, currentWeapon, command).ToString()));
                        UnturnedChat.Say(caller, EasyAmmo.Instance.Translate("balance", Uconomy.Instance.Database.GetBalance(caller.Id)));
                    }
                    else
                    {
                        UnturnedChat.Say(caller, EasyAmmo.Instance.Translate("failed_to_spawn_mags"));
                    }
                }
                else
                {
                    UnturnedChat.Say(caller, EasyAmmo.Instance.Translate("not_enough_funds",
                                                                         Uconomy.Instance.Configuration.Instance.MoneyName,
                                                                         ammoAmountToSpawn, magazine.itemName, GetCost(false, ammoAmountToSpawn, currentWeapon, magazine).ToString()));
                }
            }
            else
            {
                ushort amountoverlimit = ammoAmountToSpawn;
                ammoAmountToSpawn = (ushort)EasyAmmo.Instance.Configuration.Instance.ClipLimit;

                if (Uconomy.Instance.Database.GetBalance(caller.Id) >= GetCost(false, ammoAmountToSpawn, currentWeapon, magazine))
                {
                    if (Uplayer.GiveItem(GetMagId(Uplayer, currentWeapon, command), (byte)ammoAmountToSpawn))
                    {
                        Uconomy.Instance.Database.IncreaseBalance(caller.Id, GetCost(true, ammoAmountToSpawn, currentWeapon, magazine));

                        UnturnedChat.Say(caller, EasyAmmo.Instance.Translate("over_clip_spawn_limit_giving", amountoverlimit.ToString(),
                                                                             EasyAmmo.Instance.Configuration.Instance.ClipLimit, UnturnedItems.GetItemAssetById(GetMagId(Uplayer, currentWeapon, command)).name,
                                                                             GetMagId(Uplayer, currentWeapon, command).ToString()));
                        UnturnedChat.Say(caller, EasyAmmo.Instance.Translate("balance", Uconomy.Instance.Database.GetBalance(caller.Id)));
                    }
                    else
                    {
                        UnturnedChat.Say(caller, EasyAmmo.Instance.Translate("failed_to_spawn_mags"));
                    }
                }
                else
                {
                    UnturnedChat.Say(caller, EasyAmmo.Instance.Translate("not_enough_funds",
                                                                         Uconomy.Instance.Configuration.Instance.MoneyName,
                                                                         ammoAmountToSpawn, magazine.itemName, GetCost(false, ammoAmountToSpawn, currentWeapon, magazine).ToString()));
                }
            }
        }
Example #14
0
        public static void ItemAll()
        {
            UnturnedPlayer player;

            foreach (var p in Provider.clients)
            {
                player = UnturnedPlayer.FromCSteamID(p.playerID.steamID);
                player.GiveItem(Plugin.Instance.ItemToGive, 1);
                UnturnedChat.Say(p.playerID.steamID, Plugin.Instance.Translate("itemall_message", UnturnedItems.GetItemAssetById(Plugin.Instance.ItemToGive).itemName), Plugin.Instance.MessageColor);
            }
        }
Example #15
0
        public void Execute(IRocketPlayer caller, string[] command)
        {
            bool VoteInProgress = Plugin.Instance.VoteInProgress;
            bool VoteInCooldown = Plugin.Instance.VoteInCooldown;
            int  VoteTimer      = Plugin.Instance.Configuration.Instance.VoteTimer;
            int  VoteCooldown   = Plugin.Instance.Configuration.Instance.VoteCooldown;

            if (command.Length == 0)
            {
                if (!VoteInProgress)
                {
                    UnturnedChat.Say(caller, Plugin.Instance.Translate("no_ongoing_votes"), Color.red);
                    Utility.Help((UnturnedPlayer)caller);
                }
                else
                {
                    Voting.Vote(caller);
                }
                return;
            }

            if (command.Length == 1)
            {
                if (VoteInProgress)
                {
                    UnturnedChat.Say(caller, Plugin.Instance.Translate("vote_error"), Plugin.Instance.MessageColor);
                    return;
                }

                if (VoteInCooldown)
                {
                    UnturnedChat.Say(caller, Plugin.Instance.Translate("vote_cooldown", VoteCooldown), Plugin.Instance.MessageColor);
                    return;
                }
            }

            if (!VoteInProgress && !VoteInCooldown)
            {
                if (Utility.PlayerRequirement() == false)
                {
                    UnturnedChat.Say(caller, Plugin.Instance.Translate("not_enough_players", Plugin.Instance.Configuration.Instance.MinimumPlayers), Color.red); return;
                }
                foreach (Vote vote in Plugin.Instance.Configuration.Instance.Votes)
                {
                    if (String.Compare(command[0], vote.Name, true) == 0 || String.Compare(command[0], vote.Alias, true) == 0)
                    {
                        if (!vote.Enabled)
                        {
                            Utility.Notify((UnturnedPlayer)caller, 1); return;
                        }
                        if (!caller.HasPermission("cvote." + vote.Name.ToLower()))
                        {
                            Utility.Notify((UnturnedPlayer)caller, 2); return;
                        }

                        if (command.Length == 1)
                        {
                            if (vote.Name == "ItemAll" || vote.Name == "Kick" || vote.Name == "Mute" || vote.Name == "Spy")
                            {
                                return;
                            }
                            UnturnedChat.Say(Plugin.Instance.Translate("vote_started", caller.DisplayName, VoteTimer, Plugin.Instance.Translate(vote.Name)), Plugin.Instance.MessageColor);
                        }

                        else if (command.Length == 2)
                        {
                            if (vote.Name == "ItemAll")
                            {
                                ushort item;
                                ushort.TryParse(command[1], out item);
                                Plugin.Instance.ItemToGive = item;
                                UnturnedChat.Say(Plugin.Instance.Translate("vote_started", caller.DisplayName, VoteTimer, Plugin.Instance.Translate(vote.Name, UnturnedItems.GetItemAssetById(Plugin.Instance.ItemToGive).itemName)), Plugin.Instance.MessageColor);
                            }
                            else if (vote.Name == "Kick")
                            {
                                if (UnturnedPlayer.FromName(command[1]) != null)
                                {
                                    Plugin.Instance.PlayerToKickOrMute = UnturnedPlayer.FromName(command[1]).CSteamID;
                                }
                                UnturnedChat.Say(Plugin.Instance.Translate("vote_started", caller.DisplayName, VoteTimer, Plugin.Instance.Translate(vote.Name, UnturnedPlayer.FromName(command[1]).DisplayName)), Plugin.Instance.MessageColor);
                            }
                            else if (vote.Name == "Mute")
                            {
                                if (UnturnedPlayer.FromName(command[1]) != null)
                                {
                                    Plugin.Instance.PlayerToKickOrMute = UnturnedPlayer.FromName(command[1]).CSteamID;
                                }
                                UnturnedChat.Say(Plugin.Instance.Translate("vote_started", caller.DisplayName, VoteTimer, Plugin.Instance.Translate(vote.Name, UnturnedPlayer.FromName(command[1]).DisplayName, Plugin.Instance.Configuration.Instance.MuteTime)), Plugin.Instance.MessageColor);
                            }
                            else if (vote.Name == "Spy")
                            {
                                if (UnturnedPlayer.FromName(command[1]) != null)
                                {
                                    Plugin.Instance.PlayerToSpy = UnturnedPlayer.FromName(command[1]).CSteamID;
                                }
                                UnturnedChat.Say(Plugin.Instance.Translate("vote_started", caller.DisplayName, VoteTimer, Plugin.Instance.Translate(vote.Name)), Plugin.Instance.MessageColor);
                            }
                        }

                        else
                        {
                            string Message = "";
                            for (int x = 0; x < command.Length; x++)
                            {
                                if (x == 0)
                                {
                                    continue;
                                }
                                string Word = command[x];
                                Message += Word + " ";
                            }
                            UnturnedChat.Say(Plugin.Instance.Translate("vote_started", caller.DisplayName, VoteTimer, Plugin.Instance.Translate(vote.Name, Message)), Plugin.Instance.MessageColor);
                        }

                        Plugin.Instance.CurrentVote = vote.Name;
                        Plugin.Instance.StartCoroutine(Voting.VotingProcess());
                        Plugin.Instance.VoteStarted(caller, Plugin.Instance.CurrentVote);
                        if (Plugin.Instance.Configuration.Instance.AutoVoteCaller)
                        {
                            Voting.Vote(caller);
                        }
                    }
                }
            }
        }
Example #16
0
 private void CheckInventory(UnturnedPlayer player)
 {
     for (int i = 0; i < this.Configuration.Instance.Items.Count; i++)
     {
         ushort item = this.Configuration.Instance.Items[i];
         try
         {
             for (byte page = 0; page < PlayerInventory.PAGES; page++)
             {
                 byte itemCount = player.Player.inventory.getItemCount(page);
                 for (byte index = 0; index < itemCount; index++)
                 {
                     if (player.Player.inventory.getItem(page, index).item.id == item)
                     {
                         UnturnedChat.Say(player, Translate("item_notPermitted", UnturnedItems.GetItemAssetById(item).itemName), Color.red);
                         player.Player.inventory.removeItem(page, index);
                     }
                 }
             }
         }
         catch { }
     }
 }
Example #17
0
        private void CheckInventory(UnturnedPlayer player)
        {
            bool willRestrict;

            for (int i = 0; i < this.Configuration.Instance.Items.Count; i++)
            {
                willRestrict = true;
                ushort item = this.Configuration.Instance.Items[i];
                foreach (UnrestrictGroup group in this.Configuration.Instance.UnrestrictGroups)
                {
                    if (player.HasPermission(group.permission) && willRestrict)
                    {
                        foreach (ushort id in group.Items)
                        {
                            if (item == id)
                            {
                                willRestrict = false;
                                break;
                            }
                        }
                    }
                }
                if (willRestrict)
                {
                    try
                    {
                        for (byte page = 0; page < PlayerInventory.PAGES; page++)
                        {
                            byte itemCount = player.Player.inventory.getItemCount(page);
                            for (byte index = 0; index < itemCount; index++)
                            {
                                if (player.Player.inventory.getItem(page, index).item.id == item)
                                {
                                    UnturnedChat.Say(player, Translate("item_notPermitted", UnturnedItems.GetItemAssetById(item).itemName), Color.red);
                                    player.Player.inventory.removeItem(page, index);
                                }
                            }
                        }
                    }
                    catch { }
                }
            }
        }