Exemplo n.º 1
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.º 2
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);
            });
        }