Example #1
0
        public async Task LoadAllCustomization()
        {
            var cmd     = new MySqlCommand($"SELECT head_blend, gender, clothes, hair_color, hair_highlight_color, head_overlays, props FROM persons WHERE social_id = {SocialClubId}", MySQL.connection);
            var reader3 = cmd.ExecuteReader();

            if (reader3.Read())
            {
                Console.WriteLine("1");
                Clothes            = NAPI.Util.FromJson <Dictionary <int, ComponentVariation> >(reader3.GetString("clothes"));
                HeadOverlays       = NAPI.Util.FromJson <Dictionary <int, HeadOverlay> >(reader3.GetString("head_overlays"));
                Props              = NAPI.Util.FromJson <Dictionary <int, CPropData> >(reader3.GetString("props"));
                HairColor          = reader3.GetByte("hair_color");
                HairHighlightColor = reader3.GetByte("hair_highlight_color");
                HeadBlend headBlend = NAPI.Util.FromJson <HeadBlend>(reader3.GetString("head_blend"));
                Gender = reader3.GetInt32("gender") == 0 ? false : true;
                Console.WriteLine("2");

                reader3.Close();

                SetCustomization(Gender, headBlend, 0, HairColor, HairHighlightColor, new float[0], HeadOverlays, new Decoration[0]);
                SetPedProps(Props);
                SetPedClothes(Clothes);
                Console.WriteLine("3");
            }
        }
Example #2
0
        public static void ApplyPlayerCustomization(Client player, SkinModel skinModel, int sex)
        {
            // Populate the head
            var headBlend = new HeadBlend();
            {
                headBlend.ShapeFirst  = Convert.ToByte(skinModel.firstHeadShape);
                headBlend.ShapeSecond = Convert.ToByte(skinModel.secondHeadShape);
                headBlend.SkinFirst   = Convert.ToByte(skinModel.firstSkinTone);
                headBlend.SkinSecond  = Convert.ToByte(skinModel.secondSkinTone);
                headBlend.ShapeMix    = skinModel.headMix;
                headBlend.SkinMix     = skinModel.skinMix;
            }

            // Get the hair and eyes colors
            var eyeColor        = Convert.ToByte(skinModel.eyesColor);
            var hairColor       = Convert.ToByte(skinModel.firstHairColor);
            var hightlightColor = Convert.ToByte(skinModel.secondHairColor);

            // Add the face features
            float[] faceFeatures =
            {
                skinModel.noseWidth, skinModel.noseHeight,      skinModel.noseLength,     skinModel.noseBridge,
                skinModel.noseTip,   skinModel.noseShift,       skinModel.browHeight,
                skinModel.browWidth, skinModel.cheekboneHeight, skinModel.cheekboneWidth, skinModel.cheeksWidth,
                skinModel.eyes,      skinModel.lips,            skinModel.jawWidth,
                skinModel.jawHeight, skinModel.chinLength,      skinModel.chinPosition,   skinModel.chinWidth,
                skinModel.chinShape, skinModel.neckWidth
            };

            // Populate the head overlays
            var headOverlays = new Dictionary <int, HeadOverlay>();

            for (var i = 0; i < Constants.MAX_HEAD_OVERLAYS; i++)
            {
                // Get the overlay model and color
                var overlayData = GetOverlayData(skinModel, i);

                // Create the overlay
                var headOverlay = new HeadOverlay();
                {
                    headOverlay.Index          = Convert.ToByte(overlayData[0]);
                    headOverlay.Color          = Convert.ToByte(overlayData[1]);
                    headOverlay.SecondaryColor = 0;
                    headOverlay.Opacity        = 1.0f;
                }

                // Add the overlay
                headOverlays[i] = headOverlay;
            }

            // Update the character's skin
            player.SetCustomization(sex == Constants.SEX_MALE, headBlend, eyeColor, hairColor, hightlightColor,
                                    faceFeatures, headOverlays, new Decoration[] { });
            player.SetClothes(2, skinModel.hairModel, 0);
        }
Example #3
0
        public static void ApplyPlayerCustomization(Client player, SkinModel skinModel, int sex)
        {
            // Устанавливаем настройки головы
            HeadBlend headBlend = new HeadBlend();

            headBlend.ShapeFirst  = Convert.ToByte(skinModel.firstHeadShape);
            headBlend.ShapeSecond = Convert.ToByte(skinModel.secondHeadShape);
            headBlend.SkinFirst   = Convert.ToByte(skinModel.firstSkinTone);
            headBlend.SkinSecond  = Convert.ToByte(skinModel.secondSkinTone);
            headBlend.ShapeMix    = skinModel.headMix;
            headBlend.SkinMix     = skinModel.skinMix;

            // Получаем волосы и цвет глаз
            byte eyeColor        = Convert.ToByte(skinModel.eyesColor);
            byte hairColor       = Convert.ToByte(skinModel.firstHairColor);
            byte hightlightColor = Convert.ToByte(skinModel.secondHairColor);

            // Устанавливаем черны лица
            float[] faceFeatures = new float[]
            {
                skinModel.noseWidth, skinModel.noseHeight, skinModel.noseLength, skinModel.noseBridge, skinModel.noseTip, skinModel.noseShift, skinModel.browHeight,
                skinModel.browWidth, skinModel.cheekboneHeight, skinModel.cheekboneWidth, skinModel.cheeksWidth, skinModel.eyes, skinModel.lips, skinModel.jawWidth,
                skinModel.jawHeight, skinModel.chinLength, skinModel.chinPosition, skinModel.chinWidth, skinModel.chinShape, skinModel.neckWidth
            };


            Dictionary <int, HeadOverlay> headOverlays = new Dictionary <int, HeadOverlay>();

            for (int i = 0; i < Constants.MAX_HEAD_OVERLAYS; i++)
            {
                int[] overlayData = GetOverlayData(skinModel, i);

                HeadOverlay headOverlay = new HeadOverlay();
                headOverlay.Index          = Convert.ToByte(overlayData[0]);
                headOverlay.Color          = Convert.ToByte(overlayData[1]);
                headOverlay.SecondaryColor = 0;
                headOverlay.Opacity        = 1.0f;

                headOverlays[i] = headOverlay;
            }

            // Обновляем скин персонажа
            player.SetCustomization(sex == Constants.SEX_MALE, headBlend, eyeColor, hairColor, hightlightColor, faceFeatures, headOverlays, new Decoration[] { });
            player.SetClothes(2, skinModel.hairModel, 0);
        }
Example #4
0
        public void SetCharacter(Character.Data Char)
        {
            character = Char;

            Character.Appearance appearance = NAPI.Util.FromJson <Character.Appearance>(character.data.appearance);
            foreach (var face in appearance.facefeature)
            {
                NAPI.Player.SetPlayerFaceFeature(client, face.faceIndex, face.faceScale);
            }

            Dictionary <int, ComponentVariation> clothes = new Dictionary <int, ComponentVariation>();

            foreach (var component in appearance.components)
            {
                clothes.Add(component.componentId, new ComponentVariation {
                    Drawable = component.drawableId, Texture = component.textureId
                });
            }

            NAPI.Player.SetPlayerClothes(client, clothes);

            if (appearance.headoverlay != null)
            {
                foreach (var headoverlay in appearance.headoverlay)
                {
                    NAPI.Player.SetPlayerHeadOverlay(client, headoverlay.overlayId, new HeadOverlay {
                        Index = (byte)headoverlay.index, Color = (byte)headoverlay.firstColor, Opacity = (byte)headoverlay.opacity
                    });
                }
            }

            HeadBlend genetic = new HeadBlend
            {
                ShapeFirst  = (byte)appearance.genID,
                ShapeSecond = (byte)appearance.genID,
                SkinFirst   = (byte)appearance.genID,
                SkinSecond  = (byte)appearance.genID
            };

            NAPI.Player.SetPlayerHeadBlend(client, genetic);
            //character.Spawn();
        }
Example #5
0
        public void loadCharacter(Client player, string json)
        {
            dynamic Jony = JObject.Parse(json);

            //Gender
            int gender = Jony.gender;

            NAPI.Entity.SetEntityModel(player, gender);

            //Hair
            int hair = Jony.hair;

            NAPI.Player.SetPlayerClothes(player, 2, hair, 0);

            //Skin and Parents
            byte mother    = Jony.mother;
            byte father    = Jony.father;
            byte skinColor = Jony.skinColor;

            //MOTHER FATHER AND SKIN COLOR
            HeadBlend zaza = new HeadBlend();

            zaza.ShapeFirst  = mother;    //mother
            zaza.ShapeMix    = 0;         //works
            zaza.ShapeSecond = father;    // father
            zaza.ShapeThird  = 0;
            zaza.SkinFirst   = skinColor; //color 1
            zaza.SkinMix     = 0;         //works
            zaza.SkinSecond  = skinColor; // color 2
            zaza.SkinThird   = 0;
            zaza.ThirdMix    = 0;
            NAPI.Player.SetPlayerHeadBlend(player, zaza);

            byte eyeBrows      = Jony.eyeBrows;
            byte faceHair      = Jony.faceHair;
            byte hairColor     = Jony.hairColor;
            byte lipstickColor = Jony.lipstickColor;
            byte eyeColor      = Jony.eyeColor;

            //eyeBrows
            HeadOverlay xxx = new HeadOverlay();

            xxx.Index          = eyeBrows;
            xxx.Color          = hairColor;
            xxx.Opacity        = 1;
            xxx.SecondaryColor = hairColor;
            NAPI.Player.SetPlayerHeadOverlay(player, 2, xxx); // 8 какая фича (губы) а индекс  (какие губы)
                                                              //faceHair
            xxx.Index = faceHair;
            NAPI.Player.SetPlayerHeadOverlay(player, 1, xxx);
            //lipstickColor
            xxx.Index = lipstickColor;
            xxx.Color = 0;
            NAPI.Player.SetPlayerHeadOverlay(player, 8, xxx); // 8 какая фича (губы) а индекс  (какие губы)
                                                              //hair color
            NAPI.Player.SetPlayerHairColor(player, hairColor, hairColor);
            //Eye color
            NAPI.Player.SetPlayerEyeColor(player, eyeColor);

            //SET FACE APP FaceFeature 20 штук
            for (int i = 0; i < 20; i++)
            {
                float raz = Jony.FaceAppearance[i];
                NAPI.Player.SetPlayerFaceFeature(player, 1, raz);
            }
        }
Example #6
0
        public static void SelectCharacter(Player c, int id)
        {
            MySqlConnection conn = DatabaseAPI.API.GetInstance().GetConnection();
            MySqlCommand    cmd  = new MySqlCommand("SELECT * FROM characters_customization WHERE character_id = @character_id", conn);

            cmd.Parameters.AddWithValue("@character_id", id);
            MySqlDataReader r = cmd.ExecuteReader();

            if (r.Read())
            {
                HeadBlend headBlend = new HeadBlend
                {
                    ShapeFirst  = r.GetByte("h_ShapeFirst"),
                    ShapeSecond = r.GetByte("h_ShapeSecond"),
                    ShapeThird  = r.GetByte("h_ShapeThird"),
                    SkinFirst   = r.GetByte("h_SkinFirst"),
                    SkinSecond  = r.GetByte("h_SkinSecond"),
                    SkinThird   = r.GetByte("h_SkinThird"),
                    ShapeMix    = r.GetFloat("h_ShapeMix"),
                    SkinMix     = r.GetFloat("h_SkinMix"),
                    ThirdMix    = r.GetFloat("h_ThirdMix")
                };

                float[] faceFeatures = new float[faceFeatureNames.Length];
                for (int i = 0; i < faceFeatureNames.Length; i++)
                {
                    faceFeatures[i] = r.GetFloat(faceFeatureNames[i]);
                }

                Dictionary <int, HeadOverlay> headOverlays = new Dictionary <int, HeadOverlay>();

                for (int i = 0; i < headOverlayNames.Length; i++)
                {
                    string s = headOverlayNames[i];
                    headOverlays.Add(i, CreateHeadOverlay(r.GetByte("o_i_" + s), r.GetByte("o_c_" + s), r.GetByte("o_c2_" + s), r.GetFloat("o_o_" + s)));
                }

                c.SetData("isMale", r.GetBoolean("sex"));

                c.SetCustomization(r.GetBoolean("sex"), headBlend,
                                   r.GetByte("eyeColor"), r.GetByte("hairColor"), r.GetByte("hightlightColor"),
                                   faceFeatures, headOverlays, new Decoration[] { });

                r.Close();

                cmd = new MySqlCommand("SELECT * FROM characters_clothes WHERE character_id = @character_id", conn);
                cmd.Parameters.AddWithValue("@character_id", id);
                r = cmd.ExecuteReader();
                if (r.Read())
                {
                    c.SetData("shoes", r.GetInt32("shoes"));
                    c.SetData("legs", r.GetInt32("legs"));
                    c.SetData("tops", r.GetInt32("tops"));
                    c.SetData("torsos", r.GetInt32("torsos"));
                    c.SetData("undershirts", r.GetInt32("undershirts"));
                    c.SetData("hair", r.GetInt32("hair"));
                }
                r.Close();

                cmd = new MySqlCommand("SELECT * FROM characters WHERE id = @id", conn);
                cmd.Parameters.AddWithValue("@id", id);
                r = cmd.ExecuteReader();
                if (r.Read())
                {
                    c.SetData("adminlvl", r.GetInt32("admin"));
                    c.SetData("dim", r.GetUInt32("dim"));
                    c.Name      = r.GetString("first_name") + r.GetString("last_name");
                    c.Position  = new Vector3(r.GetFloat("last_pos_x"), r.GetFloat("last_pos_y"), r.GetFloat("last_pos_z"));
                    c.Dimension = r.GetUInt32("dim");
                }
                r.Close();

                DatabaseAPI.API.GetInstance().FreeConnection(conn);

                c.SetData("character_id", id);

                c.TriggerEvent("ShowHUD", c);
                c.TriggerEvent("LoginSuccess");

                ApplyPlayerClothes(c);
                MoneyAPI.API.SyncCash(c);

                c.SendNotification("~g~Erfolgreich eingeloggt!");
            }
            else
            {
                r.Close();
                DatabaseAPI.API.GetInstance().FreeConnection(conn);

                //Log.WriteDError("[" + id + "][" + c.Name + "]: Fehlt in {characters_customization} > Wird zu 'CharacterCreator' weitergeleitet.");
                c.SetData("temp_id", id);
                CharacterCreator(c);
            }
        }
Example #7
0
        public static void CreateCharacter(Player c, int hair, bool isMale, string headBlendJStr, byte eyeColor, byte hairColor, byte hightlightColor, string faceFeaturesStr, string headOverlaysJStr, string decorationJStr)
        {
            int characterId = c.GetData <int>("temp_id");

            HeadBlend headBlend = JsonConvert.DeserializeObject <HeadBlend>(headBlendJStr);

            float[] faceFeatures = JsonConvert.DeserializeObject <float[]>(faceFeaturesStr);
            Dictionary <int, HeadOverlay> headOverlays = JsonConvert.DeserializeObject <Dictionary <int, HeadOverlay> >(headOverlaysJStr);

            MySqlConnection conn = DatabaseAPI.API.GetInstance().GetConnection();
            MySqlCommand    cmd  = new MySqlCommand("INSERT INTO characters_customization (" +
                                                    "character_id, sex, h_ShapeFirst, h_ShapeSecond, h_ShapeThird, h_SkinFirst, h_SkinSecond, h_SkinThird, h_ShapeMix, h_SkinMix, h_ThirdMix, " +
                                                    "eyeColor, hairColor, hightlightColor, " +
                                                    "f_noseWidth, f_noseHeight, f_noseLength, f_noseBridge, f_noseTip, " +
                                                    "f_noseShift, f_browHeight, f_browWidth, f_cheekboneHeight, f_cheekboneWidth, " +
                                                    "f_cheeksWidth, f_eyes, f_lips, f_jawWidth, f_jawHeight, " +
                                                    "f_chinLength, f_chinPosition, f_chinWidth, f_chinShape, f_neckWidth, " +
                                                    "o_i_blemishes, o_c_blemishes, o_c2_blemishes, o_o_blemishes, " +
                                                    "o_i_facialHair, o_c_facialHair, o_c2_facialHair, o_o_facialHair, " +
                                                    "o_i_eyebrows, o_c_eyebrows, o_c2_eyebrows, o_o_eyebrows, " +
                                                    "o_i_ageing, o_c_ageing, o_c2_ageing, o_o_ageing, " +
                                                    "o_i_makeup, o_c_makeup, o_c2_makeup, o_o_makeup, " +
                                                    "o_i_blush, o_c_blush, o_c2_blush, o_o_blush, " +
                                                    "o_i_complexion, o_c_complexion, o_c2_complexion, o_o_complexion, " +
                                                    "o_i_sunDamage, o_c_sunDamage, o_c2_sunDamage, o_o_sunDamage, " +
                                                    "o_i_lipstick, o_c_lipstick, o_c2_lipstick, o_o_lipstick, " +
                                                    "o_i_molesFreckles, o_c_molesFreckles, o_c2_molesFreckles, o_o_molesFreckles, " +
                                                    "o_i_chestHair, o_c_chestHair, o_c2_chestHair, o_o_chestHair, " +
                                                    "o_i_bodyBlemishes, o_c_bodyBlemishes, o_c2_bodyBlemishes, o_o_bodyBlemishes, " +
                                                    "o_i_addBodyBlemishes, o_c_addBodyBlemishes, o_c2_addBodyBlemishes, o_o_addBodyBlemishes" +
                                                    ")VALUES(" +
                                                    "@character_id, @sex, @h_ShapeFirst, @h_ShapeSecond, @h_ShapeThird, @h_SkinFirst, @h_SkinSecond, @h_SkinThird, @h_ShapeMix, @h_SkinMix, @h_ThirdMix, " +
                                                    "@eyeColor, @hairColor, @hightlightColor, " +
                                                    "@f_noseWidth, @f_noseHeight, @f_noseLength, @f_noseBridge, @f_noseTip, " +
                                                    "@f_noseShift, @f_browHeight, @f_browWidth, @f_cheekboneHeight, @f_cheekboneWidth, " +
                                                    "@f_cheeksWidth, @f_eyes, @f_lips, @f_jawWidth, @f_jawHeight, " +
                                                    "@f_chinLength, @f_chinPosition, @f_chinWidth, @f_chinShape, @f_neckWidth, " +
                                                    "@o_i_blemishes, @o_c_blemishes, @o_c2_blemishes, @o_o_blemishes, " +
                                                    "@o_i_facialHair, @o_c_facialHair, @o_c2_facialHair, @o_o_facialHair, " +
                                                    "@o_i_eyebrows, @o_c_eyebrows, @o_c2_eyebrows, @o_o_eyebrows, " +
                                                    "@o_i_ageing, @o_c_ageing, @o_c2_ageing, @o_o_ageing, " +
                                                    "@o_i_makeup, @o_c_makeup, @o_c2_makeup, @o_o_makeup, " +
                                                    "@o_i_blush, @o_c_blush, @o_c2_blush, @o_o_blush, " +
                                                    "@o_i_complexion, @o_c_complexion, @o_c2_complexion, @o_o_complexion, " +
                                                    "@o_i_sunDamage, @o_c_sunDamage, @o_c2_sunDamage, @o_o_sunDamage, " +
                                                    "@o_i_lipstick, @o_c_lipstick, @o_c2_lipstick, @o_o_lipstick, " +
                                                    "@o_i_molesFreckles, @o_c_molesFreckles, o_c2_molesFreckles, o_o_molesFreckles, " +
                                                    "@o_i_chestHair, @o_c_chestHair, @o_c2_chestHair, @o_o_chestHair, " +
                                                    "@o_i_bodyBlemishes, @o_c_bodyBlemishes, @o_c2_bodyBlemishes, @o_o_bodyBlemishes, " +
                                                    "@o_i_addBodyBlemishes, @o_c_addBodyBlemishes, @o_c2_addBodyBlemishes, @o_o_addBodyBlemishes" +
                                                    ")",
                                                    conn);

            cmd.Parameters.AddWithValue("@character_id", characterId);
            cmd.Parameters.AddWithValue("@sex", isMale);

            cmd.Parameters.AddWithValue("@h_ShapeFirst", headBlend.ShapeFirst);
            cmd.Parameters.AddWithValue("@h_ShapeSecond", headBlend.ShapeSecond);
            cmd.Parameters.AddWithValue("@h_ShapeThird", headBlend.ShapeThird);
            cmd.Parameters.AddWithValue("@h_SkinFirst", headBlend.SkinFirst);
            cmd.Parameters.AddWithValue("@h_SkinSecond", headBlend.SkinSecond);
            cmd.Parameters.AddWithValue("@h_SkinThird", headBlend.SkinThird);
            cmd.Parameters.AddWithValue("@h_ShapeMix", headBlend.ShapeMix);
            cmd.Parameters.AddWithValue("@h_SkinMix", headBlend.SkinMix);
            cmd.Parameters.AddWithValue("@h_ThirdMix", headBlend.ThirdMix);

            cmd.Parameters.AddWithValue("@eyeColor", eyeColor);
            cmd.Parameters.AddWithValue("@hairColor", hairColor);
            cmd.Parameters.AddWithValue("@hightlightColor", hightlightColor);

            for (int i = 0; i < faceFeatureNames.Length; i++)
            {
                cmd.Parameters.AddWithValue("@" + faceFeatureNames[i], faceFeatures[0]);
            }

            HeadOverlay headOverlay;

            for (int i = 0; i < headOverlayNames.Length; i++)
            {
                string s = headOverlayNames[i];
                if (headOverlays.TryGetValue(i, out headOverlay))
                {
                    BindHead(cmd, s, headOverlay);
                }
                else
                {
                    BindHead(cmd, s, CreateHeadOverlay(0, 0, 0, 0));
                    Log.WriteSError("headOverlays Missing Key: " + s);
                }
            }
            cmd.ExecuteNonQuery();

            cmd = new MySqlCommand("INSERT INTO characters_clothes (character_id, hair, masks, bags, accessories, armor, decals, torsos, shoes, legs, tops, undershirts) VALUES (@charid, @hair, @masks, @bags, @accessories, @armor, @decals, @torsos, @shoes, @legs, @tops, @us)", conn);
            cmd.Parameters.AddWithValue("@charid", characterId);
            cmd.Parameters.AddWithValue("@hair", hair);
            cmd.Parameters.AddWithValue("@shoes", 4);
            if (!isMale)
            {
                cmd.Parameters.AddWithValue("@tops", 0);
                cmd.Parameters.AddWithValue("@torsos", 4);
                cmd.Parameters.AddWithValue("@us", 2);
            }
            else
            {
                cmd.Parameters.AddWithValue("@tops", 13);
                cmd.Parameters.AddWithValue("@torsos", 11);
                cmd.Parameters.AddWithValue("@us", 15);
            }
            cmd.Parameters.AddWithValue("@legs", 4);
            cmd.Parameters.AddWithValue("@masks", 0);
            cmd.Parameters.AddWithValue("@bags", 0);
            cmd.Parameters.AddWithValue("@accessories", 0);
            cmd.Parameters.AddWithValue("@armor", 0);
            cmd.Parameters.AddWithValue("@decals", 0);
            cmd.ExecuteNonQuery();

            DatabaseAPI.API.GetInstance().FreeConnection(conn);

            c.TriggerEvent("toggleCreator", false);
            SelectCharacter(c, characterId);
        }
        public static void CreateCharacter(Client c, int hair, bool isMale, string headBlendJStr, byte eyeColor, byte hairColor, byte hightlightColor, string faceFeaturesStr, string headOverlaysJStr, string decorationJStr)
        {
            Random random        = new Random();
            int    randomNumber  = random.Next(0, 99999);
            int    randomNumber2 = random.Next(0, 99999);

            HeadBlend headBlend = JsonConvert.DeserializeObject <HeadBlend>(headBlendJStr);

            float[] faceFeatures = JsonConvert.DeserializeObject <float[]>(faceFeaturesStr);
            Dictionary <int, HeadOverlay> headOverlays = JsonConvert.DeserializeObject <Dictionary <int, HeadOverlay> >(headOverlaysJStr);

            Decoration[] decorations = JsonConvert.DeserializeObject <Decoration[]>(decorationJStr);

            MySqlConnection conn = DatabaseAPI.API.GetInstance().GetConnection();
            MySqlCommand    cmd  = new MySqlCommand("INSERT INTO characters (first_name, last_name, created, account_id, p_x, p_y, p_z, cash) VALUES (@first_name, @last_name, @created, @account_id, @p_x, @p_y, @p_z, @cash)", conn);

            Console.WriteLine("Created cmd");
            cmd.Parameters.AddWithValue("@first_name", "None" + randomNumber);
            cmd.Parameters.AddWithValue("@last_name", "None" + randomNumber2);
            cmd.Parameters.AddWithValue("@created", false);
            cmd.Parameters.AddWithValue("@p_x", spawn.X);
            cmd.Parameters.AddWithValue("@p_y", spawn.Y);
            cmd.Parameters.AddWithValue("@p_z", spawn.Z);
            cmd.Parameters.AddWithValue("@account_id", c.GetData("account_id"));
            cmd.Parameters.AddWithValue("@cash", 8500);

            try
            {
                cmd.ExecuteNonQuery();
            }
            catch (MySqlException ex)
            {
                if (ex.Number == 1062)
                {
                    Log.WriteDError("Vor-/Nachname '" + "None" + randomNumber + " None" + randomNumber2 + "' existiert bereits!");
                    c.SendNotification("[~r~FEHLER~w~]: Bitte versuche es erneut.");
                    return;
                }
            }

            //DatabaseAPI.API.GetInstance().FreeConnection(conn);

            cmd = new MySqlCommand("SELECT LAST_INSERT_ID() AS id", conn);

            MySqlDataReader reader      = cmd.ExecuteReader();
            int             characterId = -1;

            if (reader.Read())
            {
                characterId = reader.GetInt32("id");
            }
            Console.WriteLine("Char Id: " + characterId);
            reader.Close();

            cmd = new MySqlCommand("INSERT INTO characters_customization (" +
                                   "character_id, sex, h_ShapeFirst, h_ShapeSecond, h_ShapeThird, h_SkinFirst, h_SkinSecond, h_SkinThird, h_ShapeMix, h_SkinMix, h_ThirdMix, " +
                                   "eyeColor, hair, hairColor, hightlightColor, " +
                                   "f_noseWidth, f_noseHeight, f_noseLength, f_noseBridge, f_noseTip, " +
                                   "f_noseShift, f_browHeight, f_browWidth, f_cheekboneHeight, f_cheekboneWidth, " +
                                   "f_cheeksWidth, f_eyes, f_lips, f_jawWidth, f_jawHeight, " +
                                   "f_chinLength, f_chinPosition, f_chinWidth, f_chinShape, f_neckWidth, " +
                                   "o_i_blemishes, o_c_blemishes, o_c2_blemishes, o_o_blemishes, " +
                                   "o_i_facialHair, o_c_facialHair, o_c2_facialHair, o_o_facialHair, " +
                                   "o_i_eyebrows, o_c_eyebrows, o_c2_eyebrows, o_o_eyebrows, " +
                                   "o_i_ageing, o_c_ageing, o_c2_ageing, o_o_ageing, " +
                                   "o_i_makeup, o_c_makeup, o_c2_makeup, o_o_makeup, " +
                                   "o_i_blush, o_c_blush, o_c2_blush, o_o_blush, " +
                                   "o_i_complexion, o_c_complexion, o_c2_complexion, o_o_complexion, " +
                                   "o_i_sunDamage, o_c_sunDamage, o_c2_sunDamage, o_o_sunDamage, " +
                                   "o_i_lipstick, o_c_lipstick, o_c2_lipstick, o_o_lipstick, " +
                                   "o_i_molesFreckles, o_c_molesFreckles, o_c2_molesFreckles, o_o_molesFreckles, " +
                                   "o_i_chestHair, o_c_chestHair, o_c2_chestHair, o_o_chestHair, " +
                                   "o_i_bodyBlemishes, o_c_bodyBlemishes, o_c2_bodyBlemishes, o_o_bodyBlemishes, " +
                                   "o_i_addBodyBlemishes, o_c_addBodyBlemishes, o_c2_addBodyBlemishes, o_o_addBodyBlemishes" +
                                   ")VALUES(" +
                                   "@character_id, @sex, @h_ShapeFirst, @h_ShapeSecond, @h_ShapeThird, @h_SkinFirst, @h_SkinSecond, @h_SkinThird, @h_ShapeMix, @h_SkinMix, @h_ThirdMix, " +
                                   "@eyeColor, @hair, @hairColor, @hightlightColor, " +
                                   "@f_noseWidth, @f_noseHeight, @f_noseLength, @f_noseBridge, @f_noseTip, " +
                                   "@f_noseShift, @f_browHeight, @f_browWidth, @f_cheekboneHeight, @f_cheekboneWidth, " +
                                   "@f_cheeksWidth, @f_eyes, @f_lips, @f_jawWidth, @f_jawHeight, " +
                                   "@f_chinLength, @f_chinPosition, @f_chinWidth, @f_chinShape, @f_neckWidth, " +
                                   "@o_i_blemishes, @o_c_blemishes, @o_c2_blemishes, @o_o_blemishes, " +
                                   "@o_i_facialHair, @o_c_facialHair, @o_c2_facialHair, @o_o_facialHair, " +
                                   "@o_i_eyebrows, @o_c_eyebrows, @o_c2_eyebrows, @o_o_eyebrows, " +
                                   "@o_i_ageing, @o_c_ageing, @o_c2_ageing, @o_o_ageing, " +
                                   "@o_i_makeup, @o_c_makeup, @o_c2_makeup, @o_o_makeup, " +
                                   "@o_i_blush, @o_c_blush, @o_c2_blush, @o_o_blush, " +
                                   "@o_i_complexion, @o_c_complexion, @o_c2_complexion, @o_o_complexion, " +
                                   "@o_i_sunDamage, @o_c_sunDamage, @o_c2_sunDamage, @o_o_sunDamage, " +
                                   "@o_i_lipstick, @o_c_lipstick, @o_c2_lipstick, @o_o_lipstick, " +
                                   "@o_i_molesFreckles, @o_c_molesFreckles, o_c2_molesFreckles, o_o_molesFreckles, " +
                                   "@o_i_chestHair, @o_c_chestHair, @o_c2_chestHair, @o_o_chestHair, " +
                                   "@o_i_bodyBlemishes, @o_c_bodyBlemishes, @o_c2_bodyBlemishes, @o_o_bodyBlemishes, " +
                                   "@o_i_addBodyBlemishes, @o_c_addBodyBlemishes, @o_c2_addBodyBlemishes, @o_o_addBodyBlemishes" +
                                   ")",
                                   conn);

            cmd.Parameters.AddWithValue("@character_id", characterId);
            cmd.Parameters.AddWithValue("@sex", isMale);

            cmd.Parameters.AddWithValue("@h_ShapeFirst", headBlend.ShapeFirst);
            cmd.Parameters.AddWithValue("@h_ShapeSecond", headBlend.ShapeSecond);
            cmd.Parameters.AddWithValue("@h_ShapeThird", headBlend.ShapeThird);
            cmd.Parameters.AddWithValue("@h_SkinFirst", headBlend.SkinFirst);
            cmd.Parameters.AddWithValue("@h_SkinSecond", headBlend.SkinSecond);
            cmd.Parameters.AddWithValue("@h_SkinThird", headBlend.SkinThird);
            cmd.Parameters.AddWithValue("@h_ShapeMix", headBlend.ShapeMix);
            cmd.Parameters.AddWithValue("@h_SkinMix", headBlend.SkinMix);
            cmd.Parameters.AddWithValue("@h_ThirdMix", headBlend.ThirdMix);

            cmd.Parameters.AddWithValue("@hair", hair);

            cmd.Parameters.AddWithValue("@eyeColor", eyeColor);
            cmd.Parameters.AddWithValue("@hairColor", hairColor);
            cmd.Parameters.AddWithValue("@hightlightColor", hightlightColor);

            for (int i = 0; i < faceFeatureNames.Length; i++)
            {
                cmd.Parameters.AddWithValue("@" + faceFeatureNames[i], faceFeatures[0]);
            }

            HeadOverlay headOverlay;

            for (int i = 0; i < headOverlayNames.Length; i++)
            {
                string s = headOverlayNames[i];
                if (headOverlays.TryGetValue(i, out headOverlay))
                {
                    BindHead(cmd, s, headOverlay);
                }
                else
                {
                    BindHead(cmd, s, CreateHeadOverlay(0, 0, 0, 0));
                    Console.WriteLine("headOverlays Missing Key: " + s);
                }
            }
            cmd.ExecuteNonQuery();

            cmd = new MySqlCommand("INSERT INTO characters_clothes (character_id, torsos, shoes, legs, tops, undershirts) VALUES (@charid, @torsos, @shoes, @legs, @tops, @us)", conn);
            cmd.Parameters.AddWithValue("@charid", characterId);
            cmd.Parameters.AddWithValue("@shoes", 4);
            if (!isMale)
            {
                cmd.Parameters.AddWithValue("@tops", 0);
                cmd.Parameters.AddWithValue("@torsos", 4);
                cmd.Parameters.AddWithValue("@us", 2);
            }
            else
            {
                cmd.Parameters.AddWithValue("@tops", 13);
                cmd.Parameters.AddWithValue("@torsos", 11);
                cmd.Parameters.AddWithValue("@us", 15);
            }
            cmd.Parameters.AddWithValue("@legs", 4);
            cmd.ExecuteNonQuery();

            c.TriggerEvent("toggleCreator", false);

            DatabaseAPI.API.GetInstance().FreeConnection(conn);

            SelectCharacter(c, characterId);
        }
        public static void SelectCharacter(Client c, int id)
        {
            Console.WriteLine("selectCharacter: " + id);

            int account_id = c.GetData("account_id");

            MySqlConnection conn = DatabaseAPI.API.GetInstance().GetConnection();
            MySqlCommand    cmd  = new MySqlCommand("SELECT * FROM characters WHERE id = @id AND account_id = @a_id", conn);

            cmd.Parameters.AddWithValue("@id", id);
            cmd.Parameters.AddWithValue("@a_id", account_id);
            MySqlDataReader r = cmd.ExecuteReader();

            if (!r.Read())
            {
                r.Close();
                DatabaseAPI.API.GetInstance().FreeConnection(conn);
            }
            NAPI.Player.SpawnPlayer(c, new Vector3(r.GetFloat("p_x"), r.GetFloat("p_y"), r.GetFloat("p_z")));
            if (r.GetUInt32("dim") != 0)
            {
                //c.Dimension = r.GetUInt32("dim");
                //c.SetData("houseid", c.Dimension);
                c.SetData("dimension", r.GetUInt32("dim"));
                c.SetData("houseid", r.GetUInt32("dim"));
            }
            else
            {
                c.SetData("dimension", r.GetUInt32("dim"));
                //c.Dimension = r.GetUInt32("dim");
            }
            c.SetData("h_key", r.GetInt32("h_key"));
            c.SetData("fraktionrank", r.GetInt32("fraktionrank"));
            c.SetData("fraktion", r.GetInt32("fraktion"));
            c.SetData("vehicles", r.GetInt32("vehicles"));
            c.SetData("PlayerPaydayTimer", r.GetInt32("payday"));
            c.SetData("createdc", r.GetBoolean("created"));
            c.SetData("jailtime", r.GetInt32("jailtime"));

            c.Name = r.GetString("first_name") + r.GetString("last_name");
            r.Close();

            cmd = new MySqlCommand("SELECT * FROM characters_customization WHERE character_id = @character_id", conn);
            cmd.Parameters.AddWithValue("@character_id", id);
            r = cmd.ExecuteReader();
            if (r.Read())
            {
                c.SetData("character_id", id);

                // Populate the head
                HeadBlend headBlend = new HeadBlend
                {
                    ShapeFirst  = r.GetByte("h_ShapeFirst"),
                    ShapeSecond = r.GetByte("h_ShapeSecond"),
                    ShapeThird  = r.GetByte("h_ShapeThird"),
                    SkinFirst   = r.GetByte("h_SkinFirst"),
                    SkinSecond  = r.GetByte("h_SkinSecond"),
                    SkinThird   = r.GetByte("h_SkinThird"),
                    ShapeMix    = r.GetFloat("h_ShapeMix"),
                    SkinMix     = r.GetFloat("h_SkinMix"),
                    ThirdMix    = r.GetFloat("h_ThirdMix")
                };

                // Add the face features

                float[] faceFeatures = new float[faceFeatureNames.Length];
                for (int i = 0; i < faceFeatureNames.Length; i++)
                {
                    faceFeatures[i] = r.GetFloat(faceFeatureNames[i]);
                }

                // Populate the head overlays
                Dictionary <int, HeadOverlay> headOverlays = new Dictionary <int, HeadOverlay>();

                for (int i = 0; i < headOverlayNames.Length; i++)
                {
                    string s = headOverlayNames[i];
                    headOverlays.Add(i, CreateHeadOverlay(r.GetByte("o_i_" + s), r.GetByte("o_c_" + s), r.GetByte("o_c2_" + s), r.GetFloat("o_o_" + s)));
                }

                c.SetData("hair", r.GetInt32("hair"));
                c.SetData("isMale", r.GetBoolean("sex"));

                // Update the character's skin
                c.SetCustomization(r.GetBoolean("sex"), headBlend,
                                   r.GetByte("eyeColor"), r.GetByte("hairColor"), r.GetByte("hightlightColor"),
                                   faceFeatures, headOverlays, new Decoration[] { });
            }
            r.Close();

            MySqlCommand cmd2 = new MySqlCommand("SELECT * FROM characters_clothes WHERE character_id = @character_id", conn);

            cmd2.Parameters.AddWithValue("@character_id", id);
            r = cmd2.ExecuteReader();
            if (r.Read())
            {
                //Klamotten der Spieler
                c.SetData("shoes", r.GetInt32("shoes"));
                c.SetData("legs", r.GetInt32("legs"));
                c.SetData("tops", r.GetInt32("tops"));
                c.SetData("torsos", r.GetInt32("torsos"));
                c.SetData("undershirts", r.GetInt32("undershirts"));
            }
            r.Close();

            DatabaseAPI.API.GetInstance().FreeConnection(conn);

            //Klamotten
            c.SetClothes(6, c.GetData("shoes"), 0);
            c.SetClothes(4, c.GetData("legs"), 0);
            c.SetClothes(11, c.GetData("tops"), 0);
            c.SetClothes(3, c.GetData("torsos"), 0);
            c.SetClothes(8, c.GetData("undershirts"), 0);

            //Haare
            c.SetClothes(2, c.GetData("hair"), 0);

            if (c.GetData("createdc") == false)
            {
                c.TriggerEvent("StartCharBrowser");
                return;
            }

            c.Dimension = c.GetData("dimension");

            c.ResetData("createdc");

            MoneyAPI.API.SyncCash(c);
            BankAPI.API.SyncCash(c);
            InventoryAPI.API.SyncItems(c);
            Player.PlayerUpdate.SyncPlayer(c);

            c.TriggerEvent("namehud", c);
            Player.PlayerTime.OnStartPayday(c);
            if (Init.Init.LSPDDoorLock == 1)
            {
                c.TriggerEvent("LSPDGateOpen");
            }
            c.SendNotification("Deine Haare werden wahrscheinlich erst beim nächsten Login sichtbar sein!");
            c.SendNotification("Du kannst ganz einfach mit '/dc' dich disconnecten und mit F1 wieder connecten.");
        }