2020-10-12 16:12:36 -05:00
|
|
|
import BasePlugin from './base-plugin.js';
|
|
|
|
|
|
|
|
export default class AutoTKWarn extends BasePlugin {
|
|
|
|
static get description() {
|
|
|
|
return 'The <code>AutoTkWarn</code> plugin will automatically warn players with a message when they teamkill.';
|
|
|
|
}
|
|
|
|
|
|
|
|
static get defaultEnabled() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static get optionsSpecification() {
|
|
|
|
return {
|
2022-07-12 14:28:47 -05:00
|
|
|
attackerMessage: {
|
2020-10-12 16:12:36 -05:00
|
|
|
required: false,
|
2022-07-12 14:06:03 -05:00
|
|
|
description: 'The message to warn attacking players with.',
|
2020-10-12 16:12:36 -05:00
|
|
|
default: 'Please apologise for ALL TKs in ALL chat!'
|
2022-07-12 14:06:03 -05:00
|
|
|
},
|
2022-07-12 14:28:47 -05:00
|
|
|
warnVictim: {
|
2022-07-12 14:06:03 -05:00
|
|
|
required: false,
|
|
|
|
description: 'Should we nottify the the victim, telling them that they were teamkilled via a warning message',
|
|
|
|
default: false
|
|
|
|
},
|
2022-07-12 14:28:47 -05:00
|
|
|
victimMessage: {
|
2022-07-12 14:06:03 -05:00
|
|
|
required: false,
|
|
|
|
description: 'The message that will be sent to the victim',
|
|
|
|
default: 'You were killed by your own team.'
|
2020-10-12 16:12:36 -05:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2020-12-03 08:16:07 -06:00
|
|
|
constructor(server, options, connectors) {
|
|
|
|
super(server, options, connectors);
|
2020-10-12 16:12:36 -05:00
|
|
|
|
2020-12-03 08:16:07 -06:00
|
|
|
this.onTeamkill = this.onTeamkill.bind(this);
|
|
|
|
}
|
|
|
|
|
2020-12-08 06:13:53 -06:00
|
|
|
async mount() {
|
2020-12-03 08:16:07 -06:00
|
|
|
this.server.on('TEAMKILL', this.onTeamkill);
|
|
|
|
}
|
|
|
|
|
2020-12-08 06:13:53 -06:00
|
|
|
async unmount() {
|
2020-12-03 08:16:07 -06:00
|
|
|
this.server.removeEventListener('TEAMKILL', this.onTeamkill);
|
|
|
|
}
|
|
|
|
|
|
|
|
async onTeamkill(info) {
|
2022-07-12 14:06:03 -05:00
|
|
|
if (info.attacker) {
|
2022-07-12 14:28:47 -05:00
|
|
|
this.server.rcon.warn(info.attacker.steamID, this.options.attackerMessage);
|
2022-07-12 14:07:43 -05:00
|
|
|
}
|
2022-07-12 14:28:47 -05:00
|
|
|
if (this.options.warnVictim && info.victim) {
|
|
|
|
this.server.rcon.warn(info.victim.steamID, this.options.victimMessage);
|
2022-07-12 14:07:43 -05:00
|
|
|
}
|
2020-10-12 16:12:36 -05:00
|
|
|
}
|
|
|
|
}
|