bool chargeSign(scPlayer sPly)
        {
            try
            {
                var economyPlayer = Wolfje.Plugins.SEconomy.SEconomyPlugin.GetEconomyPlayerSafe(sPly.Index);
                var commandCost   = new Wolfje.Plugins.SEconomy.Money(this.Cost);

                if (economyPlayer.BankAccount != null)
                {
                    if (!economyPlayer.BankAccount.IsAccountEnabled)
                    {
                        sPly.TSPlayer.SendErrorMessage("You cannot use this command because your account is disabled.");
                    }
                    else if (economyPlayer.BankAccount.Balance >= this.Cost)
                    {
                        Wolfje.Plugins.SEconomy.Journal.BankTransferEventArgs trans = economyPlayer.BankAccount.TransferTo(
                            Wolfje.Plugins.SEconomy.SEconomyPlugin.WorldAccount,
                            commandCost,
                            Wolfje.Plugins.SEconomy.Journal.BankAccountTransferOptions.AnnounceToSender |
                            Wolfje.Plugins.SEconomy.Journal.BankAccountTransferOptions.IsPayment,
                            "",
                            string.Format("Sign Command charge to {0}", sPly.TSPlayer.Name)
                            );
                        if (trans.TransferSucceeded)
                        {
                            return(true);
                        }
                        else
                        {
                            sPly.TSPlayer.SendErrorMessage("Your payment failed.");
                        }
                    }
                    else
                    {
                        sPly.TSPlayer.SendErrorMessage("This Sign Command costs {0}. You need {1} more to be able to use it.",
                                                       commandCost.ToLongString(),
                                                       ((Wolfje.Plugins.SEconomy.Money)(economyPlayer.BankAccount.Balance - commandCost)).ToLongString()
                                                       );
                    }
                }
                else
                {
                    sPly.TSPlayer.SendErrorMessage("This command costs money and you don't have a bank account. Please log in first.");
                }
            }
            catch { }
            return(false);
        }
Example #2
0
        bool chargeSign(scPlayer sPly)
        {
            try
            {
                var economyPlayer = Wolfje.Plugins.SEconomy.SEconomyPlugin.GetEconomyPlayerSafe(sPly.Index);
                var commandCost = new Wolfje.Plugins.SEconomy.Money(this.Cost);

                if (economyPlayer.BankAccount != null)
                {
                    if (!economyPlayer.BankAccount.IsAccountEnabled)
                    {
                        sPly.TSPlayer.SendErrorMessage("You cannot use this command because your account is disabled.");
                    }
                    else if (economyPlayer.BankAccount.Balance >= this.Cost)
                    {
                        Wolfje.Plugins.SEconomy.Journal.BankTransferEventArgs trans = economyPlayer.BankAccount.TransferTo(
                            Wolfje.Plugins.SEconomy.SEconomyPlugin.WorldAccount,
                            commandCost,
                            Wolfje.Plugins.SEconomy.Journal.BankAccountTransferOptions.AnnounceToSender |
                            Wolfje.Plugins.SEconomy.Journal.BankAccountTransferOptions.IsPayment,
                            "",
                            string.Format("Sign Command charge to {0}", sPly.TSPlayer.Name)
                        );
                        if (trans.TransferSucceeded)
                        {
                            return true;
                        }
                        else
                        {
                            sPly.TSPlayer.SendErrorMessage("Your payment failed.");
                        }
                    }
                    else
                    {
                        sPly.TSPlayer.SendErrorMessage("This Sign Command costs {0}. You need {1} more to be able to use it.",
                            commandCost.ToLongString(),
                            ((Wolfje.Plugins.SEconomy.Money)(economyPlayer.BankAccount.Balance - commandCost)).ToLongString()
                        );
                    }
                }
                else
                {
                    sPly.TSPlayer.SendErrorMessage("This command costs money and you don't have a bank account. Please log in first.");
                }
            }
            catch { }
            return false;
        }
 bool chargeSign(scPlayer sPly)
 {
     try
     {
         var account = Wolfje.Plugins.SEconomy.SEconomyPlugin.GetEconomyPlayerSafe(sPly.Index).BankAccount;
         var CostString = new Wolfje.Plugins.SEconomy.Money((long)this.Cost).ToString();
         if (account.Balance < this.Cost)
         {
             if (sPly.AlertCooldownCooldown == 0)
             {
                 Send.Error(sPly.TSPlayer, "You must have at least {0} to execute this sign.", CostString);
                 sPly.AlertCooldownCooldown = 3;
             }
             return false;
         }
         account.Balance -= this.Cost;
         Send.Error(sPly.TSPlayer, "Charged {0}, Your balance is now {1}.", CostString, account.Balance.ToString());
         return true;
     }
     catch { return true; }
 }