private void InsertCharacterData(int index, ref Character character, IConnection connection) { var logs = string.Empty; if (character.CharacterId <= 0) { var database = new DBGameDatabase(); var dbError = database.Open(); if (dbError.Number > 0) { Global.WriteLog(LogType.System, $"Failed to insert character Character Id: {character.CharacterId}", LogColor.Red); Global.WriteLog(LogType.System, $"Error Number: {dbError.Number}", LogColor.Red); Global.WriteLog(LogType.System, $"Error Message: {dbError.Message}", LogColor.Red); } else { // Se o personagem for inserido. if (database.InsertCharacter(character) > 0) { // Obter o Id do personagem. character.CharacterId = database.GetCharacterId(character.AccountId, character.CharacterIndex); new SpCharacterId(index, character.CharacterId).Send(connection); logs = $"Character Id: {character.CharacterId} Name: {character.Name} has been saved"; Global.WriteLog(LogType.Player, logs, LogColor.Green); } else { logs = $"Character Id: {character.CharacterId} Name: {character.Name} has not saved"; Global.WriteLog(LogType.Player, logs, LogColor.Red); } database.Close(); } } }