From abbe33f22a4fd6d78055393e78b9c7d356508985 Mon Sep 17 00:00:00 2001 From: INSANEMODE Date: Sun, 23 Apr 2023 23:53:34 -0500 Subject: [PATCH] - add game interface reconnect comand - add ScriptReconnect Event --- Commands/GameInterfaceReconnectCommand.cs | 66 +++++++++++++++++++++++ Events/Script.cs | 28 +++++++++- 2 files changed, 93 insertions(+), 1 deletion(-) create mode 100644 Commands/GameInterfaceReconnectCommand.cs diff --git a/Commands/GameInterfaceReconnectCommand.cs b/Commands/GameInterfaceReconnectCommand.cs new file mode 100644 index 0000000..82993c1 --- /dev/null +++ b/Commands/GameInterfaceReconnectCommand.cs @@ -0,0 +1,66 @@ +using SharedLibraryCore; +using SharedLibraryCore.Commands; +using SharedLibraryCore.Configuration; +using SharedLibraryCore.Database.Models; +using SharedLibraryCore.Interfaces; +using SharedLibraryCore.Interfaces.Events; +using System.Threading.Tasks; + + +namespace ClanTagRankCommands.Commands +{ + + /// + /// Example script command + /// + /// + + public class GameInterfaceReconnectCommand : Command + { + + private readonly IMetaServiceV2 _metaService; + //private readonly IConfigurationHandler _configurationHandler; + private ClanTagConfiguration Config; + + + public GameInterfaceReconnectCommand(CommandConfiguration config, ITranslationLookup lookup, ClanTagConfiguration _Config, IMetaServiceV2 metaService, IConfigurationHandlerFactory configurationHandlerFactory) : base(config, lookup) + { + _metaService = metaService; + + Config = _Config; + + Name = "GameInterfaceReconnect"; + Description = "set a user's clan tag Rank (does not give permissions)"; + Alias = "gir"; + Permission = EFClient.Permission.Administrator; + RequiresTarget = false; + //Arguments = new[] + //{ + // new CommandArgument() + // { + // Name = "rank", + // Required = true + // } + //}; + } + + public override Task ExecuteAsync(GameEvent E) + { + var gir = new GameEvent() + { + Origin = Utilities.IW4MAdminClient(), + Owner = E.Owner, + Type = GameEvent.EventType.Other, + Subtype = "ScriptReconnect", + }; + + E.Owner.ExecuteEvent(gir); + return Task.CompletedTask; + + } + } +} + + + + diff --git a/Events/Script.cs b/Events/Script.cs index 6d340bf..ee8d3d4 100644 --- a/Events/Script.cs +++ b/Events/Script.cs @@ -17,6 +17,7 @@ namespace IW4MAdmin.Plugins.ClanTagRankCommands.Events private const string EVENT_RC = "RC"; private const string EVENT_ScriptBan = "ScriptBan"; + private const string EVENT_ScriptReconnect = "ScriptReconnect"; /// /// this is a custom event printed out by _clientids.gsc (used for recording highest personal round records) @@ -63,6 +64,28 @@ namespace IW4MAdmin.Plugins.ClanTagRankCommands.Events } ); } + 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"; ///// @@ -86,12 +109,15 @@ namespace IW4MAdmin.Plugins.ClanTagRankCommands.Events public IEnumerable Events => new[] { - RC(),ScriptBan() + RC(),ScriptBan(), ScriptReconnect(), }; public class ScriptBanEvent : GameScriptEvent { } + public class ScriptReconnectEvent : GameScriptEvent + { + } } }