示例#1
0
        internal void OnPlayerVerify(VerifiedEventArgs ev)
        {
            if (!Database.LiteDatabase.GetCollection <Player>().Exists(player => player.Id == DatabasePlayer.GetRawUserId(ev.Player)))
            {
                pluginInstance.DatabasePlayerData.AddPlayer(ev.Player);
            }

            Player databasePlayer = ev.Player.GetDatabasePlayer();

            if (Database.PlayerData.ContainsKey(ev.Player))
            {
                return;
            }

            Database.PlayerData.Add(ev.Player, databasePlayer);
            if (PreauthTime.ContainsKey(ev.Player.UserId))
            {
                databasePlayer.LastSeen = PreauthTime[ev.Player.UserId];
                PreauthTime.Remove(ev.Player.UserId);
            }
            else
            {
                databasePlayer.LastSeen = DateTime.Now;
            }
            databasePlayer.Name = ev.Player.Nickname;
            databasePlayer.Ip   = ev.Player.IPAddress;


            //Disabled that feature, it cause a lot of lag when a player join, will change it in a future update

            /*  var sameIP = Database.LiteDatabase.GetCollection<Player>().FindAll().Where(x => x.Ip == databasePlayer.Ip).ToList();
             * if (databasePlayer.Ip != ev.Player.IPAddress)
             *    pluginInstance.Functions.ChangeIP(ev.Player);
             *
             * if (sameIP.Count > 1)
             *    pluginInstance.Functions.CheckAccount(ev.Player);*/

            if (databasePlayer.FirstJoin == DateTime.MinValue)
            {
                databasePlayer.FirstJoin = DateTime.Now;
            }

            if (pluginInstance.Config.WelcomeMessage.Show)
            {
                var message = pluginInstance.Config.WelcomeMessage.Content;
                message = message.Replace("%player%", ev.Player.Nickname);
                ev.Player.Broadcast(pluginInstance.Config.WelcomeMessage.Duration, message, pluginInstance.Config.WelcomeMessage.Type, false);
            }

            if (pluginInstance.Functions.CheckAsnPlayer(ev.Player))
            {
                ev.Player.Kick($"Auto-Kick: {pluginInstance.Config.AsnKickMessage}", "SCPUtils");
            }
            else
            {
                pluginInstance.Functions.PostLoadPlayer(ev.Player);
            }
        }
示例#2
0
        internal void OnPlayerPreauth(PreAuthenticatingEventArgs ev)
        {
            if (PreauthTime.ContainsKey(ev.UserId))
            {
                PreauthTime.Remove(ev.UserId);
            }

            PreauthTime.Add(ev.UserId, DateTime.Now);
        }
示例#3
0
        internal void OnPlayerVerify(VerifiedEventArgs ev)
        {
            if (PreauthTime.ContainsKey(ev.Player.UserId))
            {
                PreauthTime.Remove(ev.Player.UserId);
            }

            PreauthTime.Add(ev.Player.UserId, DateTime.Now);
            if (!Database.LiteDatabase.GetCollection <Player>().Exists(player => player.Id == DatabasePlayer.GetRawUserId(ev.Player)))
            {
                pluginInstance.DatabasePlayerData.AddPlayer(ev.Player);
            }

            Player databasePlayer = ev.Player.GetDatabasePlayer();

            if (Database.PlayerData.ContainsKey(ev.Player))
            {
                return;
            }

            Database.PlayerData.Add(ev.Player, databasePlayer);
            databasePlayer.LastSeen = PreauthTime[ev.Player.UserId];
            PreauthTime.Remove(ev.Player.UserId);
            databasePlayer.Name = ev.Player.Nickname;
            if (databasePlayer.FirstJoin == DateTime.MinValue)
            {
                databasePlayer.FirstJoin = DateTime.Now;
            }

            if (pluginInstance.Config.WelcomeMessage.Show)
            {
                var message = pluginInstance.Config.WelcomeMessage.Content;
                message = message.Replace("%player%", ev.Player.Nickname);
                ev.Player.Broadcast(pluginInstance.Config.WelcomeMessage.Duration, message, pluginInstance.Config.WelcomeMessage.Type);
            }

            if (pluginInstance.Functions.CheckAsnPlayer(ev.Player))
            {
                ev.Player.Kick($"Auto-Kick: {pluginInstance.Config.AsnKickMessage}", "SCPUtils");
            }
            else
            {
                pluginInstance.Functions.PostLoadPlayer(ev.Player);
            }
        }