コード例 #1
0
        public PlayerLoginMessage(Player player, PlayerLogin login)
        {
            Player = player;
            Login  = login;

            Info = $"Team {Player.TeamOrdinal} player LOGIN: [{Player.OutfitAlias}] {Player.NameDisplay} ({Player.Id})";
        }
コード例 #2
0
        private void PlayerPostLogin(TShockAPI.Hooks.PlayerPostLoginEventArgs e)
        {
            //if the player is not in the db, add them
            if (!db.Contains(e.Player.User.ID))
            {
                db.RegisterNewUser(e.Player.User.ID);
            }

            //if the player is in db but has not logged in yet
            else if (!db.HasLoggedIn(e.Player.User.ID))
            {
                //update their login streak and daily login
                db.UpdateLogin(e.Player.User.ID);
            }
            else
            {
                db.UpdateTime(e.Player.User.ID);
            }

            PlayerLogin playerLogin = OnPlayerLogin;

            if (playerLogin != null)
            {
                //fire the OnPlayerLogin event
                playerLogin(e.Player, db.GetLoginData(e.Player.User.ID));
            }
        }
コード例 #3
0
        public static async void HandlePlayerLogin(PlayerLogin playerLogin, WorldSession session)
        {
            Log.Debug($"Character with GUID '{playerLogin.PlayerGUID.CreationBits}' tried to login...");

            var character = DB.Character.Single <Character>(c => c.Guid == playerLogin.PlayerGUID.CreationBits && c.GameAccountId == session.GameAccount.Id);

            if (character != null)
            {
                var worldNode = Manager.Redirect.GetWorldNode((int)character.Map);

                if (worldNode != null)
                {
                    // Create new player.
                    session.Player = new Player(character);

                    // Suspend the current connection & redirect
                    await session.Send(new SuspendComms { Serial = 0x14 });

                    await NetHandler.SendConnectTo(session, worldNode.Address, worldNode.Port, 1);

                    // Enable key bindings, etc.
                    await session.Send(new AccountDataTimes { PlayerGuid = session.Player.Guid });

                    // Enter world.
                    Manager.Player.EnterWorld(session);
                }
            }
            else
            {
                session.Dispose();
            }
        }
コード例 #4
0
        private void OnPlayerLogin(PlayerLogin ev)
        {
            if (string.IsNullOrEmpty(ev.Username))
            {
                throw new ChatException("Username is empty");
            }

            if (string.IsNullOrEmpty(ev.Password))
            {
                throw new ChatException("Password is empty");
            }

            // May throw, as we are not in critical section it is ok
            if (!State.UsernameToPlayer.TryGetValue(ev.Username, out Tuple <string, IReactorReference> result))
            {
                Reply(new PlayerLoginResponse("Invalid username"));
                return;
            }

            if (result.Item1 != ev.Password)
            {
                Reply(new PlayerLoginResponse("Invalid password"));
                return;
            }

            EnterCriticalSection();

            Reply(new PlayerLoginResponse(result.Item2));
        }
コード例 #5
0
    public void Login(SocketIOEvent e)
    {
        PlayerLogin a = PlayerLogin.CreateFromJSON(e.data.str);

        if (a.count == 1)
        {
            name[0].text = getname.text;
        }
    }
コード例 #6
0
        [ServerEvent(Event.PlayerConnected)]// Connection Event. When did the error start happening? its now 0.3.7.0 from 0.3.6

        public void ConnectionDisplayLogin(Client client)
        {
            // Update logs with connection informati
            ConnectionLogger L = new ConnectionLogger();
            PlayerLogin      M = new PlayerLogin();

            string msg = $"Someone using the name{client.Name}  has connected to the server.";

            M.PlayerLoginWindow(client);
        }
コード例 #7
0
ファイル: AccountController.cs プロジェクト: LiviaBoeriu/P8
        public ActionResult RegisterLogin([Bind(Include = "email, password")] PlayerLogin playerLogin)
        {
            if (ModelState.IsValid)
            {
                db.PlayerLogins.Add(playerLogin);
                db.SaveChanges();
                return(RedirectToAction("Register", new { id = playerLogin.player_id }));
            }

            return(View());
        }
コード例 #8
0
        public IActionResult Login(PlayerLogin playerLogin)
        {
            Player player = Players.FindOneByLogin(playerLogin.Username, playerLogin.Password);

            if (player != null)
            {
                return(Ok(player));
            }

            return(NotFound());
        }
コード例 #9
0
    void SendScores(SocketIOEvent e)
    {
        string data = e.data.ToString();

        print(data);
        PlayerLogin userHealthJSON = PlayerLogin.CreateFromJSON(data);
        GameObject  ShowScorePre   = Instantiate(scoreprefab);

        ShowScorePre.transform.SetParent(GameObject.Find("ScorePanels").transform);
        ShowScorePre.transform.localScale = new Vector3(1, 1, 1);
        ShowScorePre.GetComponent <Player>().setname(userHealthJSON.names, userHealthJSON.count.ToString());
    }
コード例 #10
0
        private void LoginPlayer(Player player)
        {
            var message =
                $"Insert your password. Tries left: {player.LoginTries}/{Configuration.Instance.MaximumLogins}";
            var dialog = new InputDialog("Login", message, true, "Login", "Cancel");

            dialog.Show(player);
            dialog.Response += async(sender, ev) =>
            {
                if (ev.DialogButton == DialogButton.Left)
                {
                    if (player.LoginTries >= Configuration.Instance.MaximumLogins)
                    {
                        player.SendClientMessage(Color.OrangeRed,
                                                 "You exceed maximum login tries. You have been kicked!");
                        await Task.Delay(Configuration.Instance.KickDelay);

                        player.Kick();
                    }
                    else if (PasswordHashingService.VerifyPasswordHash(ev.InputText, player.Account.Password))
                    {
                        player.IsLoggedIn = true;

                        PlayerLogin?.Invoke(player, new PlayerLoginEventArgs {
                            Success = true
                        });
                    }
                    else
                    {
                        player.LoginTries++;
                        player.SendClientMessage(Color.Red, "Wrong password");

                        dialog.Message =
                            $"Wrong password! Retype your password! Tries left: {player.LoginTries}/{Configuration.Instance.MaximumLogins}";

                        LoginPlayer(player);
                    }
                }
                else
                {
                    player.Kick();
                }
            };
        }
コード例 #11
0
        private async Task Process(PlayerLoginPayload payload)
        {
            using (var factory = _dbContextHelper.GetFactory())
            {
                var dbContext = factory.GetDbContext();

                try
                {
                    var dataModel = new PlayerLogin
                    {
                        CharacterId = payload.CharacterId,
                        Timestamp   = payload.Timestamp,
                        WorldId     = payload.WorldId
                    };

                    dbContext.PlayerLogins.Add(dataModel);
                    await dbContext.SaveChangesAsync();
                }
                catch (Exception)
                {
                    //Ignore
                }
            }
        }
コード例 #12
0
 public static void HandlePlayerLogin(PlayerLogin playerLogin, WorldSession session)
 {
     Log.Message(LogType.Debug, "Character with GUID '{0}' tried to login...", playerLogin.PlayerGUID.CreationBits);
 }
コード例 #13
0
 public static void HandlePlayerLogin(PlayerLogin playerLogin, CharacterSession session)
 {
     session.Send(new CharacterLoginFailed {
         Code = CharLoginCode.NoWorld
     });
 }
コード例 #14
0
 public static void OnPlayerLogin(PlayerLoginEventArgs args)
 {
     PlayerLogin?.Invoke(args);
 }
コード例 #15
0
        public override void OnConnected(EventArgs e)
        {
            base.OnConnected(e);

            this.SetSkillLevel(WeaponSkill.Pistol, 998);
            this.SetSkillLevel(WeaponSkill.MicroUzi, 998);
            this.SetSkillLevel(WeaponSkill.SawnoffShotgun, 998);

            AcceptMP = true;

            dbContext = ((GameMode)GameMode.Instance).DbContext;

            bool userExist = false;

            userExist = dbContext.Accounts.Any(a => a.Username == this.Name);

            if (userExist)
            {
                AccountData = dbContext.Accounts
                              .Single(a => a.Username == this.Name);
            }
            else
            {
                Character charactere = dbContext.Characters.Select(x => x).Where(a => a.Name == this.Name).FirstOrDefault();
                if (charactere != null)
                {
                    this.Name   = charactere.Account.Username;
                    AccountData = dbContext.Accounts
                                  .Single(a => a.Username == this.Name);
                    userExist = true;
                }
            }


            this.ToggleSpectating(true);

            if (userExist)
            {
                PlayerLogin login = new PlayerLogin(this, SemiRP.Constants.PASSWORD_MAX_ATTEMPTS);
                login.DialogEnded += (sender, e) =>
                {
                    dbContext.Accounts.Attach(this.AccountData);

                    this.AccountData.LastConnectionIP   = this.IP;
                    this.AccountData.LastConnectionTime = DateTime.Now;

                    dbContext.SaveChanges();

                    PlayerCharacterChoice chrChoiceMenu = new PlayerCharacterChoice(this);
                    chrChoiceMenu.Show();
                };

                login.Begin();
            }
            else
            {
                PlayerRegistration regMenu = new PlayerRegistration();

                regMenu.GetMenu().Ended += (sender, e) =>
                {
                    if (!(e.Data.ContainsKey("password") && e.Data.ContainsKey("email")))
                    {
                        regMenu.Show(this);
                        return;
                    }


                    Account acc = new Account
                    {
                        Email              = (string)e.Data["email"],
                        Username           = this.Name,
                        Nickname           = this.Name,
                        Password           = (string)e.Data["password"],
                        LastConnectionIP   = this.IP,
                        LastConnectionTime = DateTime.Now,
                        PermsSet           = new PermissionSet()
                    };

                    dbContext.Add(acc);
                    dbContext.SaveChanges();

                    this.AccountData = dbContext.Accounts.Single(a => a.Username == this.Name);

                    PlayerCharacterChoice chrChoiceMenu = new PlayerCharacterChoice(this);
                    chrChoiceMenu.Show();
                };

                var regex = new Regex(@"[A-Z][a-z]+_[A-Z][a-z]+([A-Z][a-z]+)*");
                if (regex.IsMatch(this.Name))
                {
                    InputDialog nameChangerDialog = new InputDialog("Changement de nom",
                                                                    "Bienvenue sur le serveur.\nCe compte n'existe pas, cependant, nous avons détecté que vous utilisez un nom Roleplay.\n" +
                                                                    "Ce serveur utilise un système de compte avec personnage, vous créerez votre personnage par la suite.\n" +
                                                                    "Il est donc inutile de garder un nom de compte respectant le format roleplay Prénom_Nom.\n" +
                                                                    "Nous vous proposons donc de le changer ou non suivant votre souhait. Vous pouvez très bien garder le format Prénom_Nom mais il ne correspondera\n" +
                                                                    "pas au nom de votre personnage.\n" +
                                                                    "Veuillez écrire le nom du compte que vous souhaitez utiliser (max 24 charactères) :",
                                                                    false, "Confirmer", "Retour");
                    nameChangerDialog.Response += (sender, eventArg) =>
                    {
                        if (eventArg.DialogButton == DialogButton.Right)
                        {
                            nameChangerDialog.Show(this);
                            return;
                        }
                        if (eventArg.InputText.Length > 24)
                        {
                            nameChangerDialog.Show(this);
                            return;
                        }
                        if (dbContext.Accounts.Where(x => x.Username == eventArg.InputText).Any() || dbContext.Characters.Where(x => x.Name == eventArg.InputText).Any())
                        {
                            nameChangerDialog.Show(this);
                            return;
                        }
                        this.Name = eventArg.InputText;
                        regMenu.Show(this);
                    };
                    nameChangerDialog.Show(this);
                    return;
                }

                regMenu.Show(this);
            }
        }