예제 #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);
 }
예제 #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);
        }
예제 #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);
        }
예제 #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);
        }
예제 #5
0
 public override void Unload(bool shutdown) {
     OnPlayerConnectEvent.Unregister(ConnectHandler.HandleConnect);
     OnPlayerCommandEvent.Unregister(ChatHandler.HandleCommand);
     OnChatEvent.Unregister(ChatHandler.HandleOnChat);
     OnPlayerStartConnectingEvent.Unregister(ConnectingHandler.HandleConnecting);
     
     OnSentMapEvent.Unregister(MiscHandlers.HandleOnMapSent);
     OnPlayerMoveEvent.Unregister(MiscHandlers.HandlePlayerMove);
     OnPlayerClickEvent.Unregister(MiscHandlers.HandlePlayerClick);
     
     OnEcoTransactionEvent.Unregister(EcoHandlers.HandleEcoTransaction);
     OnModActionEvent.Unregister(ModActionHandler.HandleModAction);            
     Server.Background.Cancel(clearTask);
 }
예제 #6
0
 public override void Load(bool startup) {
     OnPlayerConnectEvent.Register(ConnectHandler.HandleConnect, Priority.Critical);
     OnPlayerCommandEvent.Register(ChatHandler.HandleCommand, Priority.Critical);
     OnChatEvent.Register(ChatHandler.HandleOnChat, Priority.Critical);
     OnPlayerStartConnectingEvent.Register(ConnectingHandler.HandleConnecting, Priority.Critical);
     
     OnSentMapEvent.Register(MiscHandlers.HandleOnMapSent, Priority.Critical);
     OnPlayerMoveEvent.Register(MiscHandlers.HandlePlayerMove, Priority.Critical);
     OnPlayerClickEvent.Register(MiscHandlers.HandlePlayerClick, Priority.Critical);
     
     OnEcoTransactionEvent.Register(EcoHandlers.HandleEcoTransaction, Priority.Critical);
     OnModActionEvent.Register(ModActionHandler.HandleModAction, Priority.Critical);
     clearTask = Server.Background.QueueRepeat(IPThrottler.CleanupTask, null, 
                                               TimeSpan.FromMinutes(10));
 }
예제 #7
0
        public override void Unload(bool shutdown)
        {
            OnPlayerConnectEvent.Unregister(ConnectHandler.HandleConnect);
            OnPlayerCommandEvent.Unregister(ChatHandler.HandleCommand);
            OnChatEvent.Unregister(ChatHandler.HandleOnChat);
            OnPlayerStartConnectingEvent.Unregister(ConnectingHandler.HandleConnecting);

            OnSentMapEvent.Unregister(MiscHandlers.HandleSentMap);
            OnPlayerMoveEvent.Unregister(MiscHandlers.HandlePlayerMove);
            OnPlayerClickEvent.Unregister(MiscHandlers.HandlePlayerClick);
            OnChangedZoneEvent.Unregister(MiscHandlers.HandleChangedZone);

            OnEcoTransactionEvent.Unregister(EcoHandlers.HandleEcoTransaction);
            OnModActionEvent.Unregister(ModActionHandler.HandleModAction);
        }
예제 #8
0
        public override void Load(bool startup)
        {
            OnPlayerConnectEvent.Register(ConnectHandler.HandleConnect, Priority.Critical);
            OnPlayerCommandEvent.Register(ChatHandler.HandleCommand, Priority.Critical);
            OnChatEvent.Register(ChatHandler.HandleOnChat, Priority.Critical);
            OnPlayerStartConnectingEvent.Register(ConnectingHandler.HandleConnecting, Priority.Critical);

            OnSentMapEvent.Register(MiscHandlers.HandleSentMap, Priority.Critical);
            OnPlayerMoveEvent.Register(MiscHandlers.HandlePlayerMove, Priority.Critical);
            OnPlayerClickEvent.Register(MiscHandlers.HandlePlayerClick, Priority.Critical);
            OnChangedZoneEvent.Register(MiscHandlers.HandleChangedZone, Priority.Critical);

            OnEcoTransactionEvent.Register(EcoHandlers.HandleEcoTransaction, Priority.Critical);
            OnModActionEvent.Register(ModActionHandler.HandleModAction, Priority.Critical);
        }
예제 #9
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);
        }
예제 #10
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);
        }
예제 #11
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);
        }
예제 #12
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);
        }