Пример #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);
        }
Пример #2
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);
        }