Need Auto Save Code for 5165

09/08/2010 16:35 sohaib#1
hi, my source don't save the caracters actions some times

ex: i was lvl 120 and i had 2000cps i was in TC , i level up to 200 and i get 5kkcps and i go to BI

i relog and i find my character lvl 120 with 2000cps in TC

a friend told me you have to make auto save code to save each 2min or 2sec whatever

but i don't know what's this code and where i put it

can some one help me please?

thanks
09/08/2010 17:45 _DreadNought_#2
Are u using /exit to close the console?
09/08/2010 19:13 sohaib#3
Sure
09/08/2010 19:19 sohaib#4
they relog and find their characters didn't save without closing or opening server or doing anything in the source
09/09/2010 01:37 Arcо#5
By default, the source autosaves characters every 8 second.
09/09/2010 05:12 felipeboladao#6
make a command in cmd /close and add an event to command to save chars ;)
09/09/2010 06:05 Arcо#7
Just do a foreach statement
foreach (Character C in World.H_Chars.Values)
{
Database.SaveCharacter(C, C.MyClient.AuthInfo.Account);
}
09/09/2010 06:50 pro4never#8
Or better yet... save the modified sections every time they are changed.

If not your server will ALWAYS be exploitable and ALWAYS have rollbacks (of differing sizes)
09/09/2010 22:34 Arcо#9
That's a good idea, listen to p4n.
09/10/2010 00:10 sohaib#10
trying to understand
09/10/2010 03:33 -Fáng-#11
Well he means that when something changes, it automatically saves the change. Unfortunately, this isn't possible on a flat database like the one you're probably using. If you made it save the entire character every time one aspect changed (like location), then the server will lag and eventually crash if too many people are online! =s

You need to use MySQL or MsSql (something I just learned today). I hope you figure out something! =]
Good luck!
09/10/2010 11:47 sohaib#12
it's not possible to make a C# script anywhere to save each 8sec or 2sec?
09/10/2010 13:06 -Fáng-#13
Quote:
Originally Posted by sohaib View Post
it's not possible to make a C# script anywhere to save each 8sec or 2sec?
It is very possible... but it will make your server not able to handle a lot of people. Plus, the problem with it not saving and showing an error code is because the file is in use (aka. flat style database). Look into MySQL. It's a lot better! =]

If you're making just a simple server for friends... make a timer in the character's structure file (whatever that may be). Make the timer run when they login and make it save the character at an interval of 800. That should be 8 seconds... I can't remember if that's right. It will turn off when the character logs out since it's just a temporary server resource! Good luck!
09/10/2010 16:50 Korvacs#14
Actually you could happily have a save system run every few seconds if you wanted, you just need to have it correctly threaded and use the right locks on the objects you wish to save, however personally i think its better to perform a small save for every change that occurs. It reduces the load when saving massively.
09/10/2010 22:12 sohaib#15
guys, i'm waiting a reply like : Go to ****.cs , and search ************************ under this put *************

i'm not a C# coder , i'm a client editor and c3 artist , and the person who was coding the server gone