Пример #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);
            }
        }
Пример #2
0
        internal static void LoadInfo(DataTable playerDb, Player p)
        {
            DataRow row = playerDb.Rows[0];

            p.totalLogins = int.Parse(row["totalLogin"].ToString()) + 1;
            p.time        = row["TimeSpent"].ToString().ParseDBTime();
            p.userID      = int.Parse(row["ID"].ToString());
            p.firstLogin  = DateTime.Parse(row["firstLogin"].ToString());
            p.timeLogged  = DateTime.Now;

            p.title = row["Title"].ToString().Trim();
            if (p.title != "")
            {
                p.title = p.title.Replace("[", "").Replace("]", "");
            }

            p.titlecolor = row["title_color"].ToString().Trim();
            if (p.titlecolor != "")
            {
                p.titlecolor = Colors.Parse(p.titlecolor);
            }
            else
            {
                p.titlecolor = "";
            }

            p.color = row["color"].ToString().Trim();
            if (p.color != "")
            {
                p.color = Colors.Parse(p.color);
            }
            else
            {
                p.color = p.group.color;
            }

            p.overallDeath  = int.Parse(row["TotalDeaths"].ToString());
            p.overallBlocks = long.Parse(row["totalBlocks"].ToString().Trim());
            //money = int.Parse(playerDb.Rows[0]["Money"].ToString());
            p.money       = Economy.RetrieveEcoStats(p.name).money;
            p.loginMoney  = p.money;
            p.totalKicked = int.Parse(row["totalKicked"].ToString());
        }