diff --git a/IW4MAdmin.sln b/IW4MAdmin.sln index b59f4a03..42c29352 100644 --- a/IW4MAdmin.sln +++ b/IW4MAdmin.sln @@ -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}" diff --git a/Plugins/ScriptPlugins/BanBroadcasting.js b/Plugins/ScriptPlugins/BanBroadcasting.js new file mode 100644 index 00000000..8f82e76c --- /dev/null +++ b/Plugins/ScriptPlugins/BanBroadcasting.js @@ -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) { + } +};