Esempio n. 1
0
        public void save()
        {
            //safe against SQL injects because no user input is provided
            string query =
                "UPDATE Players SET IP='" + ip + "'" +
                ", LastLogin='******'" +
                ", totalLogin="******", totalDeaths=" + overallDeath +
                ", Money=" + money +
                ", totalBlocks=" + overallBlocks +
                ", totalKicked=" + totalKicked +
                ", TimeSpent='" + time.ToDBTime() +
                "' WHERE Name='" + name + "'";

            if (MySQLSave != null)
            {
                MySQLSave(this, query);
            }
            OnMySQLSaveEvent.Call(this, query);
            if (cancelmysql)
            {
                cancelmysql = false;
                return;
            }
            Database.executeQuery(query);
            if (Economy.Enabled && loginMoney != money)
            {
                Economy.EcoStats ecos = Economy.RetrieveEcoStats(name);
                ecos.money = money;
                Economy.UpdateEcoStats(ecos);
            }
            Server.zombie.SaveZombieStats(this);

            try {
                if (!smileySaved)
                {
                    if (parseSmiley)
                    {
                        emoteList.RemoveAll(s => s == name);
                    }
                    else
                    {
                        emoteList.Add(name);
                    }

                    File.WriteAllLines("text/emotelist.txt", emoteList.ToArray());
                    smileySaved = true;
                }
            }
            catch (Exception e) {
                Server.ErrorLog(e);
            }
            try {
                SaveUndo(this);
            } catch (Exception e) {
                Server.s.Log("Error saving undo data.");
                Server.ErrorLog(e);
            }
        }
Esempio n. 2
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);
        }
Esempio n. 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);
        }