mirror of
https://github.com/AsgardEternal/SquadJS.git
synced 2024-09-28 11:54:23 -05:00
Use RoundEnd event for DBlog
This commit is contained in:
parent
3bc566365e
commit
70e2be8c51
1
.gitignore
vendored
1
.gitignore
vendored
@ -13,3 +13,4 @@ yarn.lock
|
||||
.idea/
|
||||
.vs/
|
||||
/squad-server/plugins/db-log-addOn.js
|
||||
/squad-server/plugins/mapvote.js
|
||||
|
@ -206,6 +206,25 @@ export default class SquadServer extends EventEmitter {
|
||||
this.emit('NEW_GAME', data);
|
||||
});
|
||||
|
||||
this.logParser.on('ROUND_ENDED', async (data) => {
|
||||
const datalayer = await Layers.getLayerById(data.winner.layer);
|
||||
const outdata = {
|
||||
rawData: data,
|
||||
rawLayer: data.winner.layer,
|
||||
rawLevel: data.winner.level,
|
||||
time: data.time,
|
||||
winnerId: data.winner.team,
|
||||
winnerFaction: data.winner.faction,
|
||||
winnerTickets: data.winner.tickets,
|
||||
loserId: data.loser.team,
|
||||
loserFaction: data.loser.faction,
|
||||
loserTickets: data.loser.tickets,
|
||||
layer: datalayer
|
||||
};
|
||||
|
||||
this.emit("ROUND_ENDED", outdata);
|
||||
})
|
||||
|
||||
this.logParser.on('PLAYER_CONNECTED', async (data) => {
|
||||
data.player = await this.getPlayerBySteamID(data.steamID);
|
||||
if (data.player) {
|
||||
|
@ -14,8 +14,8 @@ export default {
|
||||
loser: logParser.eventStore.ROUND_LOSER ? logParser.eventStore.ROUND_LOSER : null,
|
||||
time: args[1]
|
||||
};
|
||||
logParser.emit('ROUND_ENDED', data);
|
||||
delete logParser.eventStore.ROUND_WINNER;
|
||||
delete logParser.eventStore.ROUND_LOSER;
|
||||
logParser.emit('ROUND_ENDED', data);
|
||||
}
|
||||
};
|
||||
|
@ -392,6 +392,7 @@ export default class DBLog extends BasePlugin {
|
||||
this.onTickRate = this.onTickRate.bind(this);
|
||||
this.onUpdatedA2SInformation = this.onUpdatedA2SInformation.bind(this);
|
||||
this.onNewGame = this.onNewGame.bind(this);
|
||||
this.onRoundEnd = this.onRoundEnd.bind(this);
|
||||
this.onPlayerNameChange = this.onPlayerNameChange.bind(this);
|
||||
this.onPlayerWounded = this.onPlayerWounded.bind(this);
|
||||
this.onPlayerDied = this.onPlayerDied.bind(this);
|
||||
@ -426,6 +427,7 @@ export default class DBLog extends BasePlugin {
|
||||
this.server.on('TICK_RATE', this.onTickRate);
|
||||
this.server.on('UPDATED_A2S_INFORMATION', this.onUpdatedA2SInformation);
|
||||
this.server.on('NEW_GAME', this.onNewGame);
|
||||
this.server.on('ROUND_ENDED', this.onRoundEnd);
|
||||
this.server.on('PLAYER_NAME_CHANGE', this.onPlayerNameChange);
|
||||
this.server.on('PLAYER_WOUNDED', this.onPlayerWounded);
|
||||
this.server.on('PLAYER_DIED', this.onPlayerDied);
|
||||
@ -442,6 +444,7 @@ export default class DBLog extends BasePlugin {
|
||||
this.server.removeEventListener('TICK_RATE', this.onTickRate);
|
||||
this.server.removeEventListener('UPDATED_A2S_INFORMATION', this.onTickRate);
|
||||
this.server.removeEventListener('NEW_GAME', this.onNewGame);
|
||||
this.server.removeEventListener('ROUND_ENDED', this.onRoundEnd);
|
||||
this.server.removeEventListener('PLAYER_NAME_CHANGE', this.onPlayerNameChange);
|
||||
this.server.removeEventListener('PLAYER_WOUNDED', this.onPlayerWounded);
|
||||
this.server.removeEventListener('PLAYER_DIED', this.onPlayerDied);
|
||||
@ -484,6 +487,13 @@ export default class DBLog extends BasePlugin {
|
||||
});
|
||||
}
|
||||
|
||||
async onRoundEnd(info){
|
||||
await this.models.Match.update(
|
||||
{ endTime: info.time, winner: info.winnerFaction },
|
||||
{ where: { server: this.options.overrideServerID || this.server.id, endTime: null } }
|
||||
);
|
||||
}
|
||||
|
||||
async onPlayerNameChange(info) {
|
||||
if(info.player)
|
||||
await this.models.SteamUser.upsert({
|
||||
|
Loading…
Reference in New Issue
Block a user