public static void LoadNPCsAnswers() { var sqlText = "SELECT * FROM npcs_answers"; var sqlCommand = new MySqlCommand(sqlText, Program.DBHelper.Use()); var sqlReader = sqlCommand.ExecuteReader(); while (sqlReader.Read()) { var answer = new Models.NPC.NPCsAnswer() { AnswerID = sqlReader.GetInt32("answerID"), Effects = sqlReader.GetString("effects"), }; foreach (var condi in sqlReader.GetString("conditions").Split('&')) { if (condi == "") { continue; } var condiInfos = condi.Split(';'); var condiObject = new NPCConditions(); condiObject.CondiID = int.Parse(condiInfos[0]); condiObject.Args = condiInfos[1]; answer.Conditions.Add(condiObject); } AnswersList.Add(answer); } sqlReader.Close(); Utilities.Loggers.Status.Write(string.Format("Loaded '{0}' npcsAnswers from the database !", AnswersList.Count)); }
public static void LoadNPCsAnswers() { lock (DatabaseProvider.Locker) { var sqlText = "SELECT * FROM npcs_answers"; var sqlCommand = new MySqlCommand(sqlText, DatabaseProvider.Connection); var sqlReader = sqlCommand.ExecuteReader(); while (sqlReader.Read()) { var answer = new Models.NPC.NPCsAnswer() { AnswerID = sqlReader.GetInt32("answerID"), Effects = sqlReader.GetString("effects"), }; foreach (var condi in sqlReader.GetString("conditions").Split('&')) { if (condi == "") continue; var condiInfos = condi.Split(';'); var condiObject = new Game.World.Conditions.NPCConditions(); condiObject.CondiID = int.Parse(condiInfos[0]); condiObject.Args = condiInfos[1]; answer.Conditions.Add(condiObject); } AnswersList.Add(answer); } sqlReader.Close(); } Utilities.Loggers.Status.Write(string.Format("Loaded '{0}' npcsAnswers from the database !", AnswersList.Count)); }