Merge branch '2.4-pr' of https://github.com/RaidMax/IW4M-Admin into 2.4-pr

This commit is contained in:
RaidMax 2020-07-27 11:26:37 -05:00
commit 297e2c283f
3 changed files with 54 additions and 1 deletions

View File

@ -244,7 +244,10 @@ namespace IW4MAdmin.Application
customLocale: config?.EnableCustomLocale ?? false ? (config.CustomLocale ?? "en-US") : "en-US");
})
.AddSingleton<IManager, ApplicationManager>()
.AddSingleton(_serviceProvider => RestClient.For<IMasterApi>(Utilities.IsDevelopment ? new Uri("http://127.0.0.1:8080") : _serviceProvider.GetRequiredService<ApplicationConfiguration>().MasterUrl))
.AddSingleton(_serviceProvider => RestClient
.For<IMasterApi>(Utilities.IsDevelopment ? new Uri("http://127.0.0.1:8080") : _serviceProvider
.GetRequiredService<IConfigurationHandler<ApplicationConfiguration>>().Configuration()?.MasterUrl ??
new ApplicationConfiguration().MasterUrl))
.AddSingleton<IMasterCommunication, MasterCommunication>();
if (args.Contains("serialevents"))

View File

@ -34,6 +34,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IW4ScriptCommands", "Plugin
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ScriptPlugins", "ScriptPlugins", "{3F9ACC27-26DB-49FA-BCD2-50C54A49C9FA}"
ProjectSection(SolutionItems) = preProject
Plugins\ScriptPlugins\ActionOnReport.js = Plugins\ScriptPlugins\ActionOnReport.js
Plugins\ScriptPlugins\ParserCoD4x.js = Plugins\ScriptPlugins\ParserCoD4x.js
Plugins\ScriptPlugins\ParserIW4x.js = Plugins\ScriptPlugins\ParserIW4x.js
Plugins\ScriptPlugins\ParserPIW5.js = Plugins\ScriptPlugins\ParserPIW5.js

View File

@ -0,0 +1,49 @@
let plugin = {
author: 'RaidMax',
version: 1.0,
name: 'Action on Report',
enabled: false, // indicates if the plugin is enabled
reportAction: 'TempBan', // can be TempBan or Ban
maxReportCount: 5, // how many reports before action is taken
tempBanDurationMinutes: 60, // how long to temporarily ban the player
eventTypes: { 'report': 103 },
onEventAsync: function (gameEvent, server) {
if (!this.enabled) {
return;
}
if (gameEvent.Type === this.eventTypes['report']) {
if (!gameEvent.Target.IsIngame) {
return;
}
let reportCount = this.reportCounts[gameEvent.Target.NetworkId] === undefined ? 0 : this.reportCounts[gameEvent.Target.NetworkId];
reportCount++;
this.reportCounts[gameEvent.Target.NetworkId] = reportCount;
if (reportCount >= this.maxReportCount) {
switch (this.reportAction) {
case 'TempBan':
server.Logger.WriteInfo(`TempBanning client (id) ${gameEvent.Target.ClientId} because they received ${reportCount} reports`);
gameEvent.Target.TempBan(_localization.LocalizationIndex['PLUGINS_REPORT_ACTION'], System.TimeSpan.FromMinutes(this.tempBanDurationMinutes), _IW4MAdminClient);
break;
case 'Ban':
server.Logger.WriteInfo(`Banning client (id) ${gameEvent.Target.ClientId} because they received ${reportCount} reports`);
gameEvent.Target.Ban(_localization.LocalizationIndex['PLUGINS_REPORT_ACTION'], _IW4MAdminClient, false);
break;
}
}
}
},
onLoadAsync: function (manager) {
this.reportCounts = {};
},
onUnloadAsync: function () {
},
onTickAsync: function (server) {
}
};