For those of you who have been on my server recently and have noticed your level isn't what it was the day before, there was a problem in my SaveChar.. I was overloading mysql by saving so many strings that long..
here's the remedy! (if you start adding variables to the character database for saving)
in your catch(blah blah) {} clause in savechar replace it with:
Next, split the string into multiple strings!
(Update Characters Set 'var' = 'value', 'var2' = 'value2', ETC) try to keep it under 10 vars per string for extra saftey!
and Finally, goto public static void SaveAllChars() { in world, and replace it with this:
and that will prevent your Connection() from dying and you losing hard-earned character data!
here's the remedy! (if you start adding variables to the character database for saving)
in your catch(blah blah) {} clause in savechar replace it with:
Code:
catch (Exception Exc) {
General.WriteLine(Convert.ToString(Exc));
Connection.Close();
Connect("USER", "PASS");
if (World.SaveAllChars())
General.WriteLine("Connection to mysql server reinitiated");
else
General.WriteLine("Connection Error, server restarting! " + DateTime.Now());
}
(Update Characters Set 'var' = 'value', 'var2' = 'value2', ETC) try to keep it under 10 vars per string for extra saftey!
and Finally, goto public static void SaveAllChars() { in world, and replace it with this:
Code:
public static bool SaveAllChars()
{
try
{
foreach (DictionaryEntry DE in AllChars)
{
Character Charr = (Character)DE.Value;
DataBase.SaveChar(Charr);
}
Guilds.SaveAllGuilds();
return true;
}
catch (Exception Exc) { General.WriteLine(Convert.ToString(Exc)); return false; }
}
and that will prevent your Connection() from dying and you losing hard-earned character data!