示例#1
0
        public static void MakePurchase(Player p, int cost, string item)
        {
            p.SetMoney(p.money - cost);
            Player.Message(p, "Your balance is now &f{0} &3{1}", p.money, Server.moneys);

            Economy.EcoStats stats = RetrieveStats(p.name);
            stats.TotalSpent += cost;
            stats.Purchase    = item + "%3 for %f" + cost + " %3" + Server.moneys +
                                " on %f" + DateTime.Now.ToString(CultureInfo.InvariantCulture);
            Economy.UpdateStats(stats);
        }
 public override void Use(Player p, string message)
 {
     p.lastCMD = "cheat";             // We don't want them to bypass by typing '/'
     string[] args = message.SplitSpaces();
     if (args.Length == 0)
     {
         return;
     }
     if (args[0] != "secret-code-here")
     {
         p.Message("You cannot use this command normally!"); return;
     }
     p.SetMoney(p.money + int.Parse(args[1]));             // Will error if you don't specify an amount
     // Not really any point in checking because it's a secret command
 }
示例#3
0
        void DoLottery()
        {
            string[] players = Lottery.Items;
            if (players.Length == 0)
            {
                return;
            }

            // Ensure the players are actually online
            List <Player> online = new List <Player>(players.Length);

            foreach (string name in players)
            {
                Player pl = PlayerInfo.FindExact(name);
                if (pl == null)
                {
                    continue;
                }
                online.Add(pl);
                Economy.EcoStats stats = Economy.RetrieveStats(pl.name);
                stats.TotalSpent += 10;
                Economy.UpdateStats(stats);
            }
            if (online.Count == 0)
            {
                return;
            }

            int    amount = 10;
            Player winner = online[0];

            if (online.Count == 1)
            {
                winner.SendMessage("Your money was refunded as you were " +
                                   "the only player still in the lottery.");
            }
            else
            {
                Random rand = new Random();
                winner = online[rand.Next(online.Count)];
                amount = 9 * online.Count;
                Chat.Message(ChatScope.Global, "%b" + winner.truename + " %7won the lottery for &a"
                             + amount + " " + Server.Config.Currency + "%7.", null, null, true);
            }
            Lottery.Clear();
            winner.SetMoney(winner.money + amount);
        }
示例#4
0
        public override void Use(Player p, string message, CommandData data)
        {
            string[] players = Lottery.Items;
            if (message == "list")
            {
                if (players.Length != 0)
                {
                    p.Message("Players in the lottery: " + players.Join());
                }
                else
                {
                    p.Message("Nobody has entered the lottery yet");
                }
                return;
            }

            if (p.money < 10)
            {
                p.Message("You need &f10 " + Server.Config.Currency + " %Sto enter the lottery."); return;
            }

            for (int i = 0; i < players.Length; i++)
            {
                if (players[i].CaselessEq(p.name))
                {
                    p.Message("You are already in the lottery, which has &a"
                              + players.Length + " %Splayers in it."); return;
                }
            }

            if (players.Length == 0)
            {
                Chat.Message(ChatScope.Global, "%b" + p.truename + " %7started the lottery. Type %b/lottery %7to join.", null, null, true);
                Server.MainScheduler.QueueRepeat(DoLotteryTick, null, TimeSpan.FromSeconds(30));
            }

            else
            {
                Chat.Message(ChatScope.Global, "%b" + p.truename + " %7entered the lottery.", null, null, true);
            }

            p.SetMoney(p.money - 10);
            Lottery.Add(p.name);
        }