124 lines
4.4 KiB
C#
124 lines
4.4 KiB
C#
using Serilog.Debugging;
|
|
using SharedLibraryCore;
|
|
using SharedLibraryCore.Database.Models;
|
|
using SharedLibraryCore.Events.Game;
|
|
using SharedLibraryCore.Interfaces;
|
|
using System.Collections.Generic;
|
|
using System.Globalization;
|
|
using EventGeneratorCallback = System.ValueTuple<string, string,
|
|
System.Func<string, SharedLibraryCore.Interfaces.IEventParserConfiguration,
|
|
SharedLibraryCore.GameEvent,
|
|
SharedLibraryCore.GameEvent>>;
|
|
|
|
namespace IW4MAdmin.Plugins.ClanTagRankCommands.Events
|
|
{
|
|
public class Script : IRegisterEvent
|
|
{
|
|
|
|
private const string EVENT_RC = "RC";
|
|
private const string EVENT_ScriptBan = "ScriptBan";
|
|
private const string EVENT_ScriptReconnect = "ScriptReconnect";
|
|
|
|
/// <summary>
|
|
/// this is a custom event printed out by _clientids.gsc (used for recording highest personal round records)
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
private EventGeneratorCallback RC()
|
|
{
|
|
return (EVENT_RC, EVENT_RC, (string eventLine, IEventParserConfiguration config, GameEvent autoEvent) =>
|
|
{
|
|
string[] lineSplit = eventLine.Split(";");
|
|
|
|
|
|
long originId = lineSplit[1].ConvertGuidToLong(config.GuidNumberStyle, 1);
|
|
|
|
autoEvent.Type = GameEvent.EventType.Other;
|
|
autoEvent.Origin = new EFClient() { NetworkId = originId };
|
|
autoEvent.RequiredEntity = GameEvent.EventRequiredEntity.Origin;
|
|
autoEvent.GameTime = autoEvent.GameTime;
|
|
autoEvent.Subtype = EVENT_RC;
|
|
|
|
return autoEvent;
|
|
}
|
|
);
|
|
}
|
|
private EventGeneratorCallback ScriptBan()
|
|
{
|
|
return (EVENT_ScriptBan, EVENT_ScriptBan, (eventLine, _, _) =>
|
|
{
|
|
string[] lineSplit = eventLine.Split(";");
|
|
|
|
|
|
long originId = lineSplit[1].ConvertGuidToLong(NumberStyles.Integer);
|
|
int clientnum = int.Parse(lineSplit[2]);
|
|
var scriptBan = new ScriptBanEvent
|
|
|
|
{
|
|
Type = GameEvent.EventType.Other,
|
|
Subtype = EVENT_ScriptBan,
|
|
Origin = Utilities.IW4MAdminClient(),
|
|
Target = new EFClient { NetworkId = originId, Name = lineSplit[3], ClientNumber = clientnum },
|
|
ScriptData = eventLine
|
|
};
|
|
return scriptBan;
|
|
}
|
|
);
|
|
}
|
|
private EventGeneratorCallback ScriptReconnect()
|
|
{
|
|
return (EVENT_ScriptReconnect, EVENT_ScriptReconnect, (eventLine, _, _) =>
|
|
{
|
|
string[] lineSplit = eventLine.Split(";");
|
|
|
|
|
|
//long originId = lineSplit[1].ConvertGuidToLong(NumberStyles.Integer);
|
|
//int clientnum = int.Parse(lineSplit[2]);
|
|
var ScriptReconnect = new ScriptReconnectEvent
|
|
|
|
{
|
|
Type = GameEvent.EventType.Other,
|
|
Subtype = EVENT_ScriptReconnect,
|
|
Origin = Utilities.IW4MAdminClient(),
|
|
//Target = new EFClient { NetworkId = originId, Name = lineSplit[3], ClientNumber = clientnum },
|
|
ScriptData = eventLine
|
|
};
|
|
return ScriptReconnect;
|
|
}
|
|
);
|
|
}
|
|
//private const string EVENT_RoundNumber = "RoundNumber";
|
|
|
|
///// <summary>
|
|
///// this is a custom event printed out by _clientids.gsc (used for recording highest server round records)
|
|
///// </summary>
|
|
///// <returns></returns>
|
|
//private EventGeneratorCallback RoundNumber()
|
|
//{
|
|
// return (EVENT_RoundNumber, EVENT_RoundNumber, (string eventLine, IEventParserConfiguration config, GameEvent autoEvent) =>
|
|
// {
|
|
// string[] lineSplit = eventLine.Split(";");
|
|
|
|
// autoEvent.Type = GameEvent.EventType.RoundNumber;
|
|
// autoEvent.Origin = Utilities.IW4MAdminClient();
|
|
// autoEvent.GameTime = autoEvent.GameTime;
|
|
|
|
// return autoEvent;
|
|
// }
|
|
// );
|
|
//}
|
|
public IEnumerable<EventGeneratorCallback> Events =>
|
|
new[]
|
|
{
|
|
RC(),ScriptBan(), ScriptReconnect(),
|
|
|
|
};
|
|
|
|
public class ScriptBanEvent : GameScriptEvent
|
|
{
|
|
}
|
|
public class ScriptReconnectEvent : GameScriptEvent
|
|
{
|
|
}
|
|
}
|
|
}
|