Exemplo n.º 1
0
        public void CreateCharacterEvent(Client player, string playerName, int playerAge, int playerSex,
                                         string skinJson)
        {
            var playerModel = new PlayerModel();
            var 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(() => {
                var 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.SetSharedData(EntityData.PLAYER_SPAWN_POS, new Vector3(402.9364f, -996.7154f, -99.00024f));
                    player.SetSharedData(EntityData.PLAYER_SPAWN_ROT, new Vector3(0.0f, 0.0f, 180.0f));

                    Database.UpdateLastCharacter(player.SocialClubName, playerId);

                    player.TriggerEvent("characterCreatedSuccessfully");
                }
            });
        }
Exemplo n.º 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(() => {
                var 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
                    var 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
                        var character = Database.LoadCharacterInformationById(account.lastCharacter);
                        var 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;
                }
            });
        }
Exemplo n.º 3
0
        public void LoadCharacterEvent(Client player, string name)
        {
            Task.Factory.StartNew(() => {
                var playerModel = Database.LoadCharacterInformationByName(name);
                var 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);
            });
        }