Broadcast bans (Anti-cheat and manuals) script plugin

This commit is contained in:
Amos 2022-06-01 21:03:26 +01:00 committed by RaidMax
parent 83a469cae3
commit 31da5d352e
2 changed files with 49 additions and 0 deletions

View File

@ -52,6 +52,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ScriptPlugins", "ScriptPlug
Plugins\ScriptPlugins\ParserPlutoniumT4COZM.js = Plugins\ScriptPlugins\ParserPlutoniumT4COZM.js
Plugins\ScriptPlugins\GameInterface.js = Plugins\ScriptPlugins\GameInterface.js
Plugins\ScriptPlugins\SubnetBan.js = Plugins\ScriptPlugins\SubnetBan.js
Plugins\ScriptPlugins\BanBroadcasting.js = Plugins\ScriptPlugins\BanBroadcasting.js
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutomessageFeed", "Plugins\AutomessageFeed\AutomessageFeed.csproj", "{F5815359-CFC7-44B4-9A3B-C04BACAD5836}"

View File

@ -0,0 +1,48 @@
const broadcastMessage = (server, message) => {
server.Manager.GetServers().forEach(s => {
s.Broadcast(message);
});
};
const plugin = {
author: 'Amos',
version: 1.0,
name: 'Broadcast Bans',
onEventAsync: function (gameEvent, server) {
if (!this.enableBroadcastBans) {
return;
}
if (gameEvent.TypeName === 'Ban') {
let penalty = undefined;
gameEvent.Origin.AdministeredPenalties?.forEach(p => {
penalty = p.AutomatedOffense;
})
if (gameEvent.Origin.ClientId === 1 && penalty !== undefined) {
let localization = _localization.LocalizationIndex['PLUGINS_BROADCAST_BAN_ACMESSAGE'].replace('{{targetClient}}', gameEvent.Target.CleanedName);
broadcastMessage(server, localization);
} else {
let localization = _localization.LocalizationIndex['PLUGINS_BROADCAST_BAN_MESSAGE'].replace('{{targetClient}}', gameEvent.Target.CleanedName);
broadcastMessage(server, localization);
}
}
},
onLoadAsync: function (manager) {
this.configHandler = _configHandler;
this.enableBroadcastBans = this.configHandler.GetValue('EnableBroadcastBans');
if (this.enableBroadcastBans === undefined) {
this.enableBroadcastBans = false;
this.configHandler.SetValue('EnableBroadcastBans', this.enableBroadcastBans);
}
},
onUnloadAsync: function () {
},
onTickAsync: function (server) {
}
};