Пример #1
0
        public override void Use(Player p, string message)
        {
            if (message.IndexOf(' ') == -1)
            {
                Help(p); return;
            }
            if (message.Split(' ').Length != 2)
            {
                Help(p); return;
            }

            string user1 = "";
            string user2 = "";

            if (p == null)
            {
                user1 = "%f[ " + Server.DefaultColor + "Console%f]"; user2 = String.Format("{0}Console [&a{1}{0}]", Server.DefaultColor, Server.ZallState);
            }
            else
            {
                user1 = p.color + p.name; user2 = p.prefix + p.name;
            }

            int amountGiven;

            try { amountGiven = int.Parse(message.Split(' ')[1]); }
            catch { Player.SendMessage(p, "%cInvalid amount"); return; }
            if (amountGiven < 0)
            {
                Player.SendMessage(p, "%cCannot give negative %3" + Server.moneys); return;
            }

            Player who = Player.Find(message.Split(' ')[0]);

            Economy.EcoStats ecos;

            if (who == null)
            { //player is offline
                Player.OfflinePlayer off = Player.FindOffline(message.Split()[0]);
                if (off.name == "")
                {
                    Player.SendMessage(p, "%cThe player %f" + message.Split()[0] + Server.DefaultColor + "(offline)%c does not exist or has never logged on to this server"); return;
                }

                ecos = Economy.RetrieveEcoStats(message.Split()[0]);
                if (ReachedMax(p, ecos.money, amountGiven))
                {
                    return;
                }
                ecos.money += amountGiven;
                ecos.salary = "%f" + amountGiven + "%3 " + Server.moneys + " by " + user1 + "%3 on %f" + DateTime.Now.ToString(CultureInfo.InvariantCulture);
                Economy.UpdateEcoStats(ecos);
                //Player.GlobalMessage("%f" + ecos.playerName + Server.DefaultColor + "(offline) was given %f" + amountGiven + " %3" + Server.moneys + Server.DefaultColor + " by " + user2);
                Player.GlobalMessage(user2 + Server.DefaultColor + " gave %f" + ecos.playerName + Server.DefaultColor + "(offline)" + " %f" + amountGiven + " %3" + Server.moneys);
                return;
            }

            if (who == p /*&& p.name != Server.server_owner*/)
            {
                Player.SendMessage(p, "%cYou can't give yourself %3" + Server.moneys);
                return;
            }//I think owners should be able to give themselves money, for testing reasons..
             //although questionable, because console could give money too

            /* else if (who == p && p.name == Server.server_owner) {
             *  if (ReachedMax(p, who.money, amountGiven)) return;
             *  p.money += amountGiven;
             *  ecos = Economy.RetrieveEcoStats(p.name);
             *  ecos.money = p.money;
             *  ecos.salary = "%f" + amountGiven + " %3 " + Server.moneys + " by " + p.color + p.name + "%3 on %f" + DateTime.Now.ToString(CultureInfo.InvariantCulture);
             *  Economy.UpdateEcoStats(ecos);
             *  Player.SendMessage(p, "You gave yourself %f" + amountGiven + " %3" + Server.moneys);
             *  return;
             * }*/

            if (ReachedMax(p, who.money, amountGiven))
            {
                return;
            }
            who.money  += amountGiven;
            ecos        = Economy.RetrieveEcoStats(who.name);
            ecos.money  = who.money;
            ecos.salary = "%f" + amountGiven + "%3 " + Server.moneys + " by " + user1 + "%3 on %f" + DateTime.Now.ToString(CultureInfo.InvariantCulture);
            Economy.UpdateEcoStats(ecos);
            Player.GlobalMessage(user2 + Server.DefaultColor + " gave " + who.prefix + who.name + " %f" + amountGiven + " %3" + Server.moneys);
            //Player.GlobalMessage(who.color + who.prefix + who.name + Server.DefaultColor + " was given %f" + amountGiven + " %3" + Server.moneys + Server.DefaultColor + " by " + user2);
        }
Пример #2
0
        public override void Use(Player p, string message)
        {
            if (message.IndexOf(' ') == -1)
            {
                Help(p); return;
            }
            if (message.Split(' ').Length != 2)
            {
                Help(p); return;
            }

            string user1 = "";
            string user2 = "";

            if (p == null)
            {
                user1 = "%f[ " + Server.DefaultColor + "Console%f]"; user2 = String.Format("{0}Console [&a{1}{0}]", Server.DefaultColor, Server.ZallState);
            }
            else
            {
                user1 = p.color + p.name; user2 = p.prefix + p.name;
            }

            int  amountTaken = 0;
            bool all         = false;

            try { amountTaken = int.Parse(message.Split(' ')[1]); }
            catch
            {
                if (message.Split()[1].ToLower() != "all")
                {
                    Player.SendMessage(p, "%cInvalid amount");
                    return;
                }
                all = true;
            }
            if (amountTaken < 0)
            {
                Player.SendMessage(p, "%cYou can't take negative %3" + Server.moneys); return;
            }


            Player who = Player.Find(message.Split()[0]);

            Economy.EcoStats ecos;
            if (who == null)
            { //player is offline
                Player.OfflinePlayer off = Player.FindOffline(message.Split()[0]);
                if (off.name == "")
                {
                    Player.SendMessage(p, "%cThe player %f" + message.Split()[0] + Server.DefaultColor + "(offline)%c does not exist or has never logged on to this server"); return;
                }
                ecos = Economy.RetrieveEcoStats(message.Split()[0]);
                if (all || ecos.money - amountTaken < 0)
                {
                    amountTaken = ecos.money;
                    ecos.money  = 0;
                }
                else
                {
                    ecos.money -= amountTaken;
                }
                ecos.fine = "%f" + amountTaken + " %3" + Server.moneys + " by " + user1 + "%3 on %f" + DateTime.Now.ToString(CultureInfo.InvariantCulture);
                Economy.UpdateEcoStats(ecos);
                Player.GlobalMessage(user2 + Server.DefaultColor + " took %f" + amountTaken + " %3" + Server.moneys + Server.DefaultColor + " from " + off.color + off.name + "%f(offline)");
                return;
            }
            ecos = Economy.RetrieveEcoStats(who.name);
            if (who == p)
            {
                Player.SendMessage(p, "%cYou can't take %3" + Server.moneys + "%c from yourself");
                return;
            }

            if (all || ecos.money - amountTaken < 0)
            {
                amountTaken = who.money;
                who.money   = 0;
                ecos.money  = 0;
            }
            else
            {
                who.money -= amountTaken;
                ecos.money = who.money;
            }
            ecos.fine = "%f" + amountTaken + " %3" + Server.moneys + " by " + user1 + "%3 on %f" + DateTime.Now.ToString(CultureInfo.InvariantCulture);
            Economy.UpdateEcoStats(ecos);
            Player.GlobalMessage(user2 + Server.DefaultColor + " took %f" + amountTaken + " %3" + Server.moneys + Server.DefaultColor + " from " + who.prefix + who.name);
        }
Пример #3
0
        public override void Use(Player p, string message)
        {
            if (message.IndexOf(' ') == -1)
            {
                Help(p); return;
            }
            if (message.Split(' ').Length != 2)
            {
                Help(p); return;
            }

            Player who = Player.Find(message.Split(' ')[0]);

            Economy.EcoStats payer;
            Economy.EcoStats receiver;

            int amountPaid;

            try { amountPaid = int.Parse(message.Split(' ')[1]); }
            catch { Player.SendMessage(p, "%cInvalid amount"); return; }
            if (amountPaid < 0)
            {
                Player.SendMessage(p, "%cCannot pay negative %3" + Server.Currency); return;
            }

            if (who == null)
            { //player is offline
                Player.OfflinePlayer off = Player.FindOffline(message.Split()[0]);
                if (off.name == "")
                {
                    Player.SendMessage(p, "%cThe player %f" + message.Split()[0] + Server.DefaultColor + "(offline)%c does not exist or has never logged on to this server"); return;
                }

                payer    = Economy.RetrieveEcoStats(p.name);
                receiver = Economy.RetrieveEcoStats(message.Split()[0]);
                if (!IsLegalPayment(p, payer.money, receiver.money, amountPaid))
                {
                    return;
                }

                p.Money -= amountPaid;

                payer.money     = p.Money;
                receiver.money += amountPaid;

                payer.payment   = "%f" + amountPaid + " %3" + Server.Currency + " to " + off.color + off.name + "%3 on %f" + DateTime.Now.ToString(CultureInfo.InvariantCulture);
                receiver.salary = "%f" + amountPaid + " %3" + Server.Currency + " by " + p.color + p.name + "%3 on %f" + DateTime.Now.ToString(CultureInfo.InvariantCulture);

                Economy.UpdateEcoStats(payer);
                Economy.UpdateEcoStats(receiver);

                Player.GlobalMessage(p.prefix + p.name + Server.DefaultColor + " paid %f" + off.color + off.name + Server.DefaultColor + "(offline) %f" + amountPaid + " %3" + Server.Currency);
                return;
            }
            if (who == p)
            {
                Player.SendMessage(p, "%cYou can't pay yourself %3" + Server.Currency); return;
            }

            payer    = Economy.RetrieveEcoStats(p.name);
            receiver = Economy.RetrieveEcoStats(who.name);
            if (!IsLegalPayment(p, payer.money, receiver.money, amountPaid))
            {
                return;
            }

            p.Money   -= amountPaid;
            who.Money += amountPaid;

            payer.money    = p.Money;
            receiver.money = who.Money;

            payer.payment   = "%f" + amountPaid + " %3" + Server.Currency + " to " + who.color + who.name + "%3 on %f" + DateTime.Now.ToString(CultureInfo.InvariantCulture);
            receiver.salary = "%f" + amountPaid + " %3" + Server.Currency + " by " + p.color + p.name + "%3 on %f" + DateTime.Now.ToString(CultureInfo.InvariantCulture);

            Economy.UpdateEcoStats(payer);
            Economy.UpdateEcoStats(receiver);
            Player.GlobalMessage(p.prefix + p.name + Server.DefaultColor + " paid " + who.prefix + who.name + " %f" + amountPaid + " %3" + Server.Currency);
        }