示例#1
0
        public void Execute(IRocketPlayer caller, string[] command)
        {
            var player = (UnturnedPlayer)caller;

            if (player.GetGroup() == CSteamID.Nil)
            {
                player.SendMessage("NO_GROUP");
                return;
            }

            if (player.GetBank() != null)
            {
                player.SendMessage("ALREADY_HAVE_A_BANK");
                return;
            }

            if (UconomyUtil.GetBalance(player.Id) < Plugin.Instance.Configuration.Instance.BankPrice)
            {
                player.SendMessage("BANK_BUY_ERROR", Plugin.Instance.Configuration.Instance.BankPrice, UconomyUtil.MoneyName);
                return;
            }

            UconomyUtil.IncreaseBalance(player.Id, -Plugin.Instance.Configuration.Instance.BankPrice);
            Plugin.Instance.Bank.AddBank(player.SteamGroupID.ToString());

            player.SendMessage("BANK_BOUGHT", Plugin.Instance.Configuration.Instance.BankPrice, UconomyUtil.MoneyName);
            player.SendGroupMessage("BANK_BOUGHT_GROUP", player.DisplayName);
        }
示例#2
0
        public void Execute(IRocketPlayer caller, string[] command)
        {
            var player = (UnturnedPlayer)caller;

            if (command.Length != 2 || !command[0].Equals("+") || !command[0].Equals("-") ||
                !command[1].All(char.IsDigit) || !decimal.TryParse(command[1], out var money))
            {
                player.SendMessage($"/{Name} {Syntax}");
                return;
            }

            var bank = player.GetBank();

            if (bank == null)
            {
                player.SendMessage("NO_BANK");
                return;
            }

            var deposit = command[0].Equals("+");
            var balance = player.GetBalance();

            if (money > (deposit ? balance : bank.Money))
            {
                player.SendMessage(deposit ? "DEPOSIT_ERROR" : "WITHDRAW_ERROR", deposit ? balance : bank.Money);
                return;
            }

            bank.Money += (deposit ? money : -money);

            UconomyUtil.IncreaseBalance(player.Id, deposit ? -money : money);
            Plugin.Instance.Bank.UpdateBank(bank);

            player.SendGroupMessage("BANK");
            player.SendGroupMessage("BANK_MONEY", $"{bank.Money} [{(deposit ? "+" : "-")} {money}]", UconomyUtil.MoneyName);
            player.SendGroupMessage("BANK_EXP", bank.Experience);
        }