Exemplo n.º 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);
        }
Exemplo n.º 2
0
        public override void grantReward(Player player, bool shouldSend)
        {
            if (!Provider.isServer)
            {
                return;
            }
            Item item;

            if (this.sight > 0 || this.tactical > 0 || this.grip > 0 || this.barrel > 0 || this.magazine > 0)
            {
                ItemGunAsset itemGunAsset = Assets.find(EAssetType.ITEM, this.id) as ItemGunAsset;
                byte[]       state        = itemGunAsset.getState((this.sight <= 0) ? itemGunAsset.sightID : this.sight, (this.tactical <= 0) ? itemGunAsset.tacticalID : this.tactical, (this.grip <= 0) ? itemGunAsset.gripID : this.grip, (this.barrel <= 0) ? itemGunAsset.barrelID : this.barrel, (this.magazine <= 0) ? itemGunAsset.getMagazineID() : this.magazine, (this.ammo <= 0) ? itemGunAsset.ammoMax : this.ammo);
                item = new Item(this.id, 1, 100, state);
            }
            else
            {
                item = new Item(this.id, EItemOrigin.CRAFT);
            }
            for (byte b = 0; b < this.amount; b += 1)
            {
                player.inventory.forceAddItem(item, false, false);
            }
        }