예제 #1
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);
                }
            }
        }
예제 #2
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);
        }
예제 #3
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));
                    }
                }
            }
        }
예제 #4
0
        //Start paintball method
        public void startPaintball(IRocketPlayer caller)
        {
            if (PaintballManager.gameRunning)
            {
                UnturnedChat.Say(caller, "Paintball already has an active game running.", Color.red);
                return;
            }

            //Check if anyone hasn't respawned
            for (int x = 0; x < PaintballManager.joinedPlayers.Count(); x++)
            {
                if (PaintballManager.joinedPlayers[x].getRevived() == false)
                {
                    PaintballManager.joinedPlayers[x].getPlayer().Kick("AFK during paintball. Please rejoin.");
                }
            }

            if (PaintballManager.joinedPlayers.Count() == 1)
            {
                UnturnedChat.Say(caller, "Cannot start game, only one player is joined.", Color.red);
                PaintballManager.gameRunning = false;
                return;
            }

            for (int x = 0; x < PaintballManager.joinedPlayers.Count(); x++)
            {
                //Create the player
                UnturnedPlayer currentPlayer = PaintballManager.joinedPlayers[x].getPlayer();

                //Set dead to false
                PaintballManager.joinedPlayers[x].setDead(false);

                //Turn off god, clear, heal, and give max skills.
                currentPlayer.GodMode = false;
                PlayerManager.clearInventory(currentPlayer);;
                currentPlayer.Heal(100);
                currentPlayer.Hunger    = 0;
                currentPlayer.Thirst    = 0;
                currentPlayer.Infection = 0;
                PlayerManager.maxSkills(currentPlayer);

                //Spawn the paintball items
                currentPlayer.Inventory.tryAddItem(UnturnedItems.AssembleItem(1337, 250, new Attachment(1004, 100), new Attachment(151, 100), new Attachment(8, 100), new Attachment(1338, 1), new Attachment(1340, 100), EFiremode.SEMI), true);
                currentPlayer.GiveItem(1048, 1);
                currentPlayer.GiveItem(394, 4);
                currentPlayer.GiveItem(1133, 1);
                currentPlayer.GiveItem(431, 1);
                currentPlayer.GiveItem(177, 1);
                currentPlayer.GiveItem(548, 1);
                currentPlayer.GiveItem(1340, 5);

                //Locate their spawn point.
                System.Random spawnGen    = new System.Random();
                Vector3       playerSpawn = new Vector3(spawnGen.Next(PaintballManager.arenaMinX, PaintballManager.arenaMaxX), PaintballManager.arenaY, spawnGen.Next(PaintballManager.arenaMinZ, PaintballManager.arenaMaxZ));
                //Transport the player
                currentPlayer.Teleport(playerSpawn, spawnGen.Next(0, 360));
            }
            PaintballManager.gameRunning = true;
        }
예제 #5
0
        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()));
        }
예제 #7
0
        public void Execute(IRocketPlayer caller, string[] command)
        {
            UnturnedPlayer player = (UnturnedPlayer)caller;

            if (command.Length == 0 || command.Length > 2)
            {
                UnturnedChat.Say(player, U.Translate("command_generic_invalid_parameter"));
                return;
            }

            ushort id     = 0;
            byte   amount = 1;

            string itemString = command[0].ToString();

            if (!ushort.TryParse(itemString, out id))
            {
                ItemAsset asset = UnturnedItems.GetItemAssetByName(itemString.ToLower());
                if (asset != null)
                {
                    id = asset.Id;
                }
                if (String.IsNullOrEmpty(itemString.Trim()) || id == 0)
                {
                    UnturnedChat.Say(player, U.Translate("command_generic_invalid_parameter"));
                    return;
                }
            }

            Asset a = SDG.Unturned.Assets.find(EAssetType.ITEM, id);

            if (command.Length == 2 && !byte.TryParse(command[1].ToString(), out amount) || a == null)
            {
                UnturnedChat.Say(player, U.Translate("command_generic_invalid_parameter"));
                return;
            }

            string assetName = ((ItemAsset)a).Name;

            if (!player.IsAdmin && player.HasPermission("i." + id))
            {
                UnturnedChat.Say(player, Plugin.Instance.Translate("text_block"));
                return;
            }
            if (player.GiveItem(id, amount))
            {
                Logger.Log(U.Translate("command_i_giving_console", player.DisplayName, id, amount));
                UnturnedChat.Say(player, U.Translate("command_i_giving_private", amount, assetName, id));
            }
            else
            {
                UnturnedChat.Say(player, U.Translate("command_i_giving_failed_private", amount, assetName, id));
            }
        }
        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
                        );
                }
            }
        }
예제 #10
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"));
     }
 }
예제 #11
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);
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
        protected override async Task OnInitializedAsync()
        {
            Settings      = (await HttpClient.GetFromJsonAsync <List <Setting> >("api/settings")).ToDictionary(x => x.SettingId);
            UnturnedItems = await HttpClient.GetFromJsonAsync <IEnumerable <UnturnedItem> >("api/unturneditems");

            Servers = await HttpClient.GetFromJsonAsync <IEnumerable <Server> >("api/servers");

            if (PlayersService.CurrentUserInfo?.IsGlobalAdmin ?? false)
            {
                steamDevKey = Settings["SteamDevKey"];
                apiKey      = Settings["APIKey"];
                admins      = Settings["Admins"];
            }

            indexLayout    = Settings["IndexLayout"];
            itemPageLayout = Settings["ItemPageLayout"];
            productsLayout = Settings["ProductsLayout"];

            unturnedItemsCount    = UnturnedItems.Count();
            marketItemsCount      = UnturnedItems.Sum(x => x.MarketItemsCount);
            connectedServersCount = Servers.Count(x => x.IsConnected);
        }
예제 #13
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"));
                }
            }
        }
예제 #14
0
        public void GiveKit()
        {
            Player.GiveItem(GunGameConfig.instance.weapons.hat, 1);
            Player.GiveItem(GunGameConfig.instance.weapons.mask, 1);
            Player.GiveItem(GunGameConfig.instance.weapons.vest, 1);
            Player.GiveItem(GunGameConfig.instance.weapons.pants, 1);
            Player.GiveItem(GunGameConfig.instance.weapons.shirt, 1);

            GunGameConfig.Weapon weapon = GunGameConfig.instance.weapons.weapons[kitRequest];

            Item primary   = weapon.GetUnturnedItem();
            Item secondary = UnturnedItems.AssembleItem(GunGameConfig.instance.weapons.secondary, 1, 100, null);
            Item mag       = UnturnedItems.AssembleItem(weapon.mag, weapon.ammo, 100, null);

            Player.Inventory.items[0].tryAddItem(primary);
            Player.Inventory.items[1].tryAddItem(secondary);

            for (int i = 0; i < weapon.magAmt; i++)
            {
                Player.Inventory.items[2].tryAddItem(mag);
            }

            Invoke("Equip", GunGameConfig.instance.advSettings.equipTime);
        }
예제 #15
0
        public void Execute(IRocketPlayer caller, string[] command)
        {
            UnturnedPlayer player = (UnturnedPlayer)caller;
            if (command.Length == 0 || command.Length > 2)
            {
                UnturnedChat.Say(player, U.Translate("command_generic_invalid_parameter"));
                throw new WrongUsageOfCommandException(caller, this);
            }

            byte amount = 1;

            string itemString = command[0].ToString();

            if (!ushort.TryParse(itemString, out ushort id))
            {
                List<ItemAsset> sortedAssets = new List<ItemAsset>(SDG.Unturned.Assets.find(EAssetType.ITEM).Cast<ItemAsset>());
                ItemAsset asset = sortedAssets.Where(i => i.itemName != null).OrderBy(i => i.itemName.Length).Where(i => i.itemName.ToLower().Contains(itemString.ToLower())).FirstOrDefault();
                if (asset != null) id = asset.id;
                if (String.IsNullOrEmpty(itemString.Trim()) || id == 0)
                {
                    UnturnedChat.Say(player, U.Translate("command_generic_invalid_parameter"));
                    throw new WrongUsageOfCommandException(caller, this);
                }
            }

            Asset a = SDG.Unturned.Assets.find(EAssetType.ITEM, id);

            if (command.Length == 2 && !byte.TryParse(command[1].ToString(), out amount) || a == null)
            {
                UnturnedChat.Say(player, U.Translate("command_generic_invalid_parameter"));
                throw new WrongUsageOfCommandException(caller, this);
            }

            string assetName = ((ItemAsset)a).itemName;

            if (U.Settings.Instance.EnableItemBlacklist && !player.HasPermission("itemblacklist.bypass." + id))
            {
                if (UnturnedItems.isBlacklisted(id))
                {
                    UnturnedChat.Say(player, U.Translate("command_i_blacklisted"));
                    return;
                }
            }

            if (U.Settings.Instance.EnableItemSpawnLimit && !player.HasPermission("itemspawnlimit.bypass." + id))
            {
                if (amount > U.Settings.Instance.MaxSpawnAmount)
                {
                    UnturnedChat.Say(player, U.Translate("command_i_too_much", U.Settings.Instance.MaxSpawnAmount));
                    return;
                }
                if (U.Instance.PlayerSpawnInfo != null && U.Instance.PlayerSpawnInfo.ContainsKey(player))
                {
                    if (amount + U.Instance.PlayerSpawnInfo[player].RecentSpawnAmount > U.Settings.Instance.MaxRecentSpawnAmount)
                    {
                        player.Kick("You have spawned too many items recently.");
                        ItemManager.askClearAllItems();
                    }
                }
            }

            if (player.GiveItem(id, amount))
            {
                Logger.Log(U.Translate("command_i_giving_console", player.DisplayName, id, amount));
                UnturnedChat.Say(player, U.Translate("command_i_giving_private", amount, assetName, id));
                if (U.Instance.PlayerSpawnInfo == null)
                    U.Instance.PlayerSpawnInfo = new Dictionary<UnturnedPlayer, PlayerSpawnInfo>();
                if (!U.Instance.PlayerSpawnInfo.ContainsKey(player))
                    U.Instance.PlayerSpawnInfo.Add(player, new PlayerSpawnInfo(player.CSteamID, amount, amount, DateTime.Now));
                else
                {
                    if ((DateTime.Now - U.Instance.PlayerSpawnInfo[player].LastSpawnTime).TotalMinutes >= 1)
                    {
                        U.Instance.PlayerSpawnInfo.Remove(player);
                        U.Instance.PlayerSpawnInfo.Add(player, new PlayerSpawnInfo(player.CSteamID, amount, amount, DateTime.Now));
                    }
                    else
                    {
                        int Amount = U.Instance.PlayerSpawnInfo[player].RecentSpawnAmount;
                        U.Instance.PlayerSpawnInfo.Remove(player);
                        U.Instance.PlayerSpawnInfo.Add(player, new PlayerSpawnInfo(player.CSteamID, amount, amount + Amount, DateTime.Now));
                    }
                }
            }
            else
            {
                UnturnedChat.Say(player, U.Translate("command_i_giving_failed_private", amount, assetName, id));
            }
        }
예제 #16
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);
        }
예제 #17
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);
        }
예제 #18
0
        //       [RocketCommand("event", "Main command to start and manage events.", "<what to do>", AllowedCaller.Player)]
        public void Execute(IRocketPlayer caller, string[] parameters)
        {
            //           Logger.Log("Inside Execute command.");
            string[]       command = new string[1];
            UnturnedPlayer pCaller = (UnturnedPlayer)caller;

            var tempCharacterInfoDuplicate      = joinedPlayers.FirstOrDefault(item => item.getSteamID() == pCaller.CSteamID.ToString());
            var tempCharacterInfoGroupDuplicate = joinedPlayers.FirstOrDefault(item => item.getGroupID() == pCaller.SteamGroupID.ToString());

            if (parameters.Count() == 1)
            {
                command[0] = parameters[0].ToLower();
            }
            else
            {
                UnturnedChat.Say(caller, Events.Instance.Translate("events_invalid_parameter"), Events.Instance.Configuration.Instance.ErrorColor);
            }

            //Claim Reward
            if (command[0] == "reward")
            {
                if (!started && !eventActive)
                {
                    int playerWins = getWins(pCaller);
                    //      Logger.Log("Wins: " + playerWins);

                    if (playerWins == 0)
                    {
                        UnturnedChat.Say(caller, Events.Instance.Translate("events_no_reward"), Events.Instance.Configuration.Instance.ErrorColor);
                        return;
                    }
                    else
                    {
                        if (playerWins >= 1)
                        {
                            pCaller.GiveItem(253, 1);
                        }
                        if (playerWins >= 2)
                        {
                            pCaller.GiveItem(307, 1);
                            pCaller.GiveItem(308, 1);
                            pCaller.GiveItem(309, 1);
                            pCaller.GiveItem(310, 1);
                        }
                        if (playerWins >= 3)
                        {
                            pCaller.Inventory.tryAddItem(UnturnedItems.AssembleItem(1337, 250, new Attachment(1004, 100), new Attachment(151, 100), new Attachment(8, 100), new Attachment(1338, 1), new Attachment(1340, 100), EFiremode.AUTO), true);
                        }
                        if (playerWins >= 4)
                        {
                            pCaller.GiveItem(363, 1);
                            pCaller.GiveItem(6, 1);
                        }
                        if (playerWins >= 5)
                        {
                            pCaller.GiveItem(116, 1);
                            pCaller.GiveItem(6, 1);
                        }
                        if (playerWins >= 6)
                        {
                            pCaller.GiveItem(18, 1);
                            pCaller.GiveItem(20, 1);
                        }
                        if (playerWins >= 7)
                        {
                            pCaller.GiveItem(132, 1);
                            pCaller.GiveItem(133, 1);
                        }
                        if (playerWins >= 8)
                        {
                            pCaller.GiveItem(519, 1);
                            pCaller.GiveItem(520, 1);
                        }

                        UnturnedChat.Say(caller, Events.Instance.Translate("events_reward_given"), Events.Instance.Configuration.Instance.SuccessColor);
                    }
                    //Go through players and count wins and give prize based on that.
                    //Remove name from list once claimed.
                    //     pCaller.Inventory.tryAddItem(UnturnedItems.AssembleItem(363, 30, new Attachment(1004, 100), new Attachment(151, 100), new Attachment(8, 100), new Attachment(7, 100), new Attachment(6, 100), EFiremode.AUTO), true);
                    //   pCaller.GiveItem(394, 100);
                    return;
                }
                else
                {
                    UnturnedChat.Say(caller, Events.Instance.Translate("events_error_not_finished_reward"), Events.Instance.Configuration.Instance.ErrorColor);
                    return;
                }
            }

            #region on
            //Begin commands
            //On event command
            if (command[0] == "on")
            {
                if (caller.IsAdmin)
                {
                    if (!started)
                    {
                        joinedPlayers = new List <PlayerData>()
                        {
                        };
                        usedStorage    = new List <string>();
                        Events.winners = "";
                        started        = true;
                        UnturnedChat.Say(caller, Events.Instance.Translate("events_on"), Events.Instance.Configuration.Instance.SuccessColor);
                        //                 UnturnedChat.Say(Events.Instance.Translate("events_join_announcement", gameMode), Events.Instance.Configuration.Instance.AnnouncementColor);
                        return;
                    }
                    else
                    {
                        UnturnedChat.Say(caller, Events.Instance.Translate("events_already_active"), Events.Instance.Configuration.Instance.ErrorColor);
                        return;
                    }
                }
                else
                {
                    UnturnedChat.Say(caller, Events.Instance.Translate("events_no_permission"), Events.Instance.Configuration.Instance.ErrorColor);
                }
                return;
            }
            #endregion

            #region off
            //Off event command
            if (command[0] == "off")
            {
                if (caller.IsAdmin)
                {
                    if (started)
                    {
                        started     = false;
                        eventActive = false;

                        Logger.Log("Total PLayer Count on Off: " + joinedPlayers.Count);
                        int playerCountBeforeDump = joinedPlayers.Count;
                        for (int x = 0; x < playerCountBeforeDump; x++)
                        {
                            UnturnedPlayer player = UnturnedPlayer.FromCSteamID(new CSteamID(Convert.ToUInt64(joinedPlayers[0].getSteamID())));
                            Logger.Log("Inside Off Loop" + x);
                            //          player.GodMode = false;
                            //              Logger.Log("Ran list");
                            leaveEvent(player);
                        }
                        //                    leaveEvent(pCaller);

                        UnturnedChat.Say(caller, Events.Instance.Translate("events_off"), Events.Instance.Configuration.Instance.SuccessColor);
                        UnturnedChat.Say(Events.Instance.Translate("events_ended_announcement"), Events.Instance.Configuration.Instance.AnnouncementColor);
                        return;
                    }
                    else
                    {
                        UnturnedChat.Say(caller, Events.Instance.Translate("events_already_notactive"), Events.Instance.Configuration.Instance.ErrorColor);
                        return;
                    }
                }
                else
                {
                    UnturnedChat.Say(caller, Events.Instance.Translate("events_no_permission"), Events.Instance.Configuration.Instance.ErrorColor);
                }
                return;
            }
            #endregion

            //Permission Reload command
            if (command[0] == "permreload")
            {
                if (caller.IsAdmin)
                {
                    foreach (SteamPlayer plr in Provider.Players)
                    {
                        //So let's convert each SteamPlayer into an UnturnedPlayer
                        UnturnedPlayer unturnedPlayer = UnturnedPlayer.FromSteamPlayer(plr);

                        unturnedPlayer.GodMode = false;

                        //Reset permissions
                        Rocket.Core.R.Permissions.RemovePlayerFromGroup("EventGroup", unturnedPlayer);
                        Rocket.Core.R.Permissions.AddPlayerToGroup("Guest", unturnedPlayer);
                    }
                    UnturnedChat.Say(caller, "Done.", Events.Instance.Configuration.Instance.SuccessColor);
                    return;
                }
                else
                {
                    UnturnedChat.Say(caller, Events.Instance.Translate("events_no_permission"), Events.Instance.Configuration.Instance.ErrorColor);
                    return;
                }
            }



            if (started)
            {
                //Give lockers to store.
                if (command[0] == "storage")
                {
                    var tempCharacterInfoDuplicateLockers = usedStorage.FirstOrDefault(item => item == pCaller.CSteamID.ToString());

                    if (tempCharacterInfoDuplicateLockers == null)
                    {
                        pCaller.GiveItem(328, 4);
                        UnturnedChat.Say(caller, Events.Instance.Translate("events_storage_given"), Events.Instance.Configuration.Instance.SuccessColor);
                        usedStorage.Add(pCaller.CSteamID.ToString());
                        return;
                    }
                    else
                    {
                        UnturnedChat.Say(caller, Events.Instance.Translate("events_storage_used"), Events.Instance.Configuration.Instance.ErrorColor);
                        return;
                    }
                }

                #region join
                //Join Event
                if (command[0] == "join")
                {
                    //         Logger.Log("Join Command");

                    //                joinedPlayers += pCaller.CSteamID;
                    //If player is not already added, add them
                    if (tempCharacterInfoDuplicate == null)
                    {
                        //               Logger.Log("Group: ." + pCaller.SteamGroupID + ".");
                        if (tempCharacterInfoGroupDuplicate == null || pCaller.SteamGroupID.ToString() == "0")
                        {
                            PlayerData     thisPlayer = new PlayerData(pCaller.CharacterName, pCaller.CSteamID.ToString(), pCaller.SteamGroupID.ToString(), pCaller.Position);
                            UnturnedPlayer player     = UnturnedPlayer.FromCSteamID(new CSteamID(Convert.ToUInt64(thisPlayer.getSteamID())));

                            joinedPlayers.Add(thisPlayer);
                            Rocket.Core.R.Permissions.RemovePlayerFromGroup("Guest", player);
                            Rocket.Core.R.Permissions.AddPlayerToGroup("EventGroup", player);

                            //During active event, send to position2.
                            if (eventActive)
                            {
                                //          pCaller.Suicide();
                                player.Teleport(position2, 0);
                                clearInventory(player);
                                player.GodMode = true;
                                thisPlayer.setDead(true);
                            }
                            UnturnedChat.Say(caller, Events.Instance.Translate("events_joined_game"), Events.Instance.Configuration.Instance.SuccessColor);
                            return;
                        }
                        else
                        {
                            UnturnedChat.Say(caller, Events.Instance.Translate("events_group_error"), Events.Instance.Configuration.Instance.ErrorColor);
                            return;
                        }
                    }
                    else if (tempCharacterInfoDuplicate != null)
                    {
                        UnturnedChat.Say(caller, Events.Instance.Translate("events_already_joined_game", tempCharacterInfoDuplicate.getName()), Events.Instance.Configuration.Instance.ErrorColor);
                        return;
                    }
                    else
                    {
                        UnturnedChat.Say(caller, Events.Instance.Translate("events_error"), Events.Instance.Configuration.Instance.ErrorColor);
                        return;
                    }
                }
                #endregion

                #region leave
                //Leave Event
                if (command[0] == "leave")
                {
                    //             Logger.Log("Leave Command");
                    leaveEvent(pCaller);
                    return;
                    //                joinedPlayers += pCaller.CSteamID;
                    //                PlayerData thisPlayer = new PlayerData(pCaller.CharacterName, pCaller.CSteamID, pCaller.Position);
                    //               joinedPlayers.Add(thisPlayer);
                    //                UnturnedChat.Say(caller, Translate("events_joined_game"));
                }
                #endregion

                #region list
                //List All Joined Players
                if (command[0] == "list")
                {
                    //                 Logger.Log("List Command");

                    if (caller.IsAdmin)
                    {
                        //                   Logger.Log("List Command - admin");
                        string allJoinedPlayers = "";
                        for (int x = 0; x < joinedPlayers.Count; x++)
                        {
                            //                         Logger.Log("Ran list");
                            allJoinedPlayers += joinedPlayers[x].getName() + " ";
                        }
                        UnturnedChat.Say(caller, Events.Instance.Translate("events_player_list", joinedPlayers.Count, allJoinedPlayers));
                        //                    Logger.Log(string.Join(Environment.NewLine, joinedPlayers.getName()));

                        //                   Logger.Log(allJoinedPlayers);
                        return;
                    }
                    else
                    {
                        UnturnedChat.Say(caller, Events.Instance.Translate("events_no_permission"), Events.Instance.Configuration.Instance.ErrorColor);
                        return;
                    }
                }
                #endregion

                //Paintball Game Mode
                if (gameMode == "paintball")
                {
                    if (caller.IsAdmin)
                    {
                        if (command[0] == "position1")
                        {
                            position1 = pCaller.Position;
                            UnturnedChat.Say(caller, Events.Instance.Translate("events_position_set", "position1", position1), Events.Instance.Configuration.Instance.SuccessColor);
                        }

                        if (command[0] == "position2")
                        {
                            position2 = pCaller.Position;
                            UnturnedChat.Say(caller, Events.Instance.Translate("events_position_set", "position2", position2), Events.Instance.Configuration.Instance.SuccessColor);
                        }

                        //Command start event
                        if (command[0] == "start")
                        {
                            if (!eventActive)
                            {
                                if (joinedPlayers.Count > 1)
                                {
                                    //                            Logger.Log("Event Start");
                                    eventActive   = true;
                                    activePlayers = joinedPlayers.Count;


                                    for (int x = 0; x < joinedPlayers.Count; x++)
                                    {
                                        UnturnedPlayer player = UnturnedPlayer.FromCSteamID(new CSteamID(Convert.ToUInt64(joinedPlayers[x].getSteamID())));

                                        player.GodMode = false;

                                        if (!joinedPlayers[x].getRevived())
                                        {
                                            leaveEvent(player);
                                        }
                                        else if (joinedPlayers[x].getRevived())
                                        {
                                            //                                  player.GodMode = false;
                                            joinedPlayers[x].setDead(false);
                                            //                                  Logger.Log("Event Start 2");

                                            clearInventory(player);
                                            healPlayer(player);
                                            maxSkills(player);

                                            //                                  Logger.Log("Event Start 3");
                                            //Paintball gun, 3 hoppers, 5 bandages,
                                            player.Inventory.tryAddItem(UnturnedItems.AssembleItem(1337, 250, new Attachment(1004, 100), new Attachment(151, 100), new Attachment(8, 100), new Attachment(1338, 1), new Attachment(1340, 100), EFiremode.SEMI), true);
                                            player.GiveItem(1048, 1);
                                            player.GiveItem(394, 4);
                                            player.GiveItem(1133, 1);
                                            player.GiveItem(431, 1);
                                            player.GiveItem(177, 1);
                                            player.GiveItem(548, 1);
                                            player.GiveItem(1340, 5);

                                            player.GodMode = false;
                                            player.Teleport(position1, 0);

                                            UnturnedChat.Say(player, Events.Instance.Translate("events_started", "position1", position1), Events.Instance.Configuration.Instance.SuccessColor);
                                        }
                                        else
                                        {
                                            UnturnedChat.Say(player, "Error. #3 Tell an admin the error code.", Events.Instance.Configuration.Instance.ErrorColor);
                                        }
                                    }
                                    //Winning method here
                                    Events myEvent = new Events();
                                    myEvent.dealWithWinEvent();
                                }
                                else
                                {
                                    UnturnedChat.Say(caller, Events.Instance.Translate("events_start_only_one"), Events.Instance.Configuration.Instance.ErrorColor);
                                }
                            }
                            else
                            {
                                UnturnedChat.Say(caller, Events.Instance.Translate("events_started_already"), Events.Instance.Configuration.Instance.ErrorColor);
                            }
                        }

                        //Command stop event
                        //Removes people and sends them to position2.
                        if (command[0] == "stop")
                        {
                            if (eventActive)
                            {
                                //                            Logger.Log("Event Stop");
                                eventActive = false;
                                for (int x = 0; x < joinedPlayers.Count; x++)
                                {
                                    UnturnedPlayer player = UnturnedPlayer.FromCSteamID(new CSteamID(Convert.ToUInt64(joinedPlayers[x].getSteamID())));
                                    player.GodMode = true;
                                    joinedPlayers[x].setDead(true);
                                    //                                Logger.Log("Event Start 2");

                                    clearInventory(player);
                                    healPlayer(player);


                                    //                                Logger.Log("Event Start 3");
                                    //                         player.GodMode = true;
                                    clearInventory(player);
                                    player.Teleport(position2, 0);

                                    UnturnedChat.Say(player, Events.Instance.Translate("events_stopped"), Events.Instance.Configuration.Instance.SuccessColor);
                                }
                            }
                            else
                            {
                                UnturnedChat.Say(caller, Events.Instance.Translate("events_stopped_already"), Events.Instance.Configuration.Instance.ErrorColor);
                            }
                        }

                        //                  Logger.Log("Command Start Finished");
                    }
                    else
                    {
                        UnturnedChat.Say(caller, Events.Instance.Translate("events_no_permission"), Events.Instance.Configuration.Instance.ErrorColor);
                        return;
                    }
                }
            }
            else
            {
                UnturnedChat.Say(caller, Events.Instance.Translate("events_not_active"), Events.Instance.Configuration.Instance.ErrorColor);
                return;
            }
        }
예제 #19
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);
            }
        }
예제 #20
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 { }
     }
 }
예제 #21
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 { }
                }
            }
        }
예제 #22
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()));
                }
            }
        }
예제 #23
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);
                        }
                    }
                }
            }
        }