From ff2d3c84adfd11258edd04082b43eeb474bedbb1 Mon Sep 17 00:00:00 2001 From: Skillet Date: Thu, 2 Mar 2023 05:18:57 -0500 Subject: [PATCH] Update db-log-addOn.js --- squadjsPlugins/db-log-addOn.js | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/squadjsPlugins/db-log-addOn.js b/squadjsPlugins/db-log-addOn.js index d09138a..428cf5f 100644 --- a/squadjsPlugins/db-log-addOn.js +++ b/squadjsPlugins/db-log-addOn.js @@ -30,6 +30,8 @@ export default class DBLogPlayerTime extends DBLog { super(server, options, connectors); this.seeding = false; + this.repairSessions = true; + this.lastTickTime = null; this.createModel( 'PlayerTime', @@ -92,7 +94,8 @@ export default class DBLogPlayerTime extends DBLog { ); let lastServerTime = lastTickTime.time; let playerOnlineID = []; - let players = await this.rcon.getListPlayers(); + console.log(this); + let players = await this.server.rcon.getListPlayers(); for (player of players){ playerOnlineID.push(player.steamID); } @@ -119,6 +122,22 @@ export default class DBLogPlayerTime extends DBLog { async onUpdatedA2SInformation(info) { await super.onUpdatedA2SInformation(info); + + if(this.repairSessions == true){ + let playerOnlineID = []; + for (player of this.server){ + playerOnlineID.push(player.steamID); + } + const {not} = Sequelize.Op; + this.models.PlayerTime.update( + { leaveTime: lastServerTime }, + { where: { + leaveTime: null, + server: this.options.overrideServerID || this.server.id, + [not]: [{player: playerOnlineID}] + } } + ); + } if((this.seeding == true) && (info.a2sPlayerCount >= this.options.seedingThreshold)){ console.log('switching to Live');