add player_name_changed event

This commit is contained in:
Skillet 2023-02-15 18:02:44 -05:00 committed by GitHub
parent 8c34efce76
commit 38fa85b64b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -214,9 +214,6 @@ export default class SquadServer extends EventEmitter {
console.log('logging player connected'); console.log('logging player connected');
data.player = await this.getPlayerBySteamID(data.steamID); data.player = await this.getPlayerBySteamID(data.steamID);
if (data.player) data.player.suffix = data.playerSuffix; if (data.player) data.player.suffix = data.playerSuffix;
else {
console.log(data);
}
delete data.steamID; delete data.steamID;
delete data.playerSuffix; delete data.playerSuffix;
@ -227,8 +224,6 @@ export default class SquadServer extends EventEmitter {
this.logParser.on('PLAYER_DISCONNECTED', async (data) => { this.logParser.on('PLAYER_DISCONNECTED', async (data) => {
data.player = await this.getPlayerBySteamID(data.steamID); data.player = await this.getPlayerBySteamID(data.steamID);
if (!data.player) console.log(data);
delete data.steamID; delete data.steamID;
this.emit('PLAYER_DISCONNECTED', data); this.emit('PLAYER_DISCONNECTED', data);
@ -368,6 +363,12 @@ export default class SquadServer extends EventEmitter {
for (const player of this.players) { for (const player of this.players) {
if (typeof oldPlayerInfo[player.steamID] === 'undefined') continue; if (typeof oldPlayerInfo[player.steamID] === 'undefined') continue;
if (player.name !== oldPlayerInfo[player.steamID].name)
this.emit('PLAYER_NAME_CHANGE', {
player: player,
oldName: oldPlayerInfo[player.steamID].name,
newName: player.name
});
if (player.teamID !== oldPlayerInfo[player.steamID].teamID) if (player.teamID !== oldPlayerInfo[player.steamID].teamID)
this.emit('PLAYER_TEAM_CHANGE', { this.emit('PLAYER_TEAM_CHANGE', {
player: player, player: player,