public static void AddPlayer(ReferenceHub player) { try { if (LiteDatabase.GetCollection <Player>().Exists(x => x.Id == DatabasePlayer.GetRawUserId(player))) { return; } LiteDatabase.GetCollection <Player>().Insert(new Player() { Id = DatabasePlayer.GetRawUserId(player), Name = player.GetNickname(), Authentication = DatabasePlayer.GetAuthentication(player), ScpSuicideCount = 0, TotalScpGamesPlayed = 0, TotalScpSuicideKicks = 0, TotalScpSuicideBans = 0, FirstJoin = DateTime.Now, LastSeen = DateTime.Now, ColorPreference = "", CustomNickName = "", BadgeName = "", BadgeExpire = DateTime.MinValue, HideBadge = false }); Log.Info("Trying to add ID: " + player.GetUserId().Split('@')[0] + " Discriminator: " + player.GetUserId().Split('@')[1] + " to Database"); } catch (Exception ex) { Log.Error($"Cannot add new user to Database: {player.GetNickname()} ({player.GetUserId().Split('@')[0]})!\n{ex.ToString()}"); } }
public void AddPlayer(Exiled.API.Features.Player player) { try { if (LiteDatabase.GetCollection <Player>().Exists(x => x.Id == DatabasePlayer.GetRawUserId(player))) { return; } LiteDatabase.GetCollection <Player>().Insert(new Player() { Id = DatabasePlayer.GetRawUserId(player), Name = player.Nickname, Ip = "None", Authentication = DatabasePlayer.GetAuthentication(player), ScpSuicideCount = 0, TotalScpGamesPlayed = 0, TotalScpSuicideKicks = 0, TotalScpSuicideBans = 0, RoundBanLeft = 0, FirstJoin = DateTime.Now, LastSeen = DateTime.Now, ColorPreference = "", CustomNickName = "", BadgeName = "", BadgeExpire = DateTime.MinValue, PreviousBadge = "", HideBadge = false, PlayTimeRecords = null, ASNWhitelisted = false, Restricted = null, KeepPreferences = false, IgnoreDNT = false, PlaytimeSessionsLog = null, Expire = null }); } catch (Exception ex) { Log.Error($"Cannot add new user to Database: {player.Nickname} ({player.UserId.Split('@')[0]})!\n{ex.ToString()}"); } }