Exemple #1
0
 public override void Use(Player p, string message, CommandData data) {
     EcoTransaction trans;
     bool all = false;
     if (!ParseArgs(p, message, ref all, "pay", out trans)) return;
     
     int matches = 1;
     Player who = PlayerInfo.FindMatches(p, trans.TargetName, out matches);
     if (matches > 1) return;
     if (p == who) { p.Message("You cannot pay yourself &3" + ServerConfig.Currency); return; }
     int money, srcMoney = p.IsSuper ? int.MaxValue : p.money;
     
     if (who == null) {
         trans.TargetName = Economy.FindMatches(p, trans.TargetName, out money);
         if (trans.TargetName == null) return;
         
         if (!IsLegalPayment(p, srcMoney, money, trans.Amount)) return;
         money += trans.Amount;
         Economy.UpdateMoney(trans.TargetName, money);
     } else {
         trans.TargetName = who.name; 
         money = who.money;
         
         if (!IsLegalPayment(p, srcMoney, money, trans.Amount)) return;
         who.SetMoney(who.money + trans.Amount);
     }
     
     trans.TargetFormatted = PlayerInfo.GetColoredName(p, trans.TargetName);
     trans.Type = EcoTransactionType.Payment;
     OnEcoTransactionEvent.Call(trans);
 }
Exemple #2
0
        public override void Use(Player p, string message, CommandData data)
        {
            EcoTransaction trans;
            bool           all = false;

            if (!ParseArgs(p, message, ref all, "give", out trans))
            {
                return;
            }

            int    matches = 1;
            Player who     = PlayerInfo.FindMatches(p, trans.TargetName, out matches);

            if (matches > 1)
            {
                return;
            }
            if (p == who)
            {
                p.Message("You cannot give yourself &3" + ServerConfig.Currency); return;
            }
            int money = 0;

            if (who == null)
            {
                trans.TargetName = Economy.FindMatches(p, trans.TargetName, out money);
                if (trans.TargetName == null)
                {
                    return;
                }

                if (ReachedMax(p, money, trans.Amount))
                {
                    return;
                }
                money += trans.Amount;
                Economy.UpdateMoney(trans.TargetName, money);
            }
            else
            {
                trans.TargetName = who.name;
                money            = who.money;

                if (ReachedMax(p, money, trans.Amount))
                {
                    return;
                }
                who.SetMoney(who.money + trans.Amount);
            }

            trans.TargetFormatted = PlayerInfo.GetColoredName(p, trans.TargetName);
            trans.Type            = EcoTransactionType.Give;
            OnEcoTransactionEvent.Call(trans);
        }
Exemple #3
0
        public override void Use(Player p, string message)
        {
            EcoTransaction data;
            bool           all = false;

            if (!ParseArgs(p, message, ref all, "give", out data))
            {
                return;
            }

            int    matches = 1;
            Player who     = PlayerInfo.FindMatches(p, data.TargetName, out matches);

            if (matches > 1)
            {
                return;
            }
            if (p != null && p == who)
            {
                Player.Message(p, "You cannot give yourself %3" + ServerConfig.Currency); return;
            }
            int money = 0;

            if (who == null)
            {
                data.TargetName = Economy.FindMatches(p, data.TargetName, out money);
                if (data.TargetName == null)
                {
                    return;
                }

                if (ReachedMax(p, money, data.Amount))
                {
                    return;
                }
                money += data.Amount;
                Economy.UpdateMoney(data.TargetName, money);
            }
            else
            {
                data.TargetName = who.name;
                money           = who.money;

                if (ReachedMax(p, money, data.Amount))
                {
                    return;
                }
                who.SetMoney(who.money + data.Amount);
            }

            data.TargetFormatted = PlayerInfo.GetColoredName(p, data.TargetName);
            data.Type            = EcoTransactionType.Give;
            OnEcoTransactionEvent.Call(data);
        }
Exemple #4
0
        public static void MakePurchase(Player p, int cost, string item)
        {
            p.SetMoney(p.money - cost);
            EcoTransaction transaction = new EcoTransaction();

            transaction.TargetName      = p.name;
            transaction.TargetFormatted = p.ColoredName;
            transaction.Amount          = cost;
            transaction.Type            = EcoTransactionType.Purchase;
            transaction.ItemDescription = item;
            OnEcoTransactionEvent.Call(transaction);
        }
Exemple #5
0
        public override void Use(Player p, string message, CommandData data)
        {
            EcoTransaction trans;
            bool           all = true;

            if (!ParseArgs(p, message, ref all, "take", out trans))
            {
                return;
            }

            int    matches = 1;
            Player who     = PlayerInfo.FindMatches(p, trans.TargetName, out matches);

            if (matches > 1)
            {
                return;
            }
            if (p == who)
            {
                p.Message("%WYou cannot take &3" + Server.Config.Currency + " %Wfrom yourself"); return;
            }

            int money = 0;

            if (who == null)
            {
                trans.TargetName = Economy.FindMatches(p, trans.TargetName, out money);
                if (trans.TargetName == null)
                {
                    return;
                }

                Take(ref money, all, trans);
                Economy.UpdateMoney(trans.TargetName, money);
            }
            else
            {
                trans.TargetName = who.name;
                money            = who.money;

                Take(ref money, all, trans);
                who.SetMoney(money);
            }

            trans.TargetFormatted = p.FormatNick(trans.TargetName);
            trans.Type            = EcoTransactionType.Take;
            OnEcoTransactionEvent.Call(trans);
        }
Exemple #6
0
        public override void Use(Player p, string message)
        {
            EcoTransaction data;
            bool           all = true;

            if (!ParseArgs(p, message, ref all, "take", out data))
            {
                return;
            }

            int    matches = 1;
            Player who     = PlayerInfo.FindMatches(p, data.TargetName, out matches);

            if (matches > 1)
            {
                return;
            }
            if (p != null && p == who)
            {
                Player.Message(p, "%cYou can't take %3" + ServerConfig.Currency + "%c from yourself"); return;
            }

            int money = 0;

            if (who == null)
            {
                data.TargetName = Economy.FindMatches(p, data.TargetName, out money);
                if (data.TargetName == null)
                {
                    return;
                }

                Take(ref money, all, data);
                Economy.UpdateMoney(data.TargetName, money);
            }
            else
            {
                data.TargetName = who.name;
                money           = who.money;

                Take(ref money, all, data);
                who.SetMoney(money);
            }

            data.TargetFormatted = PlayerInfo.GetColoredName(p, data.TargetName);
            data.Type            = EcoTransactionType.Take;
            OnEcoTransactionEvent.Call(data);
        }
Exemple #7
0
        public override void Use(Player p, string message, CommandData data)
        {
            EcoTransaction trans;
            bool           all = true;

            if (!ParseArgs(p, message, ref all, "take", out trans))
            {
                return;
            }

            int    matches = 1;
            Player who     = PlayerInfo.FindMatches(p, trans.TargetName, out matches);

            if (matches > 1)
            {
                return;
            }

            int money = 0;

            if (who == null)
            {
                trans.TargetName = Economy.FindMatches(p, trans.TargetName, out money);
                if (trans.TargetName == null)
                {
                    return;
                }

                Take(ref money, all, trans);
                Economy.UpdateMoney(trans.TargetName, money);
            }
            else
            {
                trans.TargetName = who.name;
                money            = who.money;

                Take(ref money, all, trans);
                who.SetMoney(money);
            }

            trans.TargetFormatted = PlayerInfo.GetColoredName(p, trans.TargetName);
            trans.Type            = EcoTransactionType.Take;
            OnEcoTransactionEvent.Call(trans);
        }
Exemple #8
0
        public override void Use(Player p, string message, CommandData data)
        {
            EcoTransaction trans;
            bool           all = false;

            if (!ParseArgs(p, message, ref all, "pay", out trans))
            {
                return;
            }

            // Player can use /pay messages to bypass a mute
            // TODO: Make MessageCmd.CanSpeak more generic so that can be used here instead
            if (trans.Reason != null && !p.CanSpeak())
            {
                p.Message("%WCannot specify a payment reason, as you cannot currently speak");
                return;
            }

            int    matches = 1;
            Player who     = PlayerInfo.FindMatches(p, trans.TargetName, out matches);

            if (matches > 1)
            {
                return;
            }
            if (p == who)
            {
                p.Message("%WYou cannot pay yourself &3" + Server.Config.Currency); return;
            }
            int money, srcMoney = p.IsSuper ? int.MaxValue : p.money;

            if (who == null)
            {
                trans.TargetName = Economy.FindMatches(p, trans.TargetName, out money);
                if (trans.TargetName == null)
                {
                    return;
                }

                if (!IsLegalPayment(p, srcMoney, money, trans.Amount))
                {
                    return;
                }
                money += trans.Amount;
                Economy.UpdateMoney(trans.TargetName, money);
            }
            else
            {
                trans.TargetName = who.name;
                money            = who.money;

                if (!IsLegalPayment(p, srcMoney, money, trans.Amount))
                {
                    return;
                }
                who.SetMoney(who.money + trans.Amount);
            }

            trans.TargetFormatted = PlayerInfo.GetColoredName(p, trans.TargetName);
            trans.Type            = EcoTransactionType.Payment;
            OnEcoTransactionEvent.Call(trans);
        }