public int CreateCharacter(string Account, string Name, byte Race, byte Classe, byte Gender, byte Skin, byte Face, byte HairStyle, byte HairColor, byte FacialHair, byte OutfitID) { WS_PlayerData.CharacterObject Character = new WS_PlayerData.CharacterObject(); DataTable MySQLQuery = new DataTable(); Character.Name = WorldServiceLocator._Functions.CapitalizeName(ref Name); Character.Race = (Races)Race; Character.Classe = (Classes)Classe; Character.Gender = (Genders)Gender; Character.Skin = Skin; Character.Face = Face; Character.HairStyle = HairStyle; Character.HairColor = HairColor; Character.FacialHair = FacialHair; WorldServiceLocator._WorldServer.AccountDatabase.Query($"SELECT id, gmlevel FROM account WHERE username = \"{Account}\";", ref MySQLQuery); int Account_ID = MySQLQuery.Rows[0].As <int>("id"); AccessLevel Account_Access = (Character.Access = (AccessLevel)MySQLQuery.Rows[0].As <byte>("gmlevel")); if (!WorldServiceLocator._Functions.ValidateName(Character.Name)) { return(70); } try { MySQLQuery.Clear(); WorldServiceLocator._WorldServer.CharacterDatabase.Query($"SELECT char_name FROM characters WHERE char_name = \"{Character.Name}\";", ref MySQLQuery); if (MySQLQuery.Rows.Count > 0) { return(49); } } catch (Exception projectError) { ProjectData.SetProjectError(projectError); int CreateCharacter = 48; ProjectData.ClearProjectError(); return(CreateCharacter); } checked { if (WorldServiceLocator._Global_Constants.SERVER_CONFIG_DISABLED_CLASSES[(int)Character.Classe - 1] || (WorldServiceLocator._Global_Constants.SERVER_CONFIG_DISABLED_RACES[(int)Character.Race - 1] && Account_Access < AccessLevel.GameMaster)) { return(50); } if (Account_Access <= AccessLevel.Player) { MySQLQuery.Clear(); WorldServiceLocator._WorldServer.CharacterDatabase.Query($"SELECT char_race FROM characters WHERE account_id = \"{Account_ID}\" LIMIT 1;", ref MySQLQuery); if (MySQLQuery.Rows.Count > 0 && Character.IsHorde != WorldServiceLocator._Functions.GetCharacterSide(MySQLQuery.Rows[0].As <byte>("char_race"))) { return(51); } } MySQLQuery.Clear(); WorldServiceLocator._WorldServer.CharacterDatabase.Query($"SELECT char_name FROM characters WHERE account_id = \"{Account_ID}\";", ref MySQLQuery); if (MySQLQuery.Rows.Count >= 10) { return(52); } MySQLQuery.Clear(); WorldServiceLocator._WorldServer.CharacterDatabase.Query($"SELECT char_name FROM characters WHERE account_id = \"{Account_ID}\";", ref MySQLQuery); if (MySQLQuery.Rows.Count >= 10) { return(53); } try { WorldServiceLocator._WS_Player_Initializator.InitializeReputations(ref Character); CreateCharacter(ref Character); Character.SaveAsNewCharacter(Account_ID); CreateCharacterSpells(ref Character); CreateCharacterItems(ref Character); } catch (Exception ex) { ProjectData.SetProjectError(ex); Exception err = ex; WorldServiceLocator._WorldServer.Log.WriteLine(LogType.FAILED, "Error initializing character! {0} {1}", Environment.NewLine, err.ToString()); int CreateCharacter = 48; ProjectData.ClearProjectError(); return(CreateCharacter); } finally { Character.Dispose(); } return(46); } }