more integration tweaks
add configurable flood protect interval for rcon
This commit is contained in:
parent
07f675eadc
commit
12dfd8c558
@ -31,6 +31,7 @@ namespace IW4MAdmin.Application.RConParsers
|
||||
public string NoticeLineSeparator { get; set; } = Environment.NewLine;
|
||||
public int? DefaultRConPort { get; set; }
|
||||
public string DefaultInstallationDirectoryHint { get; set; }
|
||||
public short FloodProtectInterval { get; set; } = 750;
|
||||
|
||||
public ColorCodeMapping ColorCodeMapping { get; set; } = new ColorCodeMapping
|
||||
{
|
||||
@ -59,4 +60,4 @@ namespace IW4MAdmin.Application.RConParsers
|
||||
MaxPlayersStatus = parserRegexFactory.CreateParserRegex();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,53 +0,0 @@
|
||||
#include common_scripts\utility;
|
||||
#include maps\mp\_utility;
|
||||
#include maps\mp\gametypes\_hud_util;
|
||||
#include maps\mp\gametypes\_playerlogic;
|
||||
|
||||
init()
|
||||
{
|
||||
SetDvarIfUninitialized( "sv_iw4madmin_command", "" );
|
||||
level thread WaitForCommand();
|
||||
}
|
||||
|
||||
WaitForCommand()
|
||||
{
|
||||
level endon( "game_ended" );
|
||||
|
||||
for(;;)
|
||||
{
|
||||
commandInfo = strtok( getDvar("sv_iw4madmin_command"), ";" );
|
||||
command = commandInfo[0];
|
||||
|
||||
switch( command )
|
||||
{
|
||||
case "alert":
|
||||
//clientId alertType sound message
|
||||
SendAlert( commandInfo[1], commandInfo[2], commandInfo[3], commandInfo[4] );
|
||||
break;
|
||||
case "killplayer":
|
||||
// clientId
|
||||
KillPlayer( commandInfo[1], commandInfo[2] );
|
||||
break;
|
||||
}
|
||||
|
||||
setDvar( "sv_iw4madmin_command", "" );
|
||||
wait( 1 );
|
||||
}
|
||||
}
|
||||
|
||||
SendAlert( clientId, alertType, sound, message )
|
||||
{
|
||||
client = getPlayerFromClientNum( int( clientId ) );
|
||||
client thread playLeaderDialogOnPlayer( sound, client.team );
|
||||
client playLocalSound( sound );
|
||||
client iPrintLnBold( "^1" + alertType + ": ^3" + message );
|
||||
}
|
||||
|
||||
KillPlayer( targetId, originId)
|
||||
{
|
||||
target = getPlayerFromClientNum( int( targetId ) );
|
||||
target suicide();
|
||||
origin = getPlayerFromClientNum( int( originId ) );
|
||||
|
||||
iPrintLnBold("^1" + origin.name + " ^7killed ^5" + target.name);
|
||||
}
|
360
GameFiles/IW4x/userraw/scripts/_integration.gsc
Normal file
360
GameFiles/IW4x/userraw/scripts/_integration.gsc
Normal file
@ -0,0 +1,360 @@
|
||||
#include common_scripts\utility;
|
||||
#include maps\mp\_utility;
|
||||
#include maps\mp\gametypes\_hud_util;
|
||||
#include maps\mp\gametypes\_playerlogic;
|
||||
|
||||
init()
|
||||
{
|
||||
// setup default vars
|
||||
level.eventBus = spawnstruct();
|
||||
level.eventBus.inVar = "sv_iw4madmin_in";
|
||||
level.eventBus.outVar = "sv_iw4madmin_out";
|
||||
level.clientDataKey = "clientData";
|
||||
|
||||
level.eventTypes = spawnstruct();
|
||||
level.eventTypes.clientDataReceived = "ClientDataReceived";
|
||||
level.eventTypes.clientDataRequested = "ClientDataRequested";
|
||||
level.eventTypes.executeCommandRequested = "ExecuteCommandRequested";
|
||||
|
||||
SetDvarIfUninitialized( level.eventBus.inVar, "" );
|
||||
SetDvarIfUninitialized( level.eventBus.outVar, "" );
|
||||
SetDvarIfUninitialized( "sv_iw4madmin_integration_enabled", 1 );
|
||||
|
||||
// map the event type to the handler
|
||||
level.eventCallbacks = [];
|
||||
level.eventCallbacks[level.eventTypes.clientDataReceived] = ::OnClientDataReceived;
|
||||
level.eventCallbacks[level.eventTypes.executeCommandRequested] = ::OnExecuteCommand;
|
||||
|
||||
// start long running tasks
|
||||
level thread PlayerWaitEvents();
|
||||
level thread MonitorBus();
|
||||
level thread OnPlayerConnect();
|
||||
}
|
||||
|
||||
//////////////////////////////////
|
||||
// Client Methods
|
||||
//////////////////////////////////
|
||||
|
||||
OnPlayerConnect()
|
||||
{
|
||||
level endon ( "disconnect" );
|
||||
|
||||
for ( ;; )
|
||||
{
|
||||
level waittill( "connected", player );
|
||||
player.pers[level.clientDataKey] = spawnstruct();
|
||||
player thread OnPlayerSpawned();
|
||||
}
|
||||
}
|
||||
|
||||
OnPlayerSpawned()
|
||||
{
|
||||
self endon( "disconnect" );
|
||||
|
||||
for ( ;; )
|
||||
{
|
||||
self waittill( "spawned_player" );
|
||||
self PlayerConnectEvents();
|
||||
}
|
||||
}
|
||||
|
||||
DisplayWelcomeData()
|
||||
{
|
||||
self endon( "disconnect" );
|
||||
|
||||
clientData = self.pers[level.clientDataKey];
|
||||
|
||||
self IPrintLnBold( "Welcome, your level is ^5" + clientData.permissionLevel );
|
||||
wait (2.0);
|
||||
self IPrintLnBold( "You were last seen ^5" + clientData.lastConnection );
|
||||
}
|
||||
|
||||
PlayerConnectEvents()
|
||||
{
|
||||
self endon( "disconnect" );
|
||||
|
||||
clientData = self.pers[level.clientDataKey];
|
||||
|
||||
if ( isDefined( clientData.state ) && clientData.state == "complete" )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
self RequestClientBasicData();
|
||||
// example of requesting meta from IW4MAdmin
|
||||
// self RequestClientMeta( "LastServerPlayed" );
|
||||
}
|
||||
|
||||
PlayerWaitEvents()
|
||||
{
|
||||
level endon( "game_ended" );
|
||||
self endon( "disconnect" );
|
||||
|
||||
for ( ;; )
|
||||
{
|
||||
level waittill( "client_event", client );
|
||||
|
||||
/#self IPrintLn("Processing Event " + client.event.type + "-" + client.event.subtype );#/
|
||||
|
||||
eventHandler = level.eventCallbacks[client.event.type];
|
||||
|
||||
if ( isDefined( eventHandler ) )
|
||||
{
|
||||
client [[eventHandler]]( client.event );
|
||||
}
|
||||
|
||||
client.eventData = [];
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////
|
||||
// Helper Methods
|
||||
//////////////////////////////////
|
||||
|
||||
RequestClientMeta( metaKey )
|
||||
{
|
||||
getClientMetaEvent = BuildEventRequest( true, level.eventTypes.clientDataRequested, "Meta", self, metaKey );
|
||||
self thread QueueEvent( getClientMetaEvent, level.eventTypes.clientDataRequested );
|
||||
}
|
||||
|
||||
RequestClientBasicData()
|
||||
{
|
||||
getClientDataEvent = BuildEventRequest( true, level.eventTypes.clientDataRequested, "None", self, "" );
|
||||
self thread QueueEvent( getClientDataEvent, level.eventTypes.clientDataRequested );
|
||||
}
|
||||
|
||||
BuildEventRequest( responseExpected, eventType, eventSubtype, client, data )
|
||||
{
|
||||
if ( !isDefined( data ) )
|
||||
{
|
||||
data = "";
|
||||
}
|
||||
|
||||
if ( !isDefined( eventSubtype ) )
|
||||
{
|
||||
eventSubtype = "None";
|
||||
}
|
||||
|
||||
request = "0";
|
||||
|
||||
if ( responseExpected )
|
||||
{
|
||||
request = "1";
|
||||
}
|
||||
|
||||
request = request + ";" + eventType + ";" + eventSubtype + ";" + client getEntityNumber() + ";" + data;
|
||||
return request;
|
||||
}
|
||||
|
||||
MonitorBus()
|
||||
{
|
||||
level endon( "game_ended" );
|
||||
|
||||
for( ;; )
|
||||
{
|
||||
wait ( 0.25 );
|
||||
|
||||
// check to see if IW4MAdmin is ready to receive more data
|
||||
if ( getDvar( level.eventBus.inVar ) == "" )
|
||||
{
|
||||
level notify( "bus_ready" );
|
||||
}
|
||||
|
||||
eventString = getDvar( level.eventBus.outVar );
|
||||
|
||||
if ( eventString == "" )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
/#IPrintLn( "-> " + eventString );#/
|
||||
|
||||
NotifyClientEvent( strtok( eventString, ";" ) );
|
||||
|
||||
SetDvar( level.eventBus.outVar, "" );
|
||||
}
|
||||
}
|
||||
|
||||
QueueEvent( request, eventType )
|
||||
{
|
||||
self endon( "disconnect" );
|
||||
|
||||
start = GetTime();
|
||||
maxWait = 15 * 1000; // 15 seconds
|
||||
timedOut = "";
|
||||
|
||||
while ( GetDvar( level.eventBus.inVar ) != "" && ( GetTime() - start ) < maxWait )
|
||||
{
|
||||
level waittill_notify_or_timeout( "bus_ready", 5 );
|
||||
|
||||
if ( GetDvar( level.eventBus.inVar ) != "" )
|
||||
{
|
||||
/#self IPrintLn("A request is already in progress...");#/
|
||||
timedOut = "set";
|
||||
continue;
|
||||
}
|
||||
|
||||
timedOut = "unset";
|
||||
}
|
||||
|
||||
if ( timedOut == "set")
|
||||
{
|
||||
/# self IPrintLn("Timed out waiting for response...");#/
|
||||
if ( eventType == level.eventTypes.clientDataRequested ) // todo: this is dirty fix
|
||||
{
|
||||
self.pers["clientData"].state = "failed";
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/#IPrintLn("<- " + request);#/
|
||||
SetDvar( level.eventBus.inVar, request );
|
||||
}
|
||||
|
||||
ParseDataString( data )
|
||||
{
|
||||
dataParts = strtok( data, "|" );
|
||||
dict = [];
|
||||
|
||||
counter = 0;
|
||||
foreach ( part in dataParts )
|
||||
{
|
||||
splitPart = strtok( part, "=" );
|
||||
key = splitPart[0];
|
||||
value = splitPart[1];
|
||||
dict[key] = value;
|
||||
dict[counter] = key;
|
||||
counter++;
|
||||
}
|
||||
|
||||
return dict;
|
||||
}
|
||||
|
||||
NotifyClientEvent( eventInfo )
|
||||
{
|
||||
client = getPlayerFromClientNum( int( eventInfo[3] ) );
|
||||
|
||||
event = spawnstruct();
|
||||
event.type = eventInfo[1];
|
||||
event.subtype = eventInfo[2];
|
||||
event.data = eventInfo[4];
|
||||
|
||||
/#IPrintLn(event.data);#/
|
||||
|
||||
client.event = event;
|
||||
|
||||
level notify( "client_event", client );
|
||||
}
|
||||
|
||||
//////////////////////////////////
|
||||
// Event Handlers
|
||||
/////////////////////////////////
|
||||
|
||||
OnClientDataReceived( event )
|
||||
{
|
||||
event.data = ParseDataString( event.data );
|
||||
clientData = self.pers[level.clientDataKey];
|
||||
|
||||
if ( event.subtype == "Meta" )
|
||||
{
|
||||
if ( !isDefined( clientData["meta"] ) )
|
||||
{
|
||||
clientData.meta = [];
|
||||
}
|
||||
|
||||
metaKey = event.data[0];
|
||||
clientData["meta"][metaKey] = event.data[metaKey];
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
clientData.permissionLevel = event.data["level"];
|
||||
clientData.lastConnection = event.data["lastConnection"];
|
||||
clientData.state = "complete";
|
||||
|
||||
self thread DisplayWelcomeData();
|
||||
}
|
||||
|
||||
OnExecuteCommand( event )
|
||||
{
|
||||
data = ParseDataString( event.data );
|
||||
switch ( event.subtype )
|
||||
{
|
||||
case "GiveWeapon":
|
||||
self GiveWeaponImpl( data );
|
||||
break;
|
||||
case "TakeWeapons":
|
||||
self TakeWeaponsImpl();
|
||||
break;
|
||||
case "SwitchTeams":
|
||||
self TeamSwitchImpl();
|
||||
break;
|
||||
case "Hide":
|
||||
self HideImpl();
|
||||
break;
|
||||
case "Unhide":
|
||||
self UnhideImpl();
|
||||
break;
|
||||
case "Alert":
|
||||
self AlertImpl( data );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////
|
||||
// Command Implementations
|
||||
/////////////////////////////////
|
||||
|
||||
GiveWeaponImpl( data )
|
||||
{
|
||||
if ( IsAlive( self ) )
|
||||
{
|
||||
self IPrintLnBold( "You have been given a new weapon" );
|
||||
self GiveWeapon( data["weaponName"] );
|
||||
self SwitchToWeapon( data["weaponName"] );
|
||||
}
|
||||
}
|
||||
|
||||
TakeWeaponsImpl()
|
||||
{
|
||||
if ( IsAlive( self ) )
|
||||
{
|
||||
self TakeAllWeapons();
|
||||
self IPrintLnBold( "All your weapons have been taken" );
|
||||
}
|
||||
}
|
||||
|
||||
TeamSwitchImpl()
|
||||
{
|
||||
if ( self.team == "allies" )
|
||||
{
|
||||
self [[level.axis]]();
|
||||
}
|
||||
else
|
||||
{
|
||||
self [[level.allies]]();
|
||||
}
|
||||
}
|
||||
|
||||
HideImpl()
|
||||
{
|
||||
if ( IsAlive( self ) )
|
||||
{
|
||||
self Hide();
|
||||
self IPrintLnBold( "You are now hidden" );
|
||||
}
|
||||
}
|
||||
|
||||
UnhideImpl()
|
||||
{
|
||||
if ( IsAlive( self ) )
|
||||
{
|
||||
self Show();
|
||||
self IPrintLnBold( "You are now visible" );
|
||||
}
|
||||
}
|
||||
|
||||
AlertImpl( data )
|
||||
{
|
||||
self thread maps\mp\gametypes\_hud_message::oldNotifyMessage( data["alertType"], data["message"], "compass_waypoint_target", ( 1, 0, 0 ), "ui_mp_nukebomb_timer", 7.5 );
|
||||
}
|
@ -30,8 +30,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ProfanityDeterment", "Plugi
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Login", "Plugins\Login\Login.csproj", "{D9F2ED28-6FA5-40CA-9912-E7A849147AB1}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IW4ScriptCommands", "Plugins\IW4ScriptCommands\IW4ScriptCommands.csproj", "{6C706CE5-A206-4E46-8712-F8C48D526091}"
|
||||
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
|
||||
@ -253,30 +251,6 @@ Global
|
||||
{D9F2ED28-6FA5-40CA-9912-E7A849147AB1}.Release|x64.Build.0 = Release|Any CPU
|
||||
{D9F2ED28-6FA5-40CA-9912-E7A849147AB1}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{D9F2ED28-6FA5-40CA-9912-E7A849147AB1}.Release|x86.Build.0 = Release|Any CPU
|
||||
{6C706CE5-A206-4E46-8712-F8C48D526091}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{6C706CE5-A206-4E46-8712-F8C48D526091}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{6C706CE5-A206-4E46-8712-F8C48D526091}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{6C706CE5-A206-4E46-8712-F8C48D526091}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{6C706CE5-A206-4E46-8712-F8C48D526091}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{6C706CE5-A206-4E46-8712-F8C48D526091}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{6C706CE5-A206-4E46-8712-F8C48D526091}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{6C706CE5-A206-4E46-8712-F8C48D526091}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{6C706CE5-A206-4E46-8712-F8C48D526091}.Prerelease|Any CPU.ActiveCfg = Prerelease|Any CPU
|
||||
{6C706CE5-A206-4E46-8712-F8C48D526091}.Prerelease|Any CPU.Build.0 = Prerelease|Any CPU
|
||||
{6C706CE5-A206-4E46-8712-F8C48D526091}.Prerelease|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{6C706CE5-A206-4E46-8712-F8C48D526091}.Prerelease|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{6C706CE5-A206-4E46-8712-F8C48D526091}.Prerelease|x64.ActiveCfg = Debug|Any CPU
|
||||
{6C706CE5-A206-4E46-8712-F8C48D526091}.Prerelease|x64.Build.0 = Debug|Any CPU
|
||||
{6C706CE5-A206-4E46-8712-F8C48D526091}.Prerelease|x86.ActiveCfg = Debug|Any CPU
|
||||
{6C706CE5-A206-4E46-8712-F8C48D526091}.Prerelease|x86.Build.0 = Debug|Any CPU
|
||||
{6C706CE5-A206-4E46-8712-F8C48D526091}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{6C706CE5-A206-4E46-8712-F8C48D526091}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{6C706CE5-A206-4E46-8712-F8C48D526091}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{6C706CE5-A206-4E46-8712-F8C48D526091}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{6C706CE5-A206-4E46-8712-F8C48D526091}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{6C706CE5-A206-4E46-8712-F8C48D526091}.Release|x64.Build.0 = Release|Any CPU
|
||||
{6C706CE5-A206-4E46-8712-F8C48D526091}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{6C706CE5-A206-4E46-8712-F8C48D526091}.Release|x86.Build.0 = Release|Any CPU
|
||||
{F5815359-CFC7-44B4-9A3B-C04BACAD5836}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{F5815359-CFC7-44B4-9A3B-C04BACAD5836}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{F5815359-CFC7-44B4-9A3B-C04BACAD5836}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
@ -406,7 +380,6 @@ Global
|
||||
{179140D3-97AA-4CB4-8BF6-A0C73CA75701} = {26E8B310-269E-46D4-A612-24601F16065F}
|
||||
{958FF7EC-0226-4E85-A85B-B84EC768197D} = {26E8B310-269E-46D4-A612-24601F16065F}
|
||||
{D9F2ED28-6FA5-40CA-9912-E7A849147AB1} = {26E8B310-269E-46D4-A612-24601F16065F}
|
||||
{6C706CE5-A206-4E46-8712-F8C48D526091} = {26E8B310-269E-46D4-A612-24601F16065F}
|
||||
{3F9ACC27-26DB-49FA-BCD2-50C54A49C9FA} = {26E8B310-269E-46D4-A612-24601F16065F}
|
||||
{F5815359-CFC7-44B4-9A3B-C04BACAD5836} = {26E8B310-269E-46D4-A612-24601F16065F}
|
||||
{00A1FED2-2254-4AF7-A5DB-2357FA7C88CD} = {26E8B310-269E-46D4-A612-24601F16065F}
|
||||
|
@ -64,9 +64,9 @@ namespace Integrations.Cod
|
||||
|
||||
var timeSinceLastQuery = (DateTime.Now - connectionState.LastQuery).TotalMilliseconds;
|
||||
|
||||
if (timeSinceLastQuery < StaticHelpers.FloodProtectionInterval)
|
||||
if (timeSinceLastQuery < config.FloodProtectInterval)
|
||||
{
|
||||
await Task.Delay(StaticHelpers.FloodProtectionInterval - (int)timeSinceLastQuery);
|
||||
await Task.Delay(config.FloodProtectInterval - (int)timeSinceLastQuery);
|
||||
}
|
||||
|
||||
connectionState.LastQuery = DateTime.Now;
|
||||
|
@ -1,44 +0,0 @@
|
||||
using SharedLibraryCore;
|
||||
using SharedLibraryCore.Commands;
|
||||
using SharedLibraryCore.Configuration;
|
||||
using SharedLibraryCore.Database.Models;
|
||||
using SharedLibraryCore.Interfaces;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IW4ScriptCommands.Commands
|
||||
{
|
||||
/// <summary>
|
||||
/// Example script command
|
||||
/// </summary>
|
||||
public class KillPlayerCommand : Command
|
||||
{
|
||||
public KillPlayerCommand(CommandConfiguration config, ITranslationLookup lookup) : base(config, lookup)
|
||||
{
|
||||
Name = "killplayer";
|
||||
Description = "kill a player";
|
||||
Alias = "kp";
|
||||
Permission = EFClient.Permission.Administrator;
|
||||
RequiresTarget = true;
|
||||
Arguments = new[]
|
||||
{
|
||||
new CommandArgument()
|
||||
{
|
||||
Name = "player",
|
||||
Required = true
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public override async Task ExecuteAsync(GameEvent E)
|
||||
{
|
||||
var cmd = new ScriptCommand()
|
||||
{
|
||||
CommandName = "killplayer",
|
||||
ClientNumber = E.Target.ClientNumber,
|
||||
CommandArguments = new[] { E.Origin.ClientNumber.ToString() }
|
||||
};
|
||||
|
||||
await cmd.Execute(E.Owner);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SharedLibraryCore;
|
||||
using SharedLibraryCore.Interfaces;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace WebfrontCore.Controllers.API
|
||||
{
|
||||
[Route("api/gsc/[action]")]
|
||||
public class GscApiController : BaseController
|
||||
{
|
||||
public GscApiController(IManager manager) : base(manager)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// grabs basic info about the client from IW4MAdmin
|
||||
/// </summary>
|
||||
/// <param name="networkId"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("{networkId}")]
|
||||
public IActionResult ClientInfo(string networkId)
|
||||
{
|
||||
long decimalNetworkId = networkId.ConvertGuidToLong(System.Globalization.NumberStyles.HexNumber);
|
||||
var clientInfo = Manager.GetActiveClients()
|
||||
.FirstOrDefault(c => c.NetworkId == decimalNetworkId);
|
||||
|
||||
if (clientInfo != null)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
sb.AppendLine($"admin={clientInfo.IsPrivileged()}");
|
||||
sb.AppendLine($"level={(int)clientInfo.Level}");
|
||||
sb.AppendLine($"levelstring={clientInfo.Level.ToLocalizedLevelName()}");
|
||||
sb.AppendLine($"connections={clientInfo.Connections}");
|
||||
sb.AppendLine($"authenticated={clientInfo.GetAdditionalProperty<bool>("IsLoggedIn") == true}");
|
||||
|
||||
return Content(sb.ToString());
|
||||
}
|
||||
|
||||
return Content("");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Library</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ApplicationIcon />
|
||||
<StartupObject />
|
||||
<Configurations>Debug;Release;Prerelease</Configurations>
|
||||
<LangVersion>Latest</LangVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="RaidMax.IW4MAdmin.SharedLibraryCore" Version="2022.1.28.1" PrivateAssets="All" />
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||
<Exec Command="dotnet publish $(ProjectPath) -c $(ConfigurationName) -o $(ProjectDir)..\..\Build\Plugins --no-build --no-restore --no-dependencies" />
|
||||
</Target>
|
||||
|
||||
</Project>
|
@ -1,46 +0,0 @@
|
||||
using SharedLibraryCore;
|
||||
using SharedLibraryCore.Interfaces;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IW4ScriptCommands
|
||||
{
|
||||
public class Plugin : IPlugin
|
||||
{
|
||||
public string Name => "IW4 Script Commands";
|
||||
|
||||
public float Version => 1.0f;
|
||||
|
||||
public string Author => "RaidMax";
|
||||
|
||||
public async Task OnEventAsync(GameEvent E, Server S)
|
||||
{
|
||||
if (E.Type == GameEvent.EventType.Start)
|
||||
{
|
||||
await S.SetDvarAsync("sv_iw4madmin_serverid", S.EndPoint);
|
||||
}
|
||||
|
||||
if (E.Type == GameEvent.EventType.Warn)
|
||||
{
|
||||
var cmd = new ScriptCommand()
|
||||
{
|
||||
ClientNumber = E.Target.ClientNumber,
|
||||
CommandName = "alert",
|
||||
CommandArguments = new[]
|
||||
{
|
||||
"Warning",
|
||||
"ui_mp_nukebomb_timer",
|
||||
E.Data
|
||||
}
|
||||
};
|
||||
// notifies the player ingame of the warning
|
||||
await cmd.Execute(S);
|
||||
}
|
||||
}
|
||||
|
||||
public Task OnLoadAsync(IManager manager) => Task.CompletedTask;
|
||||
|
||||
public Task OnTickAsync(Server S) => Task.CompletedTask;
|
||||
|
||||
public Task OnUnloadAsync() => Task.CompletedTask;
|
||||
}
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
using SharedLibraryCore;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IW4ScriptCommands
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains basic properties for command information read by gsc
|
||||
/// </summary>
|
||||
class ScriptCommand
|
||||
{
|
||||
/// <summary>
|
||||
/// Name of the command to execute
|
||||
/// </summary>
|
||||
public string CommandName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Target client number
|
||||
/// </summary>
|
||||
public int ClientNumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Arguments for the script function itself
|
||||
/// </summary>
|
||||
public string[] CommandArguments { get; set; } = new string[0];
|
||||
|
||||
public override string ToString() => string.Join(";", new[] { CommandName, ClientNumber.ToString() }.Concat(CommandArguments).Select(_arg => _arg.Replace(";", "")));
|
||||
|
||||
/// <summary>
|
||||
/// Executes the command
|
||||
/// </summary>
|
||||
/// <param name="server">server to execute the command on</param>
|
||||
/// <returns></returns>
|
||||
public async Task Execute(Server server) => await server.SetDvarAsync("sv_iw4madmin_command", ToString());
|
||||
}
|
||||
}
|
@ -26,7 +26,7 @@ let plugin = {
|
||||
switch (eventType) {
|
||||
case 'start':
|
||||
const enabled = initialize(server);
|
||||
|
||||
|
||||
if (!enabled) {
|
||||
return;
|
||||
}
|
||||
@ -189,7 +189,11 @@ let commands = [{
|
||||
targetRequired: true,
|
||||
// optional
|
||||
arguments: [{
|
||||
name: 'alert message',
|
||||
name: 'player',
|
||||
required: true
|
||||
},
|
||||
{
|
||||
name: 'message',
|
||||
required: true
|
||||
}],
|
||||
supportedGames: ['IW4'],
|
||||
@ -203,9 +207,11 @@ let commands = [{
|
||||
}];
|
||||
|
||||
const sendScriptCommand = (server, command, target, data) => {
|
||||
if (plugin.enabled) {
|
||||
sendEvent(server, false, 'ExecuteCommandRequested', command, target, data);
|
||||
const state = servers[server.EndPoint];
|
||||
if (state === undefined || !state.enabled) {
|
||||
return;
|
||||
}
|
||||
sendEvent(server, false, 'ExecuteCommandRequested', command, target, data);
|
||||
}
|
||||
|
||||
const sendEvent = (server, responseExpected, event, subtype, client, data) => {
|
||||
@ -272,7 +278,7 @@ const initialize = (server) => {
|
||||
logger.WriteError(`Could not get integration status of ${server.EndPoint} - ${error}`);
|
||||
}
|
||||
|
||||
logger.WriteDebug(`GSC Integration enabledGSC Integration enabled = ${enabled}`);
|
||||
logger.WriteInfo(`GSC Integration enabled = ${enabled}`);
|
||||
|
||||
if (!enabled) {
|
||||
servers[server.EndPoint] = {
|
||||
@ -320,13 +326,13 @@ const pollForEvents = server => {
|
||||
|
||||
const event = parseEvent(input)
|
||||
|
||||
logger.WriteInfo(`Processing input... ${event.eventType}`);
|
||||
logger.WriteDebug(`Processing input... ${event.eventType} ${event.subType} ${event.data} ${event.clientNumber}`);
|
||||
|
||||
if (event.eventType === 'ClientDataRequested') {
|
||||
const client = server.GetClientByNumber(event.clientNumber);
|
||||
|
||||
if (client != null) {
|
||||
logger.WriteInfo(`Found client ${client.Name}`);
|
||||
logger.WriteDebug(`Found client ${client.Name}`);
|
||||
|
||||
let data = [];
|
||||
|
||||
@ -342,9 +348,9 @@ const pollForEvents = server => {
|
||||
}
|
||||
|
||||
sendEvent(server, false, 'ClientDataReceived', event.subType, client, data);
|
||||
} else {
|
||||
logger.WriteWarning(`Could not find client slot ${event.clientNumber} when processing ${event.eventType}`);
|
||||
}
|
||||
|
||||
logger.WriteWarning(`Could not find client slot ${event.clientNumber} when processing ${event.eventType}`);
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -3,7 +3,7 @@ var eventParser;
|
||||
|
||||
var plugin = {
|
||||
author: 'RaidMax',
|
||||
version: 0.5,
|
||||
version: 0.6,
|
||||
name: 'IW4x Parser',
|
||||
isParser: true,
|
||||
|
||||
@ -20,10 +20,11 @@ var plugin = {
|
||||
rconParser.Configuration.CommandPrefixes.Ban = 'clientkick {0} "{1}"';
|
||||
rconParser.Configuration.CommandPrefixes.TempBan = 'tempbanclient {0} "{1}"';
|
||||
|
||||
rconParser.Configuration.DefaultRConPort = 28960;
|
||||
rconParser.Configuration.DefaultInstallationDirectoryHint = 'HKEY_CURRENT_USER\\Software\\Classes\\iw4x\\shell\\open\\command';
|
||||
rconParser.Configuration.DefaultRConPort = 28960;
|
||||
rconParser.Configuration.DefaultInstallationDirectoryHint = 'HKEY_CURRENT_USER\\Software\\Classes\\iw4x\\shell\\open\\command';
|
||||
rconParser.Configuration.FloodProtectInterval = 50;
|
||||
|
||||
eventParser.Configuration.GameDirectory = 'userraw';
|
||||
eventParser.Configuration.GameDirectory = 'userraw';
|
||||
|
||||
rconParser.Version = 'IW4x (v0.6.0)';
|
||||
rconParser.GameName = 2; // IW4x
|
||||
@ -37,4 +38,4 @@ var plugin = {
|
||||
|
||||
onTickAsync: function (server) {
|
||||
}
|
||||
};
|
||||
};
|
||||
|
@ -100,5 +100,7 @@ namespace SharedLibraryCore.Interfaces
|
||||
string DefaultInstallationDirectoryHint { get; }
|
||||
|
||||
ColorCodeMapping ColorCodeMapping { get; }
|
||||
|
||||
short FloodProtectInterval { get; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user