force lastConnection date to not be nil

This commit is contained in:
SowinskiBraeden committed 2023-06-08 15:37:51 -07:00
1 parent 981102f037
commit eb6db40fac
2 files changed
+346

No files matched your search

+2
View File
@@ -64,6 +64,7 @@ module.exports = {
let newDt = await client.getDateEST(info.time);
let unixTime = Math.floor(newDt.getTime()/1000);
if (!client.exists(playerStat.lastConnectionDate)) playerStat.lastConnectionDate = client.getDateEST(info.time);
let oldUnixTime = Math.floor(playerStat.lastConnectionDate.getTime()/1000);
let seconds = unixTime - oldUnixTime;
let sessionTime = client.secondsToDhms(seconds);
@@ -106,6 +107,7 @@ module.exports = {
let playerStat = stats.find(stat => stat.playerID == info.playerID)
let playerStatIndex = stats.indexOf(playerStat);
if (playerStat == undefined) playerStat = client.getDefaultPlayerStats(info.player, info.playerID);
if (!client.exists(playerStat.lastConnectionDate)) playerStat.lastConnectionDate = client.getDateEST(info.time);
playerStat.lastPos = playerStat.pos;
playerStat.pos = info.pos;