update player gamertags if changed, but same player ID

This commit is contained in:
SowinskiBraeden committed 2026-03-25 15:15:20 -07:00
1 parent bf95bba612
commit 67116c85be
1 file changed
+6
+6
View File
@@ -33,6 +33,7 @@ module.exports = {
if (!client.exists(playerStat)) playerStat = getDefaultPlayer(info.player, info.playerID, NitradoServerID); if (!client.exists(playerStat)) playerStat = getDefaultPlayer(info.player, info.playerID, NitradoServerID);
const newDt = await client.getDateEST(info.time); const newDt = await client.getDateEST(info.time);
playerStat.gamertag = info.player; // update username if changed
playerStat.lastConnectionDate = newDt; playerStat.lastConnectionDate = newDt;
playerStat.connected = true; playerStat.connected = true;
if (!client.exists(playerStat.connections)) playerStat.connections = 0; if (!client.exists(playerStat.connections)) playerStat.connections = 0;
@@ -87,6 +88,7 @@ module.exports = {
} else sessionTimeSeconds = 0; } else sessionTimeSeconds = 0;
if (!client.exists(playerStat.longestSessionTime)) playerStat.longestSessionTime = 0; if (!client.exists(playerStat.longestSessionTime)) playerStat.longestSessionTime = 0;
playerStat.gamertag = info.player; // update username if changed
playerStat.totalSessionTime = playerStat.totalSessionTime + sessionTimeSeconds; playerStat.totalSessionTime = playerStat.totalSessionTime + sessionTimeSeconds;
playerStat.lastSessionTime = sessionTimeSeconds; playerStat.lastSessionTime = sessionTimeSeconds;
playerStat.longestSessionTime = sessionTimeSeconds > playerStat.longestSessionTime ? sessionTimeSeconds : playerStat.longestSessionTime; playerStat.longestSessionTime = sessionTimeSeconds > playerStat.longestSessionTime ? sessionTimeSeconds : playerStat.longestSessionTime;
@@ -132,6 +134,7 @@ module.exports = {
if (!client.exists(playerStat)) playerStat = getDefaultPlayer(info.player, info.playerID, NitradoServerID); if (!client.exists(playerStat)) playerStat = getDefaultPlayer(info.player, info.playerID, NitradoServerID);
if (!client.exists(playerStat.lastConnectionDate)) playerStat.lastConnectionDate = await client.getDateEST(info.time); if (!client.exists(playerStat.lastConnectionDate)) playerStat.lastConnectionDate = await client.getDateEST(info.time);
playerStat.gamertag = info.player; // update username if changed
playerStat.lastPos = playerStat.pos; playerStat.lastPos = playerStat.pos;
playerStat.pos = info.pos; playerStat.pos = info.pos;
playerStat.lastTime = playerStat.time; playerStat.lastTime = playerStat.time;
@@ -172,9 +175,12 @@ module.exports = {
if (!client.exists(playerStat)) playerStat = getDefaultPlayer(info.player, info.playerID, NitradoServerID); if (!client.exists(playerStat)) playerStat = getDefaultPlayer(info.player, info.playerID, NitradoServerID);
if (!client.exists(attackerStat)) attackerStat = getDefaultPlayer(info.attacker, info.attackerID, NitradoServerID); if (!client.exists(attackerStat)) attackerStat = getDefaultPlayer(info.attacker, info.attackerID, NitradoServerID);
playerStat.gamertag = info.player; // update username if changed
playerStat.lastDamageDate = await client.getDateEST(info.time); playerStat.lastDamageDate = await client.getDateEST(info.time);
playerStat.lastHitBy = info.attacker; playerStat.lastHitBy = info.attacker;
attackerStat.gamertag = info.attacker; // update username if changed
if (!client.exists(playerStat.shotsLanded)) playerStat = insertPVPstats(playerStat); if (!client.exists(playerStat.shotsLanded)) playerStat = insertPVPstats(playerStat);
if (!client.exists(attackerStat.shotsLanded)) attackerStat = insertPVPstats(attackerStat); if (!client.exists(attackerStat.shotsLanded)) attackerStat = insertPVPstats(attackerStat);