Example #1
0
        public void CreateCharacterEvent(Client player, string playerName, int playerAge, int playerSex, string skinJson)
        {
            PlayerModel playerModel = new PlayerModel();
            SkinModel   skinModel   = NAPI.Util.FromJson <SkinModel>(skinJson);

            playerModel.realName = playerName;
            playerModel.age      = playerAge;
            playerModel.sex      = playerSex;

            // Apply the skin to the character
            player.SetData(EntityData.PLAYER_SKIN_MODEL, skinModel);
            Customization.ApplyPlayerCustomization(player, skinModel, playerSex);

            Task.Factory.StartNew(() =>
            {
                int playerId = Database.CreateCharacter(player, playerModel, skinModel);

                if (playerId > 0)
                {
                    Character.InitializePlayerData(player);
                    player.Transparency = 255;
                    player.SetData(EntityData.PLAYER_SQL_ID, playerId);
                    player.SetData(EntityData.PLAYER_NAME, playerName);
                    player.SetData(EntityData.PLAYER_AGE, playerAge);
                    player.SetData(EntityData.PLAYER_SEX, playerSex);
                    player.SetData(EntityData.PLAYER_SPAWN_POS, new Vector3(-136.0034f, 6198.949f, 32.38448f));
                    player.SetData(EntityData.PLAYER_SPAWN_ROT, new Vector3(0.0f, 0.0f, 180.0f));

                    Database.UpdateLastCharacter(player.SocialClubName, playerId);

                    player.TriggerEvent("characterCreatedSuccessfully");
                }
            });
        }
Example #2
0
        public void OnPlayerConnected(Client player)
        {
            // Set the default skin and transparency
            NAPI.Player.SetPlayerSkin(player, PedHash.Strperf01SMM);
            player.Transparency = 255;

            // Initialize the player data
            Character.InitializePlayerData(player);

            Task.Factory.StartNew(() =>
            {
                AccountModel account = Database.GetAccount(player.SocialClubName);

                switch (account.status)
                {
                case -1:
                    player.SendChatMessage(Constants.COLOR_INFO + InfoRes.account_disabled);
                    player.Kick(InfoRes.account_disabled);
                    break;

                case 0:
                    // Check if the account is registered or not
                    player.TriggerEvent(account.registered ? "accountLoginForm" : "showRegisterWindow");
                    break;

                default:
                    // Welcome message
                    string welcomeMessage = string.Format(GenRes.welcome_message, player.SocialClubName);
                    player.SendChatMessage(welcomeMessage);
                    player.SendChatMessage(GenRes.welcome_hint);
                    player.SendChatMessage(GenRes.help_hint);
                    player.SendChatMessage(GenRes.ticket_hint);

                    if (account.lastCharacter > 0)
                    {
                        // Load selected character
                        PlayerModel character = Database.LoadCharacterInformationById(account.lastCharacter);
                        SkinModel skinModel   = Database.GetCharacterSkin(account.lastCharacter);

                        player.Name = character.realName;
                        player.SetData(EntityData.PLAYER_SKIN_MODEL, skinModel);
                        NAPI.Player.SetPlayerSkin(player, character.sex == 0 ? PedHash.FreemodeMale01 : PedHash.FreemodeFemale01);

                        Character.LoadCharacterData(player, character);
                        Customization.ApplyPlayerCustomization(player, skinModel, character.sex);
                        Customization.ApplyPlayerClothes(player);
                        Customization.ApplyPlayerTattoos(player);
                    }

                    // Activate the login window
                    player.SetSharedData(EntityData.SERVER_TIME, DateTime.Now.ToString("HH:mm:ss"));

                    break;
                }
            });
        }
Example #3
0
        public void LoadCharacterEvent(Client player, string name)
        {
            Task.Factory.StartNew(() =>
            {
                PlayerModel playerModel = Database.LoadCharacterInformationByName(name);
                SkinModel skinModel     = Database.GetCharacterSkin(playerModel.id);

                // Load player's model
                player.Name = playerModel.realName;
                player.SetData(EntityData.PLAYER_SKIN_MODEL, skinModel);
                NAPI.Player.SetPlayerSkin(player, playerModel.sex == 0 ? PedHash.FreemodeMale01 : PedHash.FreemodeFemale01);

                Character.LoadCharacterData(player, playerModel);
                Customization.ApplyPlayerCustomization(player, skinModel, playerModel.sex);
                Customization.ApplyPlayerClothes(player);
                Customization.ApplyPlayerTattoos(player);

                // Update last selected character
                Database.UpdateLastCharacter(player.SocialClubName, playerModel.id);
            });
        }