[Release]Auto Save!!

10/26/2008 18:18 felipeboladao#1
open client.cs search for

Code:
                            if (World.AllChars.Contains(MyChar.UID))
                                World.AllChars.Remove(MyChar.UID);                          
                        }
                        catch (Exception Exc) { General.WriteLine(Exc.ToString()); }
Add below

Code:
                        Console.WriteLine("Account: " + Account + " Character " + MyChar.Name + " has logged off.");
                        World.SaveAllChars();
open General.cs search for

Code:
                GameServer = new ServerSocket();
                GameServer.Port = 5816;
                GameServer.MaxPacketSize = 4096;
                GameServer.MaxThreads = 300;
                GameServer.OnClientDisconnect += new SocketDisconnectEvent(GameDisconnectionHandler);
                GameServer.OnReceivePacket += new SocketEvent(GamePacketHandler);
                GameServer.Enabled = true;

                Console.WriteLine("");
Add below

Code:
                Thetimer = new System.Timers.Timer();
                Thetimer.Interval = 300000;
                Thetimer.Elapsed += new          ElapsedEventHandler(Thetimer_Elapsed);
                Thetimer.Start();
and Search for

Code:
public static void DoStuff()
add under

Code:
        public static void Thetimer_Elapsed(object sender, ElapsedEventArgs e)
        {
            World.SendMsgToAll("Your account has been saved", "SYSTEM", 2005);
            World.SaveAllChars();
        }
Add in timers

Code:
public static System.Timers.Timer Thetimer;
open Word.cs search for

Code:
public static void PlayersOffLottery()
add under

Code:
        public static void SaveAllChars()
        {
            try
            {
                foreach (DictionaryEntry DE in AllChars)
                {
                    Character Charr = (Character)DE.Value;
                    DataBase.SaveChar(Charr);
                }
                Guilds.SaveAllGuilds();
            }
            catch (Exception Exc) { General.WriteLine(Convert.ToString(Exc)); }
        }
open DataBase.cs search for
public static void GetCharInfo(Character Charr, string UserName)
[/code]

add under

Code:
        public static void SaveChar(Character Charr)
        {
            try
            {
                Charr.PackInventory();
                Charr.PackEquips();
                Charr.PackSkills();
                Charr.PackProfs();
                Charr.PackWarehouses();
                Charr.PackEnemies();
                Charr.PackFriends();

                MySqlCommand Command = null;
                Command = new MySqlCommand("UPDATE `Characters` SET `CharName` = '" + Charr.Name + "', `Level` = " + Charr.Level + ",`Exp` = " + Charr.Exp + ",`GuildDonation` = " + Charr.GuildDonation + ",`Strength` = " + Charr.Str + ",`Agility` = " + Charr.Agi + ",`Vitality` = " + Charr.Vit + ",`Spirit` = " + Charr.Spi + ",`Job` = " + Charr.Job + ",`Model` = " + Charr.Model + ",`Money` = " + Charr.Silvers + ",`CPs` = " + Charr.CPs + ",`CurrentHP` = " + Charr.CurHP + ",`CurrentMP` = " + Charr.CurMP + ",`StatPoints` = " + Charr.StatP + ",`MyGuild` = " + Charr.GuildID + ",`GuildPos` = " + Charr.GuildPosition + ",`LocationMap` = " + Charr.LocMap + ",`LocationX` = " + Charr.LocX + ",`LocationY` = " + Charr.LocY + ",`Hair` = " + Charr.Hair + ",`Equipment` = '" + Charr.PackedEquips + "',`Inventory` = '" + Charr.PackedInventory + "',`PKPoints` = " + Charr.PKPoints + ",`PrevMap` = " + Charr.PrevMap + ", `Skills` = '" + Charr.PackedSkills + "', `Profs` = '" + Charr.PackedProfs + "',`RBCount` = " + Charr.RBCount + ",`Avatar` = " + Charr.Avatar + ",`WHMoney` = " + Charr.WHSilvers + ",`VP` = " + Charr.VP + ",`Warehouses` = '" + Charr.PackedWHs + "',`Friends` = '" + Charr.PackedFriends + "',`dexp` = '" + Charr.dexp + "',`dexptime` = '" + Charr.dexptime + "',`Enemies` = '" + Charr.PackedEnemies + "' WHERE `Account` = '" + Charr.MyClient.Account + "'", DataBase.Connection);
                Command.ExecuteNonQuery();
            }
            catch (Exception Exc) { General.WriteLine(Convert.ToString(Exc)); }
        }


Work in all Sources..
10/26/2008 18:30 pauldexter#2
A mass save :o

P.S. My 100th post
10/26/2008 18:31 tao4229#3
loool.
Waste of memory to save all chars when 1 person loggs off.
This will just overload mysql even more.
10/26/2008 18:37 pauldexter#4
@tao4229
true
10/26/2008 19:24 $HaDoW#5
xDDDDD OMFG !!! DUDE Only last idiot dont know how to do this xD
10/26/2008 20:24 Eternal46#6
Shadow you are quite right but an effort is an effort, be a little more nice.
10/26/2008 20:50 vietkidd510#7
at least he or she is trying to help the community
10/26/2008 20:55 Eternal46#8
Quote:
Originally Posted by vietkidd510 View Post
at least he or she is trying to help the community
Exactly! :p
10/26/2008 20:56 XxArcherMasterxX#9
added to [Only registered and activated users can see links. Click Here To Register...] ;s
10/26/2008 21:40 tanelipe#10
# Removed Spam - Please try to post things that contribute thread somehow.
10/26/2008 22:47 taguro#11
Say what you guys want to, but there is a large possibility for growth here. Someone out there can learn alot from this, as long as they don't intend to leech it completely.
10/27/2008 02:23 Tw3ak#12
saving char data only when they log off = data loss if server ever crashes for any reason.
Enless your server is 100% stable ( and i have seen none here that are lol ) this is bad idea and even worse doin it this way saving ALL player data at once everytime some one logs off.

If sql and database class is done properly you can easily save individual players data at timed intervals without any problems what so ever.
10/27/2008 02:37 tao4229#13
Quote:
Originally Posted by Tw3ak View Post
saving char data only when they log off = data loss if server ever crashes for any reason.
Enless your server is 100% stable ( and i have seen none here that are lol ) this is bad idea and even worse doin it this way saving ALL player data at once everytime some one logs off.

If sql and database class is done properly you can easily save individual players data at timed intervals without any problems what so ever.
That's what I was saying... It's a waste of CPU, and if you have people constantly logging in/out, it'll also rape the connection.
10/27/2008 09:02 YukiXian#14
There already is an AutoSave in the LOFT Source...
10/27/2008 21:26 tao4229#15
Quote:
Originally Posted by YukiXian View Post
There already is an AutoSave in the LOFT Source...
it's LOTF.