Example #1
0
        public void CreateCharacterEvent(Client client, string playerName, Int16 playerAge, Boolean playerSex, string skinJson)
        {
            Task.Factory.StartNew(() =>
            {
                try
                {
                    PlayerModel playerModel = new PlayerModel();
                    SkinModel skinModel     = NAPI.Util.FromJson <SkinModel>(skinJson);
                    playerModel.Age         = playerAge;
                    playerModel.Sex         = playerSex;
                    // Apply the skin to the character
                    client.SetData(EntityData.PLAYER_SKIN_MODEL, skinModel);
                    Customization.ApplyPlayerCustomization(client, skinModel, playerSex);
                    int playerId = Database.CreateCharacter(client.SocialClubName, playerModel, skinModel);

                    if (playerId > 0)
                    {
                        // Database.UpdateLastCharacter(client.SocialClubName, playerId);
                        client.TriggerEvent("characterCreatedSuccessfully");
                    }
                }
                catch (Exception ex)
                {
                    Globals.log.Trace(ex);
                    NAPI.Util.ConsoleOutput("[EXCEPTION CreateCharacter] " + ex.Message);
                    NAPI.Util.ConsoleOutput("[EXCEPTION CreateCharacter] " + ex.StackTrace);
                }
            });
        }
Example #2
0
        public static void OnCharSelected(Client player, string characterName)
        {
            NAPI.Task.Run(() =>
            {
                CharacterModel characterModel    = Database.Database.LoadCharacterByName(characterName, player.Name, player.Address);
                SkinModel skinModel              = Database.Database.GetCharacterSkin(characterModel.id);
                List <ClothesModel> clothesModel = Database.Database.GetCharacterClothes(characterModel.id);

                NAPI.Util.ConsoleOutput(characterName + " вошел на сервер.");

                LoadCharacterData(player, characterModel);

                NAPI.Player.SetPlayerNametag(player, characterName);
                NAPI.Util.ConsoleOutput("{0}", characterModel.sex);
                NAPI.Player.SetPlayerSkin(player, characterModel.sex == 0 ? PedHash.FreemodeMale01 : PedHash.FreemodeFemale01);
                // Устанавливаем внешний вид игроку (в том числе и волосы).
                Customization.ApplyPlayerCustomization(player, skinModel, characterModel.sex);
                // Устанавливаем одежду игроку.
                Customization.ApplyPlayerClothes(player, clothesModel);
            });
            //player.TriggerEvent("destroyBrowser");
            player.TriggerEvent("keyListener");
        }