Exemplo n.º 1
0
        public override string getContext(string desc, byte[] state)
        {
            ushort            id = BitConverter.ToUInt16(state, 8);
            ItemMagazineAsset itemMagazineAsset = (ItemMagazineAsset)Assets.find(EAssetType.ITEM, id);

            if (itemMagazineAsset != null)
            {
                desc += PlayerDashboardInventoryUI.localization.format("Ammo", new object[]
                {
                    string.Concat(new string[]
                    {
                        "<color=",
                        Palette.hex(ItemTool.getRarityColorUI(itemMagazineAsset.rarity)),
                        ">",
                        itemMagazineAsset.itemName,
                        "</color>"
                    }),
                    state[10],
                    itemMagazineAsset.amount
                });
            }
            else
            {
                desc += PlayerDashboardInventoryUI.localization.format("Ammo", new object[]
                {
                    PlayerDashboardInventoryUI.localization.format("None"),
                    0,
                    0
                });
            }
            desc += "\n\n";
            return(desc);
        }
Exemplo n.º 2
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()));
                }
            }
        }
Exemplo n.º 3
0
        public decimal GetCost(bool Negative, int amount, SDG.Unturned.ItemGunAsset gun, SDG.Unturned.ItemMagazineAsset magazine)
        {
            decimal cost;

            if (EasyAmmo.Instance.Configuration.Instance.ScaleCostByWeaponDamage)
            {
                cost = (decimal)(gun.playerDamageMultiplier.damage * amount) *
                       EasyAmmo.Instance.Configuration.Instance.WeaponDamageCostMultiplier;
            }
            else
            {
                cost = (decimal)(magazine.amount * amount) *
                       EasyAmmo.Instance.Configuration.Instance.PerBulletCostMultiplier;
            }

            if (Negative)
            {
                cost = -cost;
            }

            //Logger.Log(cost.ToString());
            return(cost);
        }