Compare commits
No commits in common. "release/pre" and "2023.05.30.2-prerelease" have entirely different histories.
release/pr
...
2023.05.30
@ -24,7 +24,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Jint" Version="3.0.0-beta-2049" />
|
<PackageReference Include="Jint" Version="3.0.0-beta-2047" />
|
||||||
<PackageReference Include="MaxMind.GeoIP2" Version="5.1.0" />
|
<PackageReference Include="MaxMind.GeoIP2" Version="5.1.0" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.8">
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.8">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
@ -1251,10 +1251,6 @@
|
|||||||
"Alias": "Call of the Dead",
|
"Alias": "Call of the Dead",
|
||||||
"Name": "zombie_coast"
|
"Name": "zombie_coast"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"Alias": "Shangri-La",
|
|
||||||
"Name": "zombie_temple"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"Alias": "Moon",
|
"Alias": "Moon",
|
||||||
"Name": "zombie_moon"
|
"Name": "zombie_moon"
|
||||||
|
@ -48,8 +48,8 @@ namespace IW4MAdmin.Application.Extensions
|
|||||||
loggerConfig = loggerConfig.WriteTo.Console(
|
loggerConfig = loggerConfig.WriteTo.Console(
|
||||||
outputTemplate:
|
outputTemplate:
|
||||||
"[{Timestamp:HH:mm:ss} {Server} {Level:u3}] {Message:lj}{NewLine}{Exception}")
|
"[{Timestamp:HH:mm:ss} {Server} {Level:u3}] {Message:lj}{NewLine}{Exception}")
|
||||||
.MinimumLevel.Override("Microsoft", LogEventLevel.Information)
|
; //.MinimumLevel.Override("Microsoft", LogEventLevel.Information)
|
||||||
.MinimumLevel.Debug();
|
//.MinimumLevel.Debug();
|
||||||
}
|
}
|
||||||
|
|
||||||
_defaultLogger = loggerConfig.CreateLogger();
|
_defaultLogger = loggerConfig.CreateLogger();
|
||||||
|
@ -129,7 +129,7 @@ public class BaseConfigurationHandlerV2<TConfigurationType> : IConfigurationHand
|
|||||||
await _onIo.WaitAsync();
|
await _onIo.WaitAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
await using var fileStream = File.Create(_path);
|
await using var fileStream = File.OpenWrite(_path);
|
||||||
await JsonSerializer.SerializeAsync(fileStream, configuration, _serializerOptions);
|
await JsonSerializer.SerializeAsync(fileStream, configuration, _serializerOptions);
|
||||||
await fileStream.DisposeAsync();
|
await fileStream.DisposeAsync();
|
||||||
_configurationInstance = configuration;
|
_configurationInstance = configuration;
|
||||||
|
@ -377,6 +377,7 @@ namespace IW4MAdmin
|
|||||||
if (E.Origin.State != ClientState.Connected)
|
if (E.Origin.State != ClientState.Connected)
|
||||||
{
|
{
|
||||||
E.Origin.State = ClientState.Connected;
|
E.Origin.State = ClientState.Connected;
|
||||||
|
E.Origin.LastConnection = DateTime.UtcNow;
|
||||||
E.Origin.Connections += 1;
|
E.Origin.Connections += 1;
|
||||||
|
|
||||||
ChatHistory.Add(new ChatInfo()
|
ChatHistory.Add(new ChatInfo()
|
||||||
|
@ -433,11 +433,6 @@ namespace IW4MAdmin.Application
|
|||||||
var commandConfigHandler = new BaseConfigurationHandler<CommandConfiguration>("CommandConfiguration");
|
var commandConfigHandler = new BaseConfigurationHandler<CommandConfiguration>("CommandConfiguration");
|
||||||
commandConfigHandler.BuildAsync().GetAwaiter().GetResult();
|
commandConfigHandler.BuildAsync().GetAwaiter().GetResult();
|
||||||
|
|
||||||
if (appConfigHandler.Configuration()?.MasterUrl == new Uri("http://api.raidmax.org:5000"))
|
|
||||||
{
|
|
||||||
appConfigHandler.Configuration().MasterUrl = new ApplicationConfiguration().MasterUrl;
|
|
||||||
}
|
|
||||||
|
|
||||||
var appConfig = appConfigHandler.Configuration();
|
var appConfig = appConfigHandler.Configuration();
|
||||||
var masterUri = Utilities.IsDevelopment
|
var masterUri = Utilities.IsDevelopment
|
||||||
? new Uri("http://127.0.0.1:8080")
|
? new Uri("http://127.0.0.1:8080")
|
||||||
|
@ -156,8 +156,8 @@ namespace IW4MAdmin.Application.Plugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
_logger.LogDebug("Discovered {Count} plugin implementations", pluginTypes.Count);
|
_logger.LogDebug("Discovered {Count} plugin implementations", pluginTypes.Count);
|
||||||
_logger.LogDebug("Discovered {Count} plugin command implementations", commandTypes.Count);
|
_logger.LogDebug("Discovered {Count} plugin commands", pluginTypes.Count);
|
||||||
_logger.LogDebug("Discovered {Count} plugin configuration implementations", configurationTypes.Count);
|
_logger.LogDebug("Discovered {Count} configuration implementations", pluginTypes.Count);
|
||||||
|
|
||||||
return (pluginTypes, commandTypes, configurationTypes);
|
return (pluginTypes, commandTypes, configurationTypes);
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ public class ScriptPluginHelper
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
await Task.Delay(delayMs, _manager.CancellationToken);
|
await Task.Delay(delayMs, _manager.CancellationToken);
|
||||||
_scriptPlugin.ExecuteWithErrorHandling(_ => callback.DynamicInvoke(JsValue.Undefined, new[] { JsValue.Undefined }));
|
_scriptPlugin.ExecuteWithErrorHandling(_ => callback.DynamicInvoke(JsValue.Undefined));
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
@ -76,11 +76,6 @@ public class ScriptPluginHelper
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RegisterDynamicCommand(JsValue command)
|
|
||||||
{
|
|
||||||
_scriptPlugin.RegisterDynamicCommand(command.ToObject());
|
|
||||||
}
|
|
||||||
|
|
||||||
private object RequestInternal(ScriptPluginWebRequest request)
|
private object RequestInternal(ScriptPluginWebRequest request)
|
||||||
{
|
{
|
||||||
var entered = false;
|
var entered = false;
|
||||||
|
@ -47,7 +47,6 @@ public class ScriptPluginV2 : IPluginV2
|
|||||||
private readonly List<string> _registeredCommandNames = new();
|
private readonly List<string> _registeredCommandNames = new();
|
||||||
private readonly List<string> _registeredInteractions = new();
|
private readonly List<string> _registeredInteractions = new();
|
||||||
private readonly Dictionary<MethodInfo, List<object>> _registeredEvents = new();
|
private readonly Dictionary<MethodInfo, List<object>> _registeredEvents = new();
|
||||||
private IManager _manager;
|
|
||||||
private bool _firstInitialization = true;
|
private bool _firstInitialization = true;
|
||||||
|
|
||||||
private record ScriptPluginDetails(string Name, string Author, string Version,
|
private record ScriptPluginDetails(string Name, string Author, string Version,
|
||||||
@ -113,15 +112,8 @@ public class ScriptPluginV2 : IPluginV2
|
|||||||
}, _logger, _fileName, _onProcessingScript);
|
}, _logger, _fileName, _onProcessingScript);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RegisterDynamicCommand(object command)
|
|
||||||
{
|
|
||||||
var parsedCommand = ParseScriptCommandDetails(command);
|
|
||||||
RegisterCommand(_manager, parsedCommand.First());
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task OnLoad(IManager manager, CancellationToken token)
|
private async Task OnLoad(IManager manager, CancellationToken token)
|
||||||
{
|
{
|
||||||
_manager = manager;
|
|
||||||
var entered = false;
|
var entered = false;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -261,13 +253,9 @@ public class ScriptPluginV2 : IPluginV2
|
|||||||
command.Permission, command.TargetRequired,
|
command.Permission, command.TargetRequired,
|
||||||
command.Arguments, Execute, command.SupportedGames);
|
command.Arguments, Execute, command.SupportedGames);
|
||||||
|
|
||||||
manager.RemoveCommandByName(scriptCommand.Name);
|
|
||||||
manager.AddAdditionalCommand(scriptCommand);
|
manager.AddAdditionalCommand(scriptCommand);
|
||||||
if (!_registeredCommandNames.Contains(scriptCommand.Name))
|
|
||||||
{
|
|
||||||
_registeredCommandNames.Add(scriptCommand.Name);
|
_registeredCommandNames.Add(scriptCommand.Name);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void ResetEngineState()
|
private void ResetEngineState()
|
||||||
{
|
{
|
||||||
@ -492,33 +480,6 @@ public class ScriptPluginV2 : IPluginV2
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static ScriptPluginDetails AsScriptPluginInstance(dynamic source)
|
private static ScriptPluginDetails AsScriptPluginInstance(dynamic source)
|
||||||
{
|
|
||||||
var commandDetails = ParseScriptCommandDetails(source);
|
|
||||||
|
|
||||||
var interactionDetails = Array.Empty<ScriptPluginInteractionDetails>();
|
|
||||||
if (HasProperty(source, "interactions") && source.interactions is dynamic[])
|
|
||||||
{
|
|
||||||
interactionDetails = ((dynamic[])source.interactions).Select(interaction =>
|
|
||||||
{
|
|
||||||
var name = HasProperty(interaction, "name") && interaction.name is string
|
|
||||||
? (string)interaction.name
|
|
||||||
: string.Empty;
|
|
||||||
var action = HasProperty(interaction, "action") && interaction.action is Delegate
|
|
||||||
? (Delegate)interaction.action
|
|
||||||
: null;
|
|
||||||
|
|
||||||
return new ScriptPluginInteractionDetails(name, action);
|
|
||||||
}).ToArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
var name = HasProperty(source, "name") && source.name is string ? (string)source.name : string.Empty;
|
|
||||||
var author = HasProperty(source, "author") && source.author is string ? (string)source.author : string.Empty;
|
|
||||||
var version = HasProperty(source, "version") && source.version is string ? (string)source.author : string.Empty;
|
|
||||||
|
|
||||||
return new ScriptPluginDetails(name, author, version, commandDetails, interactionDetails);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static ScriptPluginCommandDetails[] ParseScriptCommandDetails(dynamic source)
|
|
||||||
{
|
{
|
||||||
var commandDetails = Array.Empty<ScriptPluginCommandDetails>();
|
var commandDetails = Array.Empty<ScriptPluginCommandDetails>();
|
||||||
if (HasProperty(source, "commands") && source.commands is dynamic[])
|
if (HasProperty(source, "commands") && source.commands is dynamic[])
|
||||||
@ -552,7 +513,7 @@ public class ScriptPluginV2 : IPluginV2
|
|||||||
(bool)command.targetRequired;
|
(bool)command.targetRequired;
|
||||||
var supportedGames =
|
var supportedGames =
|
||||||
HasProperty(command, "supportedGames") && command.supportedGames is IEnumerable<object>
|
HasProperty(command, "supportedGames") && command.supportedGames is IEnumerable<object>
|
||||||
? ((IEnumerable<object>)command.supportedGames).Where(game => !string.IsNullOrEmpty(game?.ToString()))
|
? ((IEnumerable<object>)command.supportedGames).Where(game => game?.ToString() is not null)
|
||||||
.Select(game =>
|
.Select(game =>
|
||||||
Enum.Parse<Reference.Game>(game.ToString()!))
|
Enum.Parse<Reference.Game>(game.ToString()!))
|
||||||
: Array.Empty<Reference.Game>();
|
: Array.Empty<Reference.Game>();
|
||||||
@ -562,10 +523,31 @@ public class ScriptPluginV2 : IPluginV2
|
|||||||
|
|
||||||
return new ScriptPluginCommandDetails(name, description, alias, permission, isTargetRequired,
|
return new ScriptPluginCommandDetails(name, description, alias, permission, isTargetRequired,
|
||||||
commandArgs, supportedGames, execute);
|
commandArgs, supportedGames, execute);
|
||||||
|
|
||||||
}).ToArray();
|
}).ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
return commandDetails;
|
var interactionDetails = Array.Empty<ScriptPluginInteractionDetails>();
|
||||||
|
if (HasProperty(source, "interactions") && source.interactions is dynamic[])
|
||||||
|
{
|
||||||
|
interactionDetails = ((dynamic[])source.interactions).Select(interaction =>
|
||||||
|
{
|
||||||
|
var name = HasProperty(interaction, "name") && interaction.name is string
|
||||||
|
? (string)interaction.name
|
||||||
|
: string.Empty;
|
||||||
|
var action = HasProperty(interaction, "action") && interaction.action is Delegate
|
||||||
|
? (Delegate)interaction.action
|
||||||
|
: null;
|
||||||
|
|
||||||
|
return new ScriptPluginInteractionDetails(name, action);
|
||||||
|
}).ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
var name = HasProperty(source, "name") && source.name is string ? (string)source.name : string.Empty;
|
||||||
|
var author = HasProperty(source, "author") && source.author is string ? (string)source.author : string.Empty;
|
||||||
|
var version = HasProperty(source, "version") && source.version is string ? (string)source.author : string.Empty;
|
||||||
|
|
||||||
|
return new ScriptPluginDetails(name, author, version, commandDetails, interactionDetails);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool HasProperty(dynamic source, string name)
|
private static bool HasProperty(dynamic source, string name)
|
||||||
|
@ -8,11 +8,9 @@ using Data.Abstractions;
|
|||||||
using Data.Models;
|
using Data.Models;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using SharedLibraryCore;
|
using SharedLibraryCore;
|
||||||
using SharedLibraryCore.Configuration;
|
|
||||||
using SharedLibraryCore.Dtos;
|
using SharedLibraryCore.Dtos;
|
||||||
using SharedLibraryCore.Helpers;
|
using SharedLibraryCore.Helpers;
|
||||||
using SharedLibraryCore.Interfaces;
|
using SharedLibraryCore.Interfaces;
|
||||||
using WebfrontCore.Permissions;
|
|
||||||
using WebfrontCore.QueryHelpers.Models;
|
using WebfrontCore.QueryHelpers.Models;
|
||||||
using EFClient = Data.Models.Client.EFClient;
|
using EFClient = Data.Models.Client.EFClient;
|
||||||
|
|
||||||
@ -20,7 +18,6 @@ namespace IW4MAdmin.Application.QueryHelpers;
|
|||||||
|
|
||||||
public class ClientResourceQueryHelper : IResourceQueryHelper<ClientResourceRequest, ClientResourceResponse>
|
public class ClientResourceQueryHelper : IResourceQueryHelper<ClientResourceRequest, ClientResourceResponse>
|
||||||
{
|
{
|
||||||
public ApplicationConfiguration _appConfig { get; }
|
|
||||||
private readonly IDatabaseContextFactory _contextFactory;
|
private readonly IDatabaseContextFactory _contextFactory;
|
||||||
private readonly IGeoLocationService _geoLocationService;
|
private readonly IGeoLocationService _geoLocationService;
|
||||||
|
|
||||||
@ -30,10 +27,8 @@ public class ClientResourceQueryHelper : IResourceQueryHelper<ClientResourceRequ
|
|||||||
public EFAlias Alias { get; set; }
|
public EFAlias Alias { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClientResourceQueryHelper(IDatabaseContextFactory contextFactory, IGeoLocationService geoLocationService,
|
public ClientResourceQueryHelper(IDatabaseContextFactory contextFactory, IGeoLocationService geoLocationService)
|
||||||
ApplicationConfiguration appConfig)
|
|
||||||
{
|
{
|
||||||
_appConfig = appConfig;
|
|
||||||
_contextFactory = contextFactory;
|
_contextFactory = contextFactory;
|
||||||
_geoLocationService = geoLocationService;
|
_geoLocationService = geoLocationService;
|
||||||
}
|
}
|
||||||
@ -80,9 +75,7 @@ public class ClientResourceQueryHelper : IResourceQueryHelper<ClientResourceRequ
|
|||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(query.ClientIp))
|
if (!string.IsNullOrWhiteSpace(query.ClientIp))
|
||||||
{
|
{
|
||||||
clientAliases = SearchByIp(query, clientAliases,
|
clientAliases = SearchByIp(query, clientAliases);
|
||||||
_appConfig.HasPermission(query.RequesterPermission, WebfrontEntity.ClientIPAddress,
|
|
||||||
WebfrontPermission.Read));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var iqGroupedClientAliases = clientAliases.GroupBy(a => new { a.Client.ClientId, a.Client.LastConnection });
|
var iqGroupedClientAliases = clientAliases.GroupBy(a => new { a.Client.ClientId, a.Client.LastConnection });
|
||||||
@ -210,7 +203,7 @@ public class ClientResourceQueryHelper : IResourceQueryHelper<ClientResourceRequ
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static IQueryable<ClientAlias> SearchByIp(ClientResourceRequest query,
|
private static IQueryable<ClientAlias> SearchByIp(ClientResourceRequest query,
|
||||||
IQueryable<ClientAlias> clientAliases, bool canSearchIP)
|
IQueryable<ClientAlias> clientAliases)
|
||||||
{
|
{
|
||||||
var ipString = query.ClientIp.Trim();
|
var ipString = query.ClientIp.Trim();
|
||||||
var ipAddress = ipString.ConvertToIP();
|
var ipAddress = ipString.ConvertToIP();
|
||||||
@ -220,7 +213,7 @@ public class ClientResourceQueryHelper : IResourceQueryHelper<ClientResourceRequ
|
|||||||
clientAliases = clientAliases.Where(clientAlias =>
|
clientAliases = clientAliases.Where(clientAlias =>
|
||||||
clientAlias.Alias.IPAddress != null && clientAlias.Alias.IPAddress == ipAddress);
|
clientAlias.Alias.IPAddress != null && clientAlias.Alias.IPAddress == ipAddress);
|
||||||
}
|
}
|
||||||
else if(canSearchIP)
|
else
|
||||||
{
|
{
|
||||||
clientAliases = clientAliases.Where(clientAlias =>
|
clientAliases = clientAliases.Where(clientAlias =>
|
||||||
EF.Functions.Like(clientAlias.Alias.SearchableIPAddress, $"{ipString}%"));
|
EF.Functions.Like(clientAlias.Alias.SearchableIPAddress, $"{ipString}%"));
|
||||||
|
@ -194,14 +194,10 @@ namespace IW4MAdmin.Application.RConParsers
|
|||||||
foreach (var line in response)
|
foreach (var line in response)
|
||||||
{
|
{
|
||||||
var regex = Regex.Match(line, parserRegex.Pattern);
|
var regex = Regex.Match(line, parserRegex.Pattern);
|
||||||
|
if (regex.Success && parserRegex.GroupMapping.ContainsKey(groupType))
|
||||||
if (!regex.Success || !parserRegex.GroupMapping.ContainsKey(groupType))
|
|
||||||
{
|
{
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
value = regex.Groups[parserRegex.GroupMapping[groupType]].ToString();
|
value = regex.Groups[parserRegex.GroupMapping[groupType]].ToString();
|
||||||
break;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (value == null)
|
if (value == null)
|
||||||
@ -308,7 +304,7 @@ namespace IW4MAdmin.Application.RConParsers
|
|||||||
{
|
{
|
||||||
networkIdString = match.Values[Configuration.Status.GroupMapping[ParserRegex.GroupType.RConNetworkId]];
|
networkIdString = match.Values[Configuration.Status.GroupMapping[ParserRegex.GroupType.RConNetworkId]];
|
||||||
|
|
||||||
networkId = networkIdString.IsBotGuid() || (ip == null && ping is 999 or 0) ?
|
networkId = networkIdString.IsBotGuid() || (ip == null && ping == 999) ?
|
||||||
name.GenerateGuidFromString() :
|
name.GenerateGuidFromString() :
|
||||||
networkIdString.ConvertGuidToLong(Configuration.GuidNumberStyle);
|
networkIdString.ConvertGuidToLong(Configuration.GuidNumberStyle);
|
||||||
}
|
}
|
||||||
|
@ -153,8 +153,6 @@ namespace Data.Context
|
|||||||
|
|
||||||
modelBuilder.Entity<EFClientConnectionHistory>(ent => ent.HasIndex(history => history.CreatedDateTime));
|
modelBuilder.Entity<EFClientConnectionHistory>(ent => ent.HasIndex(history => history.CreatedDateTime));
|
||||||
|
|
||||||
modelBuilder.Entity<EFServerSnapshot>(ent => ent.HasIndex(snapshot => snapshot.CapturedAt));
|
|
||||||
|
|
||||||
// force full name for database conversion
|
// force full name for database conversion
|
||||||
modelBuilder.Entity<EFClient>().ToTable("EFClients");
|
modelBuilder.Entity<EFClient>().ToTable("EFClients");
|
||||||
modelBuilder.Entity<EFAlias>().ToTable("EFAlias");
|
modelBuilder.Entity<EFAlias>().ToTable("EFAlias");
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,24 +0,0 @@
|
|||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace Data.Migrations.MySql
|
|
||||||
{
|
|
||||||
public partial class AddIndexToEFServerSnapshotCapturedAt : Migration
|
|
||||||
{
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_EFServerSnapshot_CapturedAt",
|
|
||||||
table: "EFServerSnapshot",
|
|
||||||
column: "CapturedAt");
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropIndex(
|
|
||||||
name: "IX_EFServerSnapshot_CapturedAt",
|
|
||||||
table: "EFServerSnapshot");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -814,7 +814,6 @@ namespace Data.Migrations.MySql
|
|||||||
|
|
||||||
b.Property<string>("SearchableIPAddress")
|
b.Property<string>("SearchableIPAddress")
|
||||||
.ValueGeneratedOnAddOrUpdate()
|
.ValueGeneratedOnAddOrUpdate()
|
||||||
.HasMaxLength(255)
|
|
||||||
.HasColumnType("varchar(255)")
|
.HasColumnType("varchar(255)")
|
||||||
.HasComputedColumnSql("((IPAddress & 255) || '.' || ((IPAddress >> 8) & 255)) || '.' || ((IPAddress >> 16) & 255) || '.' || ((IPAddress >> 24) & 255)", true);
|
.HasComputedColumnSql("((IPAddress & 255) || '.' || ((IPAddress >> 8) & 255)) || '.' || ((IPAddress >> 16) & 255) || '.' || ((IPAddress >> 24) & 255)", true);
|
||||||
|
|
||||||
@ -1111,8 +1110,6 @@ namespace Data.Migrations.MySql
|
|||||||
|
|
||||||
b.HasKey("ServerSnapshotId");
|
b.HasKey("ServerSnapshotId");
|
||||||
|
|
||||||
b.HasIndex("CapturedAt");
|
|
||||||
|
|
||||||
b.HasIndex("MapId");
|
b.HasIndex("MapId");
|
||||||
|
|
||||||
b.HasIndex("ServerId");
|
b.HasIndex("ServerId");
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,52 +0,0 @@
|
|||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace Data.Migrations.Postgresql
|
|
||||||
{
|
|
||||||
public partial class AddIndexToEFServerSnapshotCapturedAt : Migration
|
|
||||||
{
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.AlterColumn<string>(
|
|
||||||
name: "SearchableIPAddress",
|
|
||||||
table: "EFAlias",
|
|
||||||
type: "character varying(255)",
|
|
||||||
maxLength: 255,
|
|
||||||
nullable: true,
|
|
||||||
computedColumnSql: "((IPAddress & 255) || '.' || ((IPAddress >> 8) & 255)) || '.' || ((IPAddress >> 16) & 255) || '.' || ((IPAddress >> 24) & 255)",
|
|
||||||
stored: true,
|
|
||||||
oldClrType: typeof(string),
|
|
||||||
oldType: "text",
|
|
||||||
oldNullable: true,
|
|
||||||
oldComputedColumnSql: "((IPAddress & 255) || '.' || ((IPAddress >> 8) & 255)) || '.' || ((IPAddress >> 16) & 255) || '.' || ((IPAddress >> 24) & 255)",
|
|
||||||
oldStored: true);
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_EFServerSnapshot_CapturedAt",
|
|
||||||
table: "EFServerSnapshot",
|
|
||||||
column: "CapturedAt");
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropIndex(
|
|
||||||
name: "IX_EFServerSnapshot_CapturedAt",
|
|
||||||
table: "EFServerSnapshot");
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<string>(
|
|
||||||
name: "SearchableIPAddress",
|
|
||||||
table: "EFAlias",
|
|
||||||
type: "text",
|
|
||||||
nullable: true,
|
|
||||||
computedColumnSql: "((IPAddress & 255) || '.' || ((IPAddress >> 8) & 255)) || '.' || ((IPAddress >> 16) & 255) || '.' || ((IPAddress >> 24) & 255)",
|
|
||||||
stored: true,
|
|
||||||
oldClrType: typeof(string),
|
|
||||||
oldType: "character varying(255)",
|
|
||||||
oldMaxLength: 255,
|
|
||||||
oldNullable: true,
|
|
||||||
oldComputedColumnSql: "((IPAddress & 255) || '.' || ((IPAddress >> 8) & 255)) || '.' || ((IPAddress >> 16) & 255) || '.' || ((IPAddress >> 24) & 255)",
|
|
||||||
oldStored: true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -853,8 +853,7 @@ namespace Data.Migrations.Postgresql
|
|||||||
|
|
||||||
b.Property<string>("SearchableIPAddress")
|
b.Property<string>("SearchableIPAddress")
|
||||||
.ValueGeneratedOnAddOrUpdate()
|
.ValueGeneratedOnAddOrUpdate()
|
||||||
.HasMaxLength(255)
|
.HasColumnType("text")
|
||||||
.HasColumnType("character varying(255)")
|
|
||||||
.HasComputedColumnSql("((IPAddress & 255) || '.' || ((IPAddress >> 8) & 255)) || '.' || ((IPAddress >> 16) & 255) || '.' || ((IPAddress >> 24) & 255)", true);
|
.HasComputedColumnSql("((IPAddress & 255) || '.' || ((IPAddress >> 8) & 255)) || '.' || ((IPAddress >> 16) & 255) || '.' || ((IPAddress >> 24) & 255)", true);
|
||||||
|
|
||||||
b.Property<string>("SearchableName")
|
b.Property<string>("SearchableName")
|
||||||
@ -1164,8 +1163,6 @@ namespace Data.Migrations.Postgresql
|
|||||||
|
|
||||||
b.HasKey("ServerSnapshotId");
|
b.HasKey("ServerSnapshotId");
|
||||||
|
|
||||||
b.HasIndex("CapturedAt");
|
|
||||||
|
|
||||||
b.HasIndex("MapId");
|
b.HasIndex("MapId");
|
||||||
|
|
||||||
b.HasIndex("ServerId");
|
b.HasIndex("ServerId");
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,24 +0,0 @@
|
|||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace Data.Migrations.Sqlite
|
|
||||||
{
|
|
||||||
public partial class AddIndexToEFServerSnapshotCapturedAt : Migration
|
|
||||||
{
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_EFServerSnapshot_CapturedAt",
|
|
||||||
table: "EFServerSnapshot",
|
|
||||||
column: "CapturedAt");
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropIndex(
|
|
||||||
name: "IX_EFServerSnapshot_CapturedAt",
|
|
||||||
table: "EFServerSnapshot");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -812,7 +812,6 @@ namespace Data.Migrations.Sqlite
|
|||||||
|
|
||||||
b.Property<string>("SearchableIPAddress")
|
b.Property<string>("SearchableIPAddress")
|
||||||
.ValueGeneratedOnAddOrUpdate()
|
.ValueGeneratedOnAddOrUpdate()
|
||||||
.HasMaxLength(255)
|
|
||||||
.HasColumnType("TEXT")
|
.HasColumnType("TEXT")
|
||||||
.HasComputedColumnSql("((IPAddress & 255) || '.' || ((IPAddress >> 8) & 255)) || '.' || ((IPAddress >> 16) & 255) || '.' || ((IPAddress >> 24) & 255)", true);
|
.HasComputedColumnSql("((IPAddress & 255) || '.' || ((IPAddress >> 8) & 255)) || '.' || ((IPAddress >> 16) & 255) || '.' || ((IPAddress >> 24) & 255)", true);
|
||||||
|
|
||||||
@ -1109,8 +1108,6 @@ namespace Data.Migrations.Sqlite
|
|||||||
|
|
||||||
b.HasKey("ServerSnapshotId");
|
b.HasKey("ServerSnapshotId");
|
||||||
|
|
||||||
b.HasIndex("CapturedAt");
|
|
||||||
|
|
||||||
b.HasIndex("MapId");
|
b.HasIndex("MapId");
|
||||||
|
|
||||||
b.HasIndex("ServerId");
|
b.HasIndex("ServerId");
|
||||||
|
@ -16,8 +16,7 @@
|
|||||||
T7 = 8,
|
T7 = 8,
|
||||||
SHG1 = 9,
|
SHG1 = 9,
|
||||||
CSGO = 10,
|
CSGO = 10,
|
||||||
H1 = 11,
|
H1 = 11
|
||||||
L4D2 = 12,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum ConnectionType
|
public enum ConnectionType
|
||||||
|
@ -6,7 +6,6 @@ trigger:
|
|||||||
include:
|
include:
|
||||||
- release/pre
|
- release/pre
|
||||||
- master
|
- master
|
||||||
- develop
|
|
||||||
|
|
||||||
pr: none
|
pr: none
|
||||||
|
|
||||||
@ -21,8 +20,6 @@ variables:
|
|||||||
buildConfiguration: Stable
|
buildConfiguration: Stable
|
||||||
isPreRelease: false
|
isPreRelease: false
|
||||||
|
|
||||||
jobs:
|
|
||||||
- job: Build_Deploy
|
|
||||||
steps:
|
steps:
|
||||||
- task: UseDotNet@2
|
- task: UseDotNet@2
|
||||||
displayName: 'Install .NET Core 6 SDK'
|
displayName: 'Install .NET Core 6 SDK'
|
||||||
@ -35,7 +32,7 @@ jobs:
|
|||||||
|
|
||||||
- task: PowerShell@2
|
- task: PowerShell@2
|
||||||
displayName: 'Setup Pre-Release configuration'
|
displayName: 'Setup Pre-Release configuration'
|
||||||
condition: or(eq(variables['Build.SourceBranch'], 'refs/heads/release/pre'), eq(variables['Build.SourceBranch'], 'refs/heads/develop'))
|
condition: eq(variables['Build.SourceBranch'], 'refs/heads/release/pre')
|
||||||
inputs:
|
inputs:
|
||||||
targetType: 'inline'
|
targetType: 'inline'
|
||||||
script: |
|
script: |
|
||||||
@ -174,15 +171,7 @@ jobs:
|
|||||||
targetPath: '$(Build.ArtifactStagingDirectory)/IW4MAdmin-$(Build.BuildNumber).zip'
|
targetPath: '$(Build.ArtifactStagingDirectory)/IW4MAdmin-$(Build.BuildNumber).zip'
|
||||||
artifact: 'IW4MAdmin-$(Build.BuildNumber).zip'
|
artifact: 'IW4MAdmin-$(Build.BuildNumber).zip'
|
||||||
|
|
||||||
- task: PublishPipelineArtifact@1
|
|
||||||
displayName: 'Publish artifact for analysis'
|
|
||||||
inputs:
|
|
||||||
targetPath: '$(outputFolder)'
|
|
||||||
artifact: 'IW4MAdmin.$(buildConfiguration)'
|
|
||||||
publishLocation: 'pipeline'
|
|
||||||
|
|
||||||
- task: FtpUpload@2
|
- task: FtpUpload@2
|
||||||
condition: ne(variables['Build.SourceBranch'], 'refs/heads/develop')
|
|
||||||
displayName: 'Upload zip file to website'
|
displayName: 'Upload zip file to website'
|
||||||
inputs:
|
inputs:
|
||||||
credentialsOption: 'inputs'
|
credentialsOption: 'inputs'
|
||||||
@ -198,7 +187,6 @@ jobs:
|
|||||||
trustSSL: false
|
trustSSL: false
|
||||||
|
|
||||||
- task: FtpUpload@2
|
- task: FtpUpload@2
|
||||||
condition: ne(variables['Build.SourceBranch'], 'refs/heads/develop')
|
|
||||||
displayName: 'Upload version info to website'
|
displayName: 'Upload version info to website'
|
||||||
inputs:
|
inputs:
|
||||||
credentialsOption: 'inputs'
|
credentialsOption: 'inputs'
|
||||||
@ -214,7 +202,6 @@ jobs:
|
|||||||
trustSSL: false
|
trustSSL: false
|
||||||
|
|
||||||
- task: GitHubRelease@1
|
- task: GitHubRelease@1
|
||||||
condition: ne(variables['Build.SourceBranch'], 'refs/heads/develop')
|
|
||||||
displayName: 'Make GitHub release'
|
displayName: 'Make GitHub release'
|
||||||
inputs:
|
inputs:
|
||||||
gitHubConnection: 'github.com_RaidMax'
|
gitHubConnection: 'github.com_RaidMax'
|
||||||
@ -227,12 +214,11 @@ jobs:
|
|||||||
assets: '$(Build.ArtifactStagingDirectory)/*.zip'
|
assets: '$(Build.ArtifactStagingDirectory)/*.zip'
|
||||||
isPreRelease: $(isPreRelease)
|
isPreRelease: $(isPreRelease)
|
||||||
releaseNotesSource: 'inline'
|
releaseNotesSource: 'inline'
|
||||||
releaseNotesInline: 'Automated rolling release - changelog below. [Updating Instructions](https://github.com/RaidMax/IW4M-Admin/wiki/Getting-Started#updating)'
|
releaseNotesInline: 'todo'
|
||||||
changeLogCompareToRelease: 'lastNonDraftRelease'
|
changeLogCompareToRelease: 'lastNonDraftRelease'
|
||||||
changeLogType: 'commitBased'
|
changeLogType: 'commitBased'
|
||||||
|
|
||||||
- task: PowerShell@2
|
- task: PowerShell@2
|
||||||
condition: ne(variables['Build.SourceBranch'], 'refs/heads/develop')
|
|
||||||
displayName: 'Update master version'
|
displayName: 'Update master version'
|
||||||
inputs:
|
inputs:
|
||||||
targetType: 'inline'
|
targetType: 'inline'
|
||||||
@ -251,3 +237,10 @@ jobs:
|
|||||||
}
|
}
|
||||||
|
|
||||||
Invoke-RestMethod @params
|
Invoke-RestMethod @params
|
||||||
|
|
||||||
|
- task: PublishPipelineArtifact@1
|
||||||
|
displayName: 'Publish artifact for analysis'
|
||||||
|
inputs:
|
||||||
|
targetPath: '$(outputFolder)'
|
||||||
|
artifact: 'IW4MAdmin.$(buildConfiguration)'
|
||||||
|
publishLocation: 'pipeline'
|
||||||
|
@ -19,33 +19,11 @@ Setup()
|
|||||||
|
|
||||||
level.commonFunctions = spawnstruct();
|
level.commonFunctions = spawnstruct();
|
||||||
level.commonFunctions.setDvar = "SetDvarIfUninitialized";
|
level.commonFunctions.setDvar = "SetDvarIfUninitialized";
|
||||||
|
level.commonFunctions.isBot = "IsBot";
|
||||||
|
level.commonFunctions.getXuid = "GetXuid";
|
||||||
level.commonFunctions.getPlayerFromClientNum = "GetPlayerFromClientNum";
|
level.commonFunctions.getPlayerFromClientNum = "GetPlayerFromClientNum";
|
||||||
level.commonFunctions.waittillNotifyOrTimeout = "WaittillNotifyOrTimeout";
|
|
||||||
level.commonFunctions.getInboundData = "GetInboundData";
|
|
||||||
level.commonFunctions.getOutboundData = "GetOutboundData";
|
|
||||||
level.commonFunctions.setInboundData = "SetInboundData";
|
|
||||||
level.commonFunctions.setOutboundData = "SetOutboundData";
|
|
||||||
|
|
||||||
level.overrideMethods = [];
|
|
||||||
level.overrideMethods[level.commonFunctions.setDvar] = scripts\_integration_base::NotImplementedFunction;
|
|
||||||
level.overrideMethods[level.commonFunctions.getPlayerFromClientNum] = ::_GetPlayerFromClientNum;
|
|
||||||
level.overrideMethods[level.commonFunctions.getInboundData] = ::_GetInboundData;
|
|
||||||
level.overrideMethods[level.commonFunctions.getOutboundData] = ::_GetOutboundData;
|
|
||||||
level.overrideMethods[level.commonFunctions.setInboundData] = ::_SetInboundData;
|
|
||||||
level.overrideMethods[level.commonFunctions.setOutboundData] = ::_SetOutboundData;
|
|
||||||
|
|
||||||
level.busMethods = [];
|
|
||||||
level.busMethods[level.commonFunctions.getInboundData] = ::_GetInboundData;
|
|
||||||
level.busMethods[level.commonFunctions.getOutboundData] = ::_GetOutboundData;
|
|
||||||
level.busMethods[level.commonFunctions.setInboundData] = ::_SetInboundData;
|
|
||||||
level.busMethods[level.commonFunctions.setOutboundData] = ::_SetOutboundData;
|
|
||||||
|
|
||||||
level.commonKeys = spawnstruct();
|
level.commonKeys = spawnstruct();
|
||||||
level.commonKeys.enabled = "sv_iw4madmin_integration_enabled";
|
|
||||||
level.commonKeys.busMode = "sv_iw4madmin_integration_busmode";
|
|
||||||
level.commonKeys.busDir = "sv_iw4madmin_integration_busdir";
|
|
||||||
level.eventBus.inLocation = "";
|
|
||||||
level.eventBus.outLocation = "";
|
|
||||||
|
|
||||||
level.notifyTypes = spawnstruct();
|
level.notifyTypes = spawnstruct();
|
||||||
level.notifyTypes.gameFunctionsInitialized = "GameFunctionsInitialized";
|
level.notifyTypes.gameFunctionsInitialized = "GameFunctionsInitialized";
|
||||||
@ -55,7 +33,7 @@ Setup()
|
|||||||
level.clientDataKey = "clientData";
|
level.clientDataKey = "clientData";
|
||||||
|
|
||||||
level.eventTypes = spawnstruct();
|
level.eventTypes = spawnstruct();
|
||||||
level.eventTypes.eventAvailable = "EventAvailable";
|
level.eventTypes.localClientEvent = "client_event";
|
||||||
level.eventTypes.clientDataReceived = "ClientDataReceived";
|
level.eventTypes.clientDataReceived = "ClientDataReceived";
|
||||||
level.eventTypes.clientDataRequested = "ClientDataRequested";
|
level.eventTypes.clientDataRequested = "ClientDataRequested";
|
||||||
level.eventTypes.setClientDataRequested = "SetClientDataRequested";
|
level.eventTypes.setClientDataRequested = "SetClientDataRequested";
|
||||||
@ -73,11 +51,12 @@ Setup()
|
|||||||
level.clientCommandCallbacks = [];
|
level.clientCommandCallbacks = [];
|
||||||
level.clientCommandRusAsTarget = [];
|
level.clientCommandRusAsTarget = [];
|
||||||
level.logger = spawnstruct();
|
level.logger = spawnstruct();
|
||||||
|
level.overrideMethods = [];
|
||||||
|
|
||||||
level.iw4madminIntegrationDebug = GetDvarInt( "sv_iw4madmin_integration_debug" );
|
level.iw4madminIntegrationDebug = GetDvarInt( "sv_iw4madmin_integration_debug" );
|
||||||
InitializeLogger();
|
InitializeLogger();
|
||||||
|
|
||||||
wait ( 0.05 * 2 ); // needed to give script engine time to propagate notifies
|
wait ( 0.05 ); // needed to give script engine time to propagate notifies
|
||||||
|
|
||||||
level notify( level.notifyTypes.integrationBootstrapInitialized );
|
level notify( level.notifyTypes.integrationBootstrapInitialized );
|
||||||
level waittill( level.notifyTypes.gameFunctionsInitialized );
|
level waittill( level.notifyTypes.gameFunctionsInitialized );
|
||||||
@ -86,58 +65,122 @@ Setup()
|
|||||||
|
|
||||||
_SetDvarIfUninitialized( level.eventBus.inVar, "" );
|
_SetDvarIfUninitialized( level.eventBus.inVar, "" );
|
||||||
_SetDvarIfUninitialized( level.eventBus.outVar, "" );
|
_SetDvarIfUninitialized( level.eventBus.outVar, "" );
|
||||||
_SetDvarIfUninitialized( level.commonKeys.enabled, 1 );
|
_SetDvarIfUninitialized( "sv_iw4madmin_integration_enabled", 1 );
|
||||||
_SetDvarIfUninitialized( level.commonKeys.busMode, "rcon" );
|
|
||||||
_SetDvarIfUninitialized( level.commonKeys.busdir, "" );
|
|
||||||
_SetDvarIfUninitialized( "sv_iw4madmin_integration_debug", 0 );
|
_SetDvarIfUninitialized( "sv_iw4madmin_integration_debug", 0 );
|
||||||
_SetDvarIfUninitialized( "GroupSeparatorChar", "" );
|
|
||||||
_SetDvarIfUninitialized( "RecordSeparatorChar", "" );
|
|
||||||
_SetDvarIfUninitialized( "UnitSeparatorChar", "" );
|
|
||||||
|
|
||||||
if ( GetDvarInt( level.commonKeys.enabled ) != 1 )
|
if ( GetDvarInt( "sv_iw4madmin_integration_enabled" ) != 1 )
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// start long running tasks
|
// start long running tasks
|
||||||
thread MonitorEvents();
|
level thread MonitorClientEvents();
|
||||||
thread MonitorBus();
|
level thread MonitorBus();
|
||||||
|
level thread OnPlayerConnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
MonitorEvents()
|
//////////////////////////////////
|
||||||
|
// Client Methods
|
||||||
|
//////////////////////////////////
|
||||||
|
|
||||||
|
OnPlayerConnect()
|
||||||
{
|
{
|
||||||
level endon( level.eventTypes.gameEnd );
|
level endon ( "game_ended" );
|
||||||
|
|
||||||
for ( ;; )
|
for ( ;; )
|
||||||
{
|
{
|
||||||
level waittill( level.eventTypes.eventAvailable, event );
|
level waittill( "connected", player );
|
||||||
|
|
||||||
LogDebug( "Processing Event " + event.type + "-" + event.subtype );
|
if ( _IsBot( player ) )
|
||||||
|
{
|
||||||
|
// we don't want to track bots
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
eventHandler = level.eventCallbacks[event.type];
|
if ( !IsDefined( player.pers[level.clientDataKey] ) )
|
||||||
|
{
|
||||||
|
player.pers[level.clientDataKey] = spawnstruct();
|
||||||
|
}
|
||||||
|
|
||||||
|
player thread OnPlayerSpawned();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
OnPlayerSpawned()
|
||||||
|
{
|
||||||
|
self endon( "disconnect" );
|
||||||
|
|
||||||
|
for ( ;; )
|
||||||
|
{
|
||||||
|
self waittill( "spawned_player" );
|
||||||
|
self PlayerSpawnEvents();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
OnGameEnded()
|
||||||
|
{
|
||||||
|
for ( ;; )
|
||||||
|
{
|
||||||
|
level waittill( "game_ended" );
|
||||||
|
// note: you can run data code here but it's possible for
|
||||||
|
// data to get truncated, so we will try a timer based approach for now
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DisplayWelcomeData()
|
||||||
|
{
|
||||||
|
self endon( "disconnect" );
|
||||||
|
|
||||||
|
clientData = self.pers[level.clientDataKey];
|
||||||
|
|
||||||
|
if ( clientData.permissionLevel == "User" || clientData.permissionLevel == "Flagged" )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
self IPrintLnBold( "Welcome, your level is ^5" + clientData.permissionLevel );
|
||||||
|
wait( 2.0 );
|
||||||
|
self IPrintLnBold( "You were last seen ^5" + clientData.lastConnection );
|
||||||
|
}
|
||||||
|
|
||||||
|
PlayerSpawnEvents()
|
||||||
|
{
|
||||||
|
self endon( "disconnect" );
|
||||||
|
|
||||||
|
clientData = self.pers[level.clientDataKey];
|
||||||
|
|
||||||
|
// this gives IW4MAdmin some time to register the player before making the request;
|
||||||
|
// although probably not necessary some users might have a slow database or poll rate
|
||||||
|
wait ( 2 );
|
||||||
|
|
||||||
|
if ( IsDefined( clientData.state ) && clientData.state == "complete" )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
self RequestClientBasicData();
|
||||||
|
}
|
||||||
|
|
||||||
|
MonitorClientEvents()
|
||||||
|
{
|
||||||
|
level endon( "game_ended" );
|
||||||
|
|
||||||
|
for ( ;; )
|
||||||
|
{
|
||||||
|
level waittill( level.eventTypes.localClientEvent, client );
|
||||||
|
|
||||||
|
LogDebug( "Processing Event " + client.event.type + "-" + client.event.subtype );
|
||||||
|
|
||||||
|
eventHandler = level.eventCallbacks[client.event.type];
|
||||||
|
|
||||||
if ( IsDefined( eventHandler ) )
|
if ( IsDefined( eventHandler ) )
|
||||||
{
|
{
|
||||||
if ( IsDefined( event.entity ) )
|
client [[eventHandler]]( client.event );
|
||||||
{
|
LogDebug( "notify client for " + client.event.type );
|
||||||
event.entity [[eventHandler]]( event );
|
client notify( level.eventTypes.localClientEvent, client.event );
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
[[eventHandler]]( event );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( IsDefined( event.entity ) )
|
client.eventData = [];
|
||||||
{
|
|
||||||
LogDebug( "Notify client for " + event.type );
|
|
||||||
event.entity notify( event.type, event );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
LogDebug( "Notify level for " + event.type );
|
|
||||||
level notify( event.type, event );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,13 +188,11 @@ MonitorEvents()
|
|||||||
// Helper Methods
|
// Helper Methods
|
||||||
//////////////////////////////////
|
//////////////////////////////////
|
||||||
|
|
||||||
NotImplementedFunction( a, b, c, d, e, f )
|
_IsBot( entity )
|
||||||
{
|
{
|
||||||
LogWarning( "Function not implemented" );
|
// there already is a cgame function exists as "IsBot", for IW4, but unsure what all titles have it defined,
|
||||||
if ( IsDefined ( a ) )
|
// so we are defining it here
|
||||||
{
|
return IsDefined( entity.pers["isBot"] ) && entity.pers["isBot"];
|
||||||
LogWarning( a );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_SetDvarIfUninitialized( dvarName, dvarValue )
|
_SetDvarIfUninitialized( dvarName, dvarValue )
|
||||||
@ -159,44 +200,9 @@ _SetDvarIfUninitialized( dvarName, dvarValue )
|
|||||||
[[level.overrideMethods[level.commonFunctions.setDvar]]]( dvarName, dvarValue );
|
[[level.overrideMethods[level.commonFunctions.setDvar]]]( dvarName, dvarValue );
|
||||||
}
|
}
|
||||||
|
|
||||||
_GetPlayerFromClientNum( clientNum )
|
NotImplementedFunction( a, b, c, d, e, f )
|
||||||
{
|
{
|
||||||
assertEx( clientNum >= 0, "clientNum cannot be negative" );
|
LogWarning( "Function not implemented" );
|
||||||
|
|
||||||
if ( clientNum < 0 )
|
|
||||||
{
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
for ( i = 0; i < level.players.size; i++ )
|
|
||||||
{
|
|
||||||
if ( level.players[i] getEntityNumber() == clientNum )
|
|
||||||
{
|
|
||||||
return level.players[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
_GetInboundData( location )
|
|
||||||
{
|
|
||||||
return GetDvar( level.eventBus.inVar );
|
|
||||||
}
|
|
||||||
|
|
||||||
_GetOutboundData( location )
|
|
||||||
{
|
|
||||||
return GetDvar( level.eventBus.outVar );
|
|
||||||
}
|
|
||||||
|
|
||||||
_SetInboundData( location, data )
|
|
||||||
{
|
|
||||||
return SetDvar( level.eventBus.inVar, data );
|
|
||||||
}
|
|
||||||
|
|
||||||
_SetOutboundData( location, data )
|
|
||||||
{
|
|
||||||
return SetDvar( level.eventBus.outVar, data );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Not every game can output to console or even game log.
|
// Not every game can output to console or even game log.
|
||||||
@ -217,7 +223,7 @@ _Log( LogLevel, message )
|
|||||||
{
|
{
|
||||||
for( i = 0; i < level.logger._logger.size; i++ )
|
for( i = 0; i < level.logger._logger.size; i++ )
|
||||||
{
|
{
|
||||||
[[level.logger._logger[i]]]( LogLevel, GetSubStr( message, 0, 1000 ) );
|
[[level.logger._logger[i]]]( LogLevel, message );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -279,13 +285,13 @@ RegisterLogger( logger )
|
|||||||
RequestClientMeta( metaKey )
|
RequestClientMeta( metaKey )
|
||||||
{
|
{
|
||||||
getClientMetaEvent = BuildEventRequest( true, level.eventTypes.clientDataRequested, "Meta", self, metaKey );
|
getClientMetaEvent = BuildEventRequest( true, level.eventTypes.clientDataRequested, "Meta", self, metaKey );
|
||||||
thread QueueEvent( getClientMetaEvent, level.eventTypes.clientDataRequested, self );
|
level thread QueueEvent( getClientMetaEvent, level.eventTypes.clientDataRequested, self );
|
||||||
}
|
}
|
||||||
|
|
||||||
RequestClientBasicData()
|
RequestClientBasicData()
|
||||||
{
|
{
|
||||||
getClientDataEvent = BuildEventRequest( true, level.eventTypes.clientDataRequested, "None", self, "" );
|
getClientDataEvent = BuildEventRequest( true, level.eventTypes.clientDataRequested, "None", self, "" );
|
||||||
thread QueueEvent( getClientDataEvent, level.eventTypes.clientDataRequested, self );
|
level thread QueueEvent( getClientDataEvent, level.eventTypes.clientDataRequested, self );
|
||||||
}
|
}
|
||||||
|
|
||||||
IncrementClientMeta( metaKey, incrementValue, clientId )
|
IncrementClientMeta( metaKey, incrementValue, clientId )
|
||||||
@ -300,20 +306,18 @@ DecrementClientMeta( metaKey, decrementValue, clientId )
|
|||||||
|
|
||||||
SetClientMeta( metaKey, metaValue, clientId, direction )
|
SetClientMeta( metaKey, metaValue, clientId, direction )
|
||||||
{
|
{
|
||||||
data = [];
|
data = "key=" + metaKey + "|value=" + metaValue;
|
||||||
data["key"] = metaKey;
|
|
||||||
data["value"] = metaValue;
|
|
||||||
clientNumber = -1;
|
clientNumber = -1;
|
||||||
|
|
||||||
if ( IsDefined ( clientId ) )
|
if ( IsDefined ( clientId ) )
|
||||||
{
|
{
|
||||||
data["clientId"] = clientId;
|
data = data + "|clientId=" + clientId;
|
||||||
clientNumber = -1;
|
clientNumber = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( IsDefined( direction ) )
|
if ( IsDefined( direction ) )
|
||||||
{
|
{
|
||||||
data["direction"] = direction;
|
data = data + "|direction=" + direction;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( IsPlayer( self ) )
|
if ( IsPlayer( self ) )
|
||||||
@ -322,7 +326,7 @@ SetClientMeta( metaKey, metaValue, clientId, direction )
|
|||||||
}
|
}
|
||||||
|
|
||||||
setClientMetaEvent = BuildEventRequest( true, level.eventTypes.setClientDataRequested, "Meta", clientNumber, data );
|
setClientMetaEvent = BuildEventRequest( true, level.eventTypes.setClientDataRequested, "Meta", clientNumber, data );
|
||||||
thread QueueEvent( setClientMetaEvent, level.eventTypes.setClientDataRequested, self );
|
level thread QueueEvent( setClientMetaEvent, level.eventTypes.setClientDataRequested, self );
|
||||||
}
|
}
|
||||||
|
|
||||||
BuildEventRequest( responseExpected, eventType, eventSubtype, entOrId, data )
|
BuildEventRequest( responseExpected, eventType, eventSubtype, entOrId, data )
|
||||||
@ -337,11 +341,6 @@ BuildEventRequest( responseExpected, eventType, eventSubtype, entOrId, data )
|
|||||||
eventSubtype = "None";
|
eventSubtype = "None";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !IsDefined( entOrId ) )
|
|
||||||
{
|
|
||||||
entOrId = "-1";
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( IsPlayer( entOrId ) )
|
if ( IsPlayer( entOrId ) )
|
||||||
{
|
{
|
||||||
entOrId = entOrId getEntityNumber();
|
entOrId = entOrId getEntityNumber();
|
||||||
@ -354,64 +353,51 @@ BuildEventRequest( responseExpected, eventType, eventSubtype, entOrId, data )
|
|||||||
request = "1";
|
request = "1";
|
||||||
}
|
}
|
||||||
|
|
||||||
data = BuildDataString( data );
|
request = request + ";" + eventType + ";" + eventSubtype + ";" + entOrId + ";" + data;
|
||||||
groupSeparator = GetSubStr( GetDvar( "GroupSeparatorChar" ), 0, 1 );
|
|
||||||
request = request + groupSeparator + eventType + groupSeparator + eventSubtype + groupSeparator + entOrId + groupSeparator + data;
|
|
||||||
|
|
||||||
return request;
|
return request;
|
||||||
}
|
}
|
||||||
|
|
||||||
MonitorBus()
|
MonitorBus()
|
||||||
{
|
{
|
||||||
level endon( level.eventTypes.gameEnd );
|
level endon( "game_ended" );
|
||||||
|
|
||||||
level.eventBus.inLocation = level.eventBus.inVar + "_" + GetDvar( "net_port" );
|
|
||||||
level.eventBus.outLocation = level.eventBus.outVar + "_" + GetDvar( "net_port" );
|
|
||||||
|
|
||||||
[[level.overrideMethods[level.commonFunctions.SetInboundData]]]( level.eventBus.inLocation, "" );
|
|
||||||
[[level.overrideMethods[level.commonFunctions.SetOutboundData]]]( level.eventBus.outLocation, "" );
|
|
||||||
|
|
||||||
for( ;; )
|
for( ;; )
|
||||||
{
|
{
|
||||||
wait ( 0.1 );
|
wait ( 0.1 );
|
||||||
|
|
||||||
// check to see if IW4MAdmin is ready to receive more data
|
// check to see if IW4MAdmin is ready to receive more data
|
||||||
inVal = [[level.busMethods[level.commonFunctions.getInboundData]]]( level.eventBus.inLocation );
|
if ( getDvar( level.eventBus.inVar ) == "" )
|
||||||
|
|
||||||
if ( !IsDefined( inVal ) || inVal == "" )
|
|
||||||
{
|
{
|
||||||
level notify( "bus_ready" );
|
level notify( "bus_ready" );
|
||||||
}
|
}
|
||||||
|
|
||||||
eventString = [[level.busMethods[level.commonFunctions.getOutboundData]]]( level.eventBus.outLocation );
|
eventString = getDvar( level.eventBus.outVar );
|
||||||
|
|
||||||
if ( !IsDefined( eventString ) || eventString == "" )
|
if ( eventString == "" )
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
LogDebug( "-> " + eventString );
|
LogDebug( "-> " + eventString );
|
||||||
|
|
||||||
groupSeparator = GetSubStr( GetDvar( "GroupSeparatorChar" ), 0, 1 );
|
NotifyClientEvent( strtok( eventString, ";" ) );
|
||||||
NotifyEvent( strtok( eventString, groupSeparator ) );
|
|
||||||
|
|
||||||
[[level.busMethods[level.commonFunctions.SetOutboundData]]]( level.eventBus.outLocation, "" );
|
SetDvar( level.eventBus.outVar, "" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QueueEvent( request, eventType, notifyEntity )
|
QueueEvent( request, eventType, notifyEntity )
|
||||||
{
|
{
|
||||||
level endon( level.eventTypes.gameEnd );
|
level endon( "game_ended" );
|
||||||
|
|
||||||
start = GetTime();
|
start = GetTime();
|
||||||
maxWait = level.eventBus.timeout * 1000; // 30 seconds
|
maxWait = level.eventBus.timeout * 1000; // 30 seconds
|
||||||
timedOut = "";
|
timedOut = "";
|
||||||
|
|
||||||
while ( [[level.busMethods[level.commonFunctions.getInboundData]]]( level.eventBus.inLocation ) != "" && ( GetTime() - start ) < maxWait )
|
while ( GetDvar( level.eventBus.inVar ) != "" && ( GetTime() - start ) < maxWait )
|
||||||
{
|
{
|
||||||
level [[level.overrideMethods[level.commonFunctions.waittillNotifyOrTimeout]]]( "bus_ready", 1 );
|
level [[level.overrideMethods["waittill_notify_or_timeout"]]]( "bus_ready", 1 );
|
||||||
|
|
||||||
if ( [[level.busMethods[level.commonFunctions.getInboundData]]]( level.eventBus.inLocation ) != "" )
|
if ( GetDvar( level.eventBus.inVar ) != "" )
|
||||||
{
|
{
|
||||||
LogDebug( "A request is already in progress..." );
|
LogDebug( "A request is already in progress..." );
|
||||||
timedOut = "set";
|
timedOut = "set";
|
||||||
@ -430,14 +416,14 @@ QueueEvent( request, eventType, notifyEntity )
|
|||||||
notifyEntity NotifyClientEventTimeout( eventType );
|
notifyEntity NotifyClientEventTimeout( eventType );
|
||||||
}
|
}
|
||||||
|
|
||||||
[[level.busMethods[level.commonFunctions.SetInboundData]]]( level.eventBus.inLocation, "" );
|
SetDvar( level.eventBus.inVar, "" );
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
LogDebug("<- " + request );
|
LogDebug("<- " + request );
|
||||||
|
|
||||||
[[level.busMethods[level.commonFunctions.setInboundData]]]( level.eventBus.inLocation, request );
|
SetDvar( level.eventBus.inVar, request );
|
||||||
}
|
}
|
||||||
|
|
||||||
ParseDataString( data )
|
ParseDataString( data )
|
||||||
@ -448,13 +434,13 @@ ParseDataString( data )
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
dataParts = strtok( data, GetSubStr( GetDvar( "RecordSeparatorChar" ), 0, 1 ) );
|
dataParts = strtok( data, "|" );
|
||||||
dict = [];
|
dict = [];
|
||||||
|
|
||||||
for ( i = 0; i < dataParts.size; i++ )
|
for ( i = 0; i < dataParts.size; i++ )
|
||||||
{
|
{
|
||||||
part = dataParts[i];
|
part = dataParts[i];
|
||||||
splitPart = strtok( part, GetSubStr( GetDvar( "UnitSeparatorChar" ), 0, 1 ) );
|
splitPart = strtok( part, "=" );
|
||||||
key = splitPart[0];
|
key = splitPart[0];
|
||||||
value = splitPart[1];
|
value = splitPart[1];
|
||||||
dict[key] = value;
|
dict[key] = value;
|
||||||
@ -464,26 +450,6 @@ ParseDataString( data )
|
|||||||
return dict;
|
return dict;
|
||||||
}
|
}
|
||||||
|
|
||||||
BuildDataString( data )
|
|
||||||
{
|
|
||||||
if ( IsString( data ) )
|
|
||||||
{
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
dataString = "";
|
|
||||||
keys = GetArrayKeys( data );
|
|
||||||
unitSeparator = GetSubStr( GetDvar( "UnitSeparatorChar" ), 0, 1 );
|
|
||||||
recordSeparator = GetSubStr( GetDvar( "RecordSeparatorChar" ), 0, 1 );
|
|
||||||
|
|
||||||
for ( i = 0; i < keys.size; i++ )
|
|
||||||
{
|
|
||||||
dataString = dataString + keys[i] + unitSeparator + data[keys[i]] + recordSeparator;
|
|
||||||
}
|
|
||||||
|
|
||||||
return dataString;
|
|
||||||
}
|
|
||||||
|
|
||||||
NotifyClientEventTimeout( eventType )
|
NotifyClientEventTimeout( eventType )
|
||||||
{
|
{
|
||||||
// todo: make this actual eventing
|
// todo: make this actual eventing
|
||||||
@ -493,7 +459,7 @@ NotifyClientEventTimeout( eventType )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NotifyEvent( eventInfo )
|
NotifyClientEvent( eventInfo )
|
||||||
{
|
{
|
||||||
origin = [[level.overrideMethods[level.commonFunctions.getPlayerFromClientNum]]]( int( eventInfo[3] ) );
|
origin = [[level.overrideMethods[level.commonFunctions.getPlayerFromClientNum]]]( int( eventInfo[3] ) );
|
||||||
target = [[level.overrideMethods[level.commonFunctions.getPlayerFromClientNum]]]( int( eventInfo[4] ) );
|
target = [[level.overrideMethods[level.commonFunctions.getPlayerFromClientNum]]]( int( eventInfo[4] ) );
|
||||||
@ -501,10 +467,15 @@ NotifyEvent( eventInfo )
|
|||||||
event = spawnstruct();
|
event = spawnstruct();
|
||||||
event.type = eventInfo[1];
|
event.type = eventInfo[1];
|
||||||
event.subtype = eventInfo[2];
|
event.subtype = eventInfo[2];
|
||||||
event.data = ParseDataString( eventInfo[5] );
|
event.data = eventInfo[5];
|
||||||
event.origin = origin;
|
event.origin = origin;
|
||||||
event.target = target;
|
event.target = target;
|
||||||
|
|
||||||
|
if ( IsDefined( event.data ) )
|
||||||
|
{
|
||||||
|
LogDebug( "NotifyClientEvent->" + event.data );
|
||||||
|
}
|
||||||
|
|
||||||
if ( int( eventInfo[3] ) != -1 && !IsDefined( origin ) )
|
if ( int( eventInfo[3] ) != -1 && !IsDefined( origin ) )
|
||||||
{
|
{
|
||||||
LogDebug( "origin is null but the slot id is " + int( eventInfo[3] ) );
|
LogDebug( "origin is null but the slot id is " + int( eventInfo[3] ) );
|
||||||
@ -514,15 +485,23 @@ NotifyEvent( eventInfo )
|
|||||||
LogDebug( "target is null but the slot id is " + int( eventInfo[4] ) );
|
LogDebug( "target is null but the slot id is " + int( eventInfo[4] ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
client = event.origin;
|
if ( IsDefined( target ) )
|
||||||
|
|
||||||
if ( !IsDefined( client ) )
|
|
||||||
{
|
{
|
||||||
client = event.target;
|
client = event.target;
|
||||||
}
|
}
|
||||||
|
else if ( IsDefined( origin ) )
|
||||||
|
{
|
||||||
|
client = event.origin;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LogDebug( "Neither origin or target are set but we are a Client Event, aborting" );
|
||||||
|
|
||||||
event.entity = client;
|
return;
|
||||||
level notify( level.eventTypes.eventAvailable, event );
|
}
|
||||||
|
|
||||||
|
client.event = event;
|
||||||
|
level notify( level.eventTypes.localClientEvent, client );
|
||||||
}
|
}
|
||||||
|
|
||||||
AddClientCommand( commandName, shouldRunAsTarget, callback, shouldOverwrite )
|
AddClientCommand( commandName, shouldRunAsTarget, callback, shouldOverwrite )
|
||||||
@ -542,7 +521,7 @@ AddClientCommand( commandName, shouldRunAsTarget, callback, shouldOverwrite )
|
|||||||
|
|
||||||
OnClientDataReceived( event )
|
OnClientDataReceived( event )
|
||||||
{
|
{
|
||||||
assertEx( isDefined( self ), "player entity is not defined");
|
event.data = ParseDataString( event.data );
|
||||||
clientData = self.pers[level.clientDataKey];
|
clientData = self.pers[level.clientDataKey];
|
||||||
|
|
||||||
if ( event.subtype == "Fail" )
|
if ( event.subtype == "Fail" )
|
||||||
@ -562,7 +541,7 @@ OnClientDataReceived( event )
|
|||||||
metaKey = event.data[0];
|
metaKey = event.data[0];
|
||||||
clientData.meta[metaKey] = event.data[metaKey];
|
clientData.meta[metaKey] = event.data[metaKey];
|
||||||
|
|
||||||
LogDebug( "Meta Key=" + CoerceUndefined( metaKey ) + ", Meta Value=" + CoerceUndefined( event.data[metaKey] ) );
|
LogDebug( "Meta Key=" + metaKey + ", Meta Value=" + event.data[metaKey] );
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -574,11 +553,13 @@ OnClientDataReceived( event )
|
|||||||
clientData.performance = event.data["performance"];
|
clientData.performance = event.data["performance"];
|
||||||
clientData.state = "complete";
|
clientData.state = "complete";
|
||||||
self.persistentClientId = event.data["clientId"];
|
self.persistentClientId = event.data["clientId"];
|
||||||
|
|
||||||
|
self thread DisplayWelcomeData();
|
||||||
}
|
}
|
||||||
|
|
||||||
OnExecuteCommand( event )
|
OnExecuteCommand( event )
|
||||||
{
|
{
|
||||||
data = event.data;
|
data = ParseDataString( event.data );
|
||||||
response = "";
|
response = "";
|
||||||
|
|
||||||
command = level.clientCommandCallbacks[event.subtype];
|
command = level.clientCommandCallbacks[event.subtype];
|
||||||
@ -592,14 +573,7 @@ OnExecuteCommand( event )
|
|||||||
|
|
||||||
if ( IsDefined( command ) )
|
if ( IsDefined( command ) )
|
||||||
{
|
{
|
||||||
if ( IsDefined( executionContextEntity ) )
|
response = executionContextEntity [[command]]( event, data );
|
||||||
{
|
|
||||||
response = executionContextEntity thread [[command]]( event, data );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
thread [[command]]( event );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -615,15 +589,6 @@ OnExecuteCommand( event )
|
|||||||
|
|
||||||
OnSetClientDataCompleted( event )
|
OnSetClientDataCompleted( event )
|
||||||
{
|
{
|
||||||
LogDebug( "Set Client Data -> subtype = " + CoerceUndefined( event.subType ) + ", status = " + CoerceUndefined( event.data["status"] ) );
|
// IW4MAdmin let us know it persisted (success or fail)
|
||||||
}
|
LogDebug( "Set Client Data -> subtype = " + event.subType + " status = " + event.data["status"] );
|
||||||
|
|
||||||
CoerceUndefined( object )
|
|
||||||
{
|
|
||||||
if ( !IsDefined( object ) )
|
|
||||||
{
|
|
||||||
return "undefined";
|
|
||||||
}
|
|
||||||
|
|
||||||
return object;
|
|
||||||
}
|
}
|
||||||
|
@ -8,17 +8,18 @@ Init()
|
|||||||
Setup()
|
Setup()
|
||||||
{
|
{
|
||||||
level endon( "game_ended" );
|
level endon( "game_ended" );
|
||||||
waittillframeend;
|
|
||||||
|
|
||||||
level waittill( level.notifyTypes.sharedFunctionsInitialized );
|
// it's possible that the notify type has not been defined yet so we have to hard code it
|
||||||
|
level waittill( "SharedFunctionsInitialized" );
|
||||||
level.eventBus.gamename = "IW4";
|
level.eventBus.gamename = "IW4";
|
||||||
|
|
||||||
scripts\_integration_base::RegisterLogger( ::Log2Console );
|
scripts\_integration_base::RegisterLogger( ::Log2Console );
|
||||||
|
|
||||||
level.overrideMethods[level.commonFunctions.getTotalShotsFired] = ::GetTotalShotsFired;
|
level.overrideMethods["GetTotalShotsFired"] = ::GetTotalShotsFired;
|
||||||
level.overrideMethods[level.commonFunctions.setDvar] = ::SetDvarIfUninitializedWrapper;
|
level.overrideMethods[level.commonFunctions.setDvar] = ::_SetDvarIfUninitialized;
|
||||||
level.overrideMethods[level.commonFunctions.isBot] = ::IsBotWrapper;
|
level.overrideMethods[level.commonFunctions.isBot] = ::IsTestClient;
|
||||||
level.overrideMethods[level.commonFunctions.getXuid] = ::GetXuidWrapper;
|
level.overrideMethods[level.commonFunctions.getXuid] = ::_GetXUID;
|
||||||
|
level.overrideMethods["waittill_notify_or_timeout"] = ::_waittill_notify_or_timeout;
|
||||||
level.overrideMethods[level.commonFunctions.changeTeam] = ::ChangeTeam;
|
level.overrideMethods[level.commonFunctions.changeTeam] = ::ChangeTeam;
|
||||||
level.overrideMethods[level.commonFunctions.getTeamCounts] = ::CountPlayers;
|
level.overrideMethods[level.commonFunctions.getTeamCounts] = ::CountPlayers;
|
||||||
level.overrideMethods[level.commonFunctions.getMaxClients] = ::GetMaxClients;
|
level.overrideMethods[level.commonFunctions.getMaxClients] = ::GetMaxClients;
|
||||||
@ -27,25 +28,19 @@ Setup()
|
|||||||
level.overrideMethods[level.commonFunctions.getClientKillStreak] = ::GetClientKillStreak;
|
level.overrideMethods[level.commonFunctions.getClientKillStreak] = ::GetClientKillStreak;
|
||||||
level.overrideMethods[level.commonFunctions.backupRestoreClientKillStreakData] = ::BackupRestoreClientKillStreakData;
|
level.overrideMethods[level.commonFunctions.backupRestoreClientKillStreakData] = ::BackupRestoreClientKillStreakData;
|
||||||
level.overrideMethods[level.commonFunctions.waitTillAnyTimeout] = ::WaitTillAnyTimeout;
|
level.overrideMethods[level.commonFunctions.waitTillAnyTimeout] = ::WaitTillAnyTimeout;
|
||||||
level.overrideMethods[level.commonFunctions.waittillNotifyOrTimeout] = ::WaitillNotifyOrTimeoutWrapper;
|
|
||||||
|
|
||||||
level.overrideMethods[level.commonFunctions.getInboundData] = ::GetInboundData;
|
|
||||||
level.overrideMethods[level.commonFunctions.getOutboundData] = ::GetOutboundData;
|
|
||||||
level.overrideMethods[level.commonFunctions.setInboundData] = ::SetInboundData;
|
|
||||||
level.overrideMethods[level.commonFunctions.setOutboundData] = ::SetOutboundData;
|
|
||||||
|
|
||||||
RegisterClientCommands();
|
RegisterClientCommands();
|
||||||
|
|
||||||
|
_SetDvarIfUninitialized( "sv_iw4madmin_autobalance", 0 );
|
||||||
|
|
||||||
level notify( level.notifyTypes.gameFunctionsInitialized );
|
level notify( level.notifyTypes.gameFunctionsInitialized );
|
||||||
|
|
||||||
scripts\_integration_base::_SetDvarIfUninitialized( level.commonKeys.busdir, GetDvar( "fs_homepath" ) + "userraw/" + "scriptdata" );
|
if ( GetDvarInt( "sv_iw4madmin_integration_enabled" ) != 1 )
|
||||||
|
|
||||||
if ( GetDvarInt( level.commonKeys.enabled ) != 1 )
|
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
thread OnPlayerConnect();
|
level thread OnPlayerConnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
OnPlayerConnect()
|
OnPlayerConnect()
|
||||||
@ -56,7 +51,7 @@ OnPlayerConnect()
|
|||||||
{
|
{
|
||||||
level waittill( "connected", player );
|
level waittill( "connected", player );
|
||||||
|
|
||||||
if ( player IsTestClient() )
|
if ( player call [[ level.overrideMethods[ level.commonFunctions.isBot ] ]]() )
|
||||||
{
|
{
|
||||||
// we don't want to track bots
|
// we don't want to track bots
|
||||||
continue;
|
continue;
|
||||||
@ -92,7 +87,7 @@ WaitForClientEvents()
|
|||||||
|
|
||||||
for ( ;; )
|
for ( ;; )
|
||||||
{
|
{
|
||||||
self waittill( level.eventTypes.eventAvailable, event );
|
self waittill( level.eventTypes.localClientEvent, event );
|
||||||
|
|
||||||
scripts\_integration_base::LogDebug( "Received client event " + event.type );
|
scripts\_integration_base::LogDebug( "Received client event " + event.type );
|
||||||
|
|
||||||
@ -104,26 +99,6 @@ WaitForClientEvents()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GetInboundData( location )
|
|
||||||
{
|
|
||||||
return FileRead( location );
|
|
||||||
}
|
|
||||||
|
|
||||||
GetOutboundData( location )
|
|
||||||
{
|
|
||||||
return FileRead( location );
|
|
||||||
}
|
|
||||||
|
|
||||||
SetInboundData( location, data )
|
|
||||||
{
|
|
||||||
FileWrite( location, data, "write" );
|
|
||||||
}
|
|
||||||
|
|
||||||
SetOutboundData( location, data )
|
|
||||||
{
|
|
||||||
FileWrite( location, data, "write" );
|
|
||||||
}
|
|
||||||
|
|
||||||
GetMaxClients()
|
GetMaxClients()
|
||||||
{
|
{
|
||||||
return level.maxClients;
|
return level.maxClients;
|
||||||
@ -211,7 +186,12 @@ GetTotalShotsFired()
|
|||||||
return maps\mp\_utility::getPlayerStat( "mostshotsfired" );
|
return maps\mp\_utility::getPlayerStat( "mostshotsfired" );
|
||||||
}
|
}
|
||||||
|
|
||||||
WaitillNotifyOrTimeoutWrapper( _notify, timeout )
|
_SetDvarIfUninitialized( dvar, value )
|
||||||
|
{
|
||||||
|
SetDvarIfUninitialized( dvar, value );
|
||||||
|
}
|
||||||
|
|
||||||
|
_waittill_notify_or_timeout( _notify, timeout )
|
||||||
{
|
{
|
||||||
common_scripts\utility::waittill_notify_or_timeout( _notify, timeout );
|
common_scripts\utility::waittill_notify_or_timeout( _notify, timeout );
|
||||||
}
|
}
|
||||||
@ -221,21 +201,11 @@ Log2Console( logLevel, message )
|
|||||||
PrintConsole( "[" + logLevel + "] " + message + "\n" );
|
PrintConsole( "[" + logLevel + "] " + message + "\n" );
|
||||||
}
|
}
|
||||||
|
|
||||||
SetDvarIfUninitializedWrapper( dvar, value )
|
_GetXUID()
|
||||||
{
|
|
||||||
SetDvarIfUninitialized( dvar, value );
|
|
||||||
}
|
|
||||||
|
|
||||||
GetXuidWrapper()
|
|
||||||
{
|
{
|
||||||
return self GetXUID();
|
return self GetXUID();
|
||||||
}
|
}
|
||||||
|
|
||||||
IsBotWrapper( client )
|
|
||||||
{
|
|
||||||
return client IsTestClient();
|
|
||||||
}
|
|
||||||
|
|
||||||
//////////////////////////////////
|
//////////////////////////////////
|
||||||
// GUID helpers
|
// GUID helpers
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
@ -548,8 +518,12 @@ HideImpl()
|
|||||||
}
|
}
|
||||||
|
|
||||||
AlertImpl( event, data )
|
AlertImpl( event, data )
|
||||||
|
{
|
||||||
|
if ( level.eventBus.gamename == "IW4" )
|
||||||
{
|
{
|
||||||
self thread maps\mp\gametypes\_hud_message::oldNotifyMessage( data["alertType"], data["message"], "compass_waypoint_target", ( 1, 0, 0 ), "ui_mp_nukebomb_timer", 7.5 );
|
self thread maps\mp\gametypes\_hud_message::oldNotifyMessage( data["alertType"], data["message"], "compass_waypoint_target", ( 1, 0, 0 ), "ui_mp_nukebomb_timer", 7.5 );
|
||||||
|
}
|
||||||
|
|
||||||
return "Sent alert to " + self.name;
|
return "Sent alert to " + self.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
#include common_scripts\utility;
|
#include common_scripts\utility;
|
||||||
|
|
||||||
#inline scripts\_integration_utility;
|
|
||||||
|
|
||||||
Init()
|
Init()
|
||||||
{
|
{
|
||||||
thread Setup();
|
thread Setup();
|
||||||
@ -10,22 +8,50 @@ Init()
|
|||||||
Setup()
|
Setup()
|
||||||
{
|
{
|
||||||
level endon( "game_ended" );
|
level endon( "game_ended" );
|
||||||
waittillframeend;
|
|
||||||
|
|
||||||
level waittill( level.notifyTypes.sharedFunctionsInitialized );
|
// it's possible that the notify type has not been defined yet so we have to hard code it
|
||||||
|
level waittill( "SharedFunctionsInitialized" );
|
||||||
level.eventBus.gamename = "IW5";
|
level.eventBus.gamename = "IW5";
|
||||||
|
|
||||||
scripts\_integration_base::RegisterLogger( ::Log2Console );
|
scripts\_integration_base::RegisterLogger( ::Log2Console );
|
||||||
|
|
||||||
level.overrideMethods[level.commonFunctions.getTotalShotsFired] = ::GetTotalShotsFired;
|
level.overrideMethods["GetTotalShotsFired"] = ::GetTotalShotsFired;
|
||||||
level.overrideMethods[level.commonFunctions.setDvar] = ::SetDvarIfUninitializedWrapper;
|
level.overrideMethods["SetDvarIfUninitialized"] = ::_SetDvarIfUninitialized;
|
||||||
level.overrideMethods[level.commonFunctions.waittillNotifyOrTimeout] = ::WaitillNotifyOrTimeoutWrapper;
|
level.overrideMethods["waittill_notify_or_timeout"] = ::_waittill_notify_or_timeout;
|
||||||
level.overrideMethods[level.commonFunctions.isBot] = ::IsBotWrapper;
|
level.overrideMethods[level.commonFunctions.isBot] = ::IsTestClient;
|
||||||
level.overrideMethods[level.commonFunctions.getXuid] = ::GetXuidWrapper;
|
level.overrideMethods[level.commonFunctions.getXuid] = ::_GetXUID;
|
||||||
level.overrideMethods[level.commonFunctions.waitTillAnyTimeout] = ::WaitTillAnyTimeout;
|
|
||||||
RegisterClientCommands();
|
RegisterClientCommands();
|
||||||
|
|
||||||
|
_SetDvarIfUninitialized( "sv_iw4madmin_autobalance", 0 );
|
||||||
|
|
||||||
level notify( level.notifyTypes.gameFunctionsInitialized );
|
level notify( level.notifyTypes.gameFunctionsInitialized );
|
||||||
|
|
||||||
|
if ( GetDvarInt( "sv_iw4madmin_integration_enabled" ) != 1 )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
level thread OnPlayerConnect();
|
||||||
|
}
|
||||||
|
|
||||||
|
OnPlayerConnect()
|
||||||
|
{
|
||||||
|
level endon ( "game_ended" );
|
||||||
|
|
||||||
|
for ( ;; )
|
||||||
|
{
|
||||||
|
level waittill( "connected", player );
|
||||||
|
|
||||||
|
if ( player call [[ level.overrideMethods[ level.commonFunctions.isBot ] ]]() )
|
||||||
|
{
|
||||||
|
// we don't want to track bots
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
player thread SetPersistentData();
|
||||||
|
player thread WaitForClientEvents();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RegisterClientCommands()
|
RegisterClientCommands()
|
||||||
@ -43,17 +69,39 @@ RegisterClientCommands()
|
|||||||
scripts\_integration_base::AddClientCommand( "NoClip", false, ::NoClipImpl );
|
scripts\_integration_base::AddClientCommand( "NoClip", false, ::NoClipImpl );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WaitForClientEvents()
|
||||||
|
{
|
||||||
|
self endon( "disconnect" );
|
||||||
|
|
||||||
|
// example of requesting a meta value
|
||||||
|
lastServerMetaKey = "LastServerPlayed";
|
||||||
|
// self scripts\_integration_base::RequestClientMeta( lastServerMetaKey );
|
||||||
|
|
||||||
|
for ( ;; )
|
||||||
|
{
|
||||||
|
self waittill( level.eventTypes.localClientEvent, event );
|
||||||
|
|
||||||
|
scripts\_integration_base::LogDebug( "Received client event " + event.type );
|
||||||
|
|
||||||
|
if ( event.type == level.eventTypes.clientDataReceived && event.data[0] == lastServerMetaKey )
|
||||||
|
{
|
||||||
|
clientData = self.pers[level.clientDataKey];
|
||||||
|
lastServerPlayed = clientData.meta[lastServerMetaKey];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
GetTotalShotsFired()
|
GetTotalShotsFired()
|
||||||
{
|
{
|
||||||
return maps\mp\_utility::getPlayerStat( "mostshotsfired" );
|
return maps\mp\_utility::getPlayerStat( "mostshotsfired" );
|
||||||
}
|
}
|
||||||
|
|
||||||
SetDvarIfUninitializedWrapper( dvar, value )
|
_SetDvarIfUninitialized( dvar, value )
|
||||||
{
|
{
|
||||||
SetDvarIfUninitialized( dvar, value );
|
SetDvarIfUninitialized( dvar, value );
|
||||||
}
|
}
|
||||||
|
|
||||||
WaitillNotifyOrTimeoutWrapper( _notify, timeout )
|
_waittill_notify_or_timeout( _notify, timeout )
|
||||||
{
|
{
|
||||||
common_scripts\utility::waittill_notify_or_timeout( _notify, timeout );
|
common_scripts\utility::waittill_notify_or_timeout( _notify, timeout );
|
||||||
}
|
}
|
||||||
@ -63,19 +111,140 @@ Log2Console( logLevel, message )
|
|||||||
Print( "[" + logLevel + "] " + message + "\n" );
|
Print( "[" + logLevel + "] " + message + "\n" );
|
||||||
}
|
}
|
||||||
|
|
||||||
IsBotWrapper( client )
|
_GetXUID()
|
||||||
{
|
|
||||||
return client IsTestClient();
|
|
||||||
}
|
|
||||||
|
|
||||||
GetXuidWrapper()
|
|
||||||
{
|
{
|
||||||
return self GetXUID();
|
return self GetXUID();
|
||||||
}
|
}
|
||||||
|
|
||||||
WaitTillAnyTimeout( timeOut, string1, string2, string3, string4, string5 )
|
//////////////////////////////////
|
||||||
|
// GUID helpers
|
||||||
|
/////////////////////////////////
|
||||||
|
|
||||||
|
SetPersistentData()
|
||||||
{
|
{
|
||||||
return common_scripts\utility::waittill_any_timeout( timeOut, string1, string2, string3, string4, string5 );
|
self endon( "disconnect" );
|
||||||
|
|
||||||
|
guidHigh = self GetPlayerData( "bests", "none" );
|
||||||
|
guidLow = self GetPlayerData( "awards", "none" );
|
||||||
|
persistentGuid = guidHigh + "," + guidLow;
|
||||||
|
guidIsStored = guidHigh != 0 && guidLow != 0;
|
||||||
|
|
||||||
|
if ( guidIsStored )
|
||||||
|
{
|
||||||
|
// give IW4MAdmin time to collect IP
|
||||||
|
wait( 15 );
|
||||||
|
scripts\_integration_base::LogDebug( "Uploading persistent guid " + persistentGuid );
|
||||||
|
scripts\_integration_base::SetClientMeta( "PersistentClientGuid", persistentGuid );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
guid = self SplitGuid();
|
||||||
|
|
||||||
|
scripts\_integration_base::LogDebug( "Persisting client guid " + guidHigh + "," + guidLow );
|
||||||
|
|
||||||
|
self SetPlayerData( "bests", "none", guid["high"] );
|
||||||
|
self SetPlayerData( "awards", "none", guid["low"] );
|
||||||
|
}
|
||||||
|
|
||||||
|
SplitGuid()
|
||||||
|
{
|
||||||
|
guid = self GetGuid();
|
||||||
|
|
||||||
|
if ( isDefined( self.guid ) )
|
||||||
|
{
|
||||||
|
guid = self.guid;
|
||||||
|
}
|
||||||
|
|
||||||
|
firstPart = 0;
|
||||||
|
secondPart = 0;
|
||||||
|
stringLength = 17;
|
||||||
|
firstPartExp = 0;
|
||||||
|
secondPartExp = 0;
|
||||||
|
|
||||||
|
for ( i = stringLength - 1; i > 0; i-- )
|
||||||
|
{
|
||||||
|
char = GetSubStr( guid, i - 1, i );
|
||||||
|
if ( char == "" )
|
||||||
|
{
|
||||||
|
char = "0";
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( i > stringLength / 2 )
|
||||||
|
{
|
||||||
|
value = GetIntForHexChar( char );
|
||||||
|
power = Pow( 16, secondPartExp );
|
||||||
|
secondPart = secondPart + ( value * power );
|
||||||
|
secondPartExp++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
value = GetIntForHexChar( char );
|
||||||
|
power = Pow( 16, firstPartExp );
|
||||||
|
firstPart = firstPart + ( value * power );
|
||||||
|
firstPartExp++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
split = [];
|
||||||
|
split["low"] = int( secondPart );
|
||||||
|
split["high"] = int( firstPart );
|
||||||
|
|
||||||
|
return split;
|
||||||
|
}
|
||||||
|
|
||||||
|
Pow( num, exponent )
|
||||||
|
{
|
||||||
|
result = 1;
|
||||||
|
while( exponent != 0 )
|
||||||
|
{
|
||||||
|
result = result * num;
|
||||||
|
exponent--;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
GetIntForHexChar( char )
|
||||||
|
{
|
||||||
|
char = ToLower( char );
|
||||||
|
// generated by co-pilot because I can't be bothered to make it more "elegant"
|
||||||
|
switch( char )
|
||||||
|
{
|
||||||
|
case "0":
|
||||||
|
return 0;
|
||||||
|
case "1":
|
||||||
|
return 1;
|
||||||
|
case "2":
|
||||||
|
return 2;
|
||||||
|
case "3":
|
||||||
|
return 3;
|
||||||
|
case "4":
|
||||||
|
return 4;
|
||||||
|
case "5":
|
||||||
|
return 5;
|
||||||
|
case "6":
|
||||||
|
return 6;
|
||||||
|
case "7":
|
||||||
|
return 7;
|
||||||
|
case "8":
|
||||||
|
return 8;
|
||||||
|
case "9":
|
||||||
|
return 9;
|
||||||
|
case "a":
|
||||||
|
return 10;
|
||||||
|
case "b":
|
||||||
|
return 11;
|
||||||
|
case "c":
|
||||||
|
return 12;
|
||||||
|
case "d":
|
||||||
|
return 13;
|
||||||
|
case "e":
|
||||||
|
return 14;
|
||||||
|
case "f":
|
||||||
|
return 15;
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////
|
//////////////////////////////////
|
||||||
@ -84,7 +253,10 @@ WaitTillAnyTimeout( timeOut, string1, string2, string3, string4, string5 )
|
|||||||
|
|
||||||
GiveWeaponImpl( event, data )
|
GiveWeaponImpl( event, data )
|
||||||
{
|
{
|
||||||
_IS_ALIVE( self );
|
if ( !IsAlive( self ) )
|
||||||
|
{
|
||||||
|
return self.name + "^7 is not alive";
|
||||||
|
}
|
||||||
|
|
||||||
self IPrintLnBold( "You have been given a new weapon" );
|
self IPrintLnBold( "You have been given a new weapon" );
|
||||||
self GiveWeapon( data["weaponName"] );
|
self GiveWeapon( data["weaponName"] );
|
||||||
@ -95,7 +267,10 @@ GiveWeaponImpl( event, data )
|
|||||||
|
|
||||||
TakeWeaponsImpl()
|
TakeWeaponsImpl()
|
||||||
{
|
{
|
||||||
_IS_ALIVE( self );
|
if ( !IsAlive( self ) )
|
||||||
|
{
|
||||||
|
return self.name + "^7 is not alive";
|
||||||
|
}
|
||||||
|
|
||||||
self TakeAllWeapons();
|
self TakeAllWeapons();
|
||||||
self IPrintLnBold( "All your weapons have been taken" );
|
self IPrintLnBold( "All your weapons have been taken" );
|
||||||
@ -105,7 +280,10 @@ TakeWeaponsImpl()
|
|||||||
|
|
||||||
TeamSwitchImpl()
|
TeamSwitchImpl()
|
||||||
{
|
{
|
||||||
_IS_ALIVE( self );
|
if ( !IsAlive( self ) )
|
||||||
|
{
|
||||||
|
return self + "^7 is not alive";
|
||||||
|
}
|
||||||
|
|
||||||
team = level.allies;
|
team = level.allies;
|
||||||
|
|
||||||
@ -123,7 +301,10 @@ TeamSwitchImpl()
|
|||||||
|
|
||||||
LockControlsImpl()
|
LockControlsImpl()
|
||||||
{
|
{
|
||||||
_IS_ALIVE( self );
|
if ( !IsAlive( self ) )
|
||||||
|
{
|
||||||
|
return self.name + "^7 is not alive";
|
||||||
|
}
|
||||||
|
|
||||||
if ( !IsDefined ( self.isControlLocked ) )
|
if ( !IsDefined ( self.isControlLocked ) )
|
||||||
{
|
{
|
||||||
@ -160,8 +341,6 @@ LockControlsImpl()
|
|||||||
|
|
||||||
NoClipImpl()
|
NoClipImpl()
|
||||||
{
|
{
|
||||||
_VERIFY_PLAYER_ENT( self );
|
|
||||||
|
|
||||||
if ( !IsAlive( self ) )
|
if ( !IsAlive( self ) )
|
||||||
{
|
{
|
||||||
self IPrintLnBold( "You are not alive" );
|
self IPrintLnBold( "You are not alive" );
|
||||||
@ -207,11 +386,10 @@ NoClipImpl()
|
|||||||
|
|
||||||
HideImpl()
|
HideImpl()
|
||||||
{
|
{
|
||||||
_VERIFY_PLAYER_ENT( self );
|
|
||||||
|
|
||||||
if ( !IsAlive( self ) )
|
if ( !IsAlive( self ) )
|
||||||
{
|
{
|
||||||
self IPrintLnBold( "You are not alive" );
|
self IPrintLnBold( "You are not alive" );
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !IsDefined ( self.isHidden ) )
|
if ( !IsDefined ( self.isHidden ) )
|
||||||
@ -249,7 +427,10 @@ HideImpl()
|
|||||||
|
|
||||||
AlertImpl( event, data )
|
AlertImpl( event, data )
|
||||||
{
|
{
|
||||||
|
if ( level.eventBus.gamename == "IW5" ) {
|
||||||
self thread maps\mp\gametypes\_hud_message::oldNotifyMessage( data["alertType"], data["message"], undefined, ( 1, 0, 0 ), "ui_mp_nukebomb_timer", 7.5 );
|
self thread maps\mp\gametypes\_hud_message::oldNotifyMessage( data["alertType"], data["message"], undefined, ( 1, 0, 0 ), "ui_mp_nukebomb_timer", 7.5 );
|
||||||
|
}
|
||||||
|
|
||||||
return "Sent alert to " + self.name;
|
return "Sent alert to " + self.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -267,8 +448,6 @@ GotoImpl( event, data )
|
|||||||
|
|
||||||
GotoCoordImpl( data )
|
GotoCoordImpl( data )
|
||||||
{
|
{
|
||||||
_VERIFY_PLAYER_ENT( self );
|
|
||||||
|
|
||||||
if ( !IsAlive( self ) )
|
if ( !IsAlive( self ) )
|
||||||
{
|
{
|
||||||
self IPrintLnBold( "You are not alive" );
|
self IPrintLnBold( "You are not alive" );
|
||||||
@ -282,8 +461,6 @@ GotoCoordImpl( data )
|
|||||||
|
|
||||||
GotoPlayerImpl( target )
|
GotoPlayerImpl( target )
|
||||||
{
|
{
|
||||||
_VERIFY_PLAYER_ENT( self );
|
|
||||||
|
|
||||||
if ( !IsAlive( target ) )
|
if ( !IsAlive( target ) )
|
||||||
{
|
{
|
||||||
self IPrintLnBold( target.name + " is not alive" );
|
self IPrintLnBold( target.name + " is not alive" );
|
||||||
@ -296,7 +473,10 @@ GotoPlayerImpl( target )
|
|||||||
|
|
||||||
PlayerToMeImpl( event )
|
PlayerToMeImpl( event )
|
||||||
{
|
{
|
||||||
_IS_ALIVE( self );
|
if ( !IsAlive( self ) )
|
||||||
|
{
|
||||||
|
return self.name + " is not alive";
|
||||||
|
}
|
||||||
|
|
||||||
self SetOrigin( event.origin GetOrigin() );
|
self SetOrigin( event.origin GetOrigin() );
|
||||||
return "Moved here " + self.name;
|
return "Moved here " + self.name;
|
||||||
@ -304,7 +484,10 @@ PlayerToMeImpl( event )
|
|||||||
|
|
||||||
KillImpl()
|
KillImpl()
|
||||||
{
|
{
|
||||||
_IS_ALIVE( self );
|
if ( !IsAlive( self ) )
|
||||||
|
{
|
||||||
|
return self.name + " is not alive";
|
||||||
|
}
|
||||||
|
|
||||||
self Suicide();
|
self Suicide();
|
||||||
self IPrintLnBold( "You were killed by " + self.name );
|
self IPrintLnBold( "You were killed by " + self.name );
|
||||||
@ -314,8 +497,6 @@ KillImpl()
|
|||||||
|
|
||||||
SetSpectatorImpl()
|
SetSpectatorImpl()
|
||||||
{
|
{
|
||||||
_VERIFY_PLAYER_ENT( self );
|
|
||||||
|
|
||||||
if ( self.pers["team"] == "spectator" )
|
if ( self.pers["team"] == "spectator" )
|
||||||
{
|
{
|
||||||
return self.name + " is already spectating";
|
return self.name + " is already spectating";
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
Init()
|
Init()
|
||||||
{
|
{
|
||||||
thread Setup();
|
thread Setup();
|
||||||
@ -5,10 +6,10 @@ Init()
|
|||||||
|
|
||||||
Setup()
|
Setup()
|
||||||
{
|
{
|
||||||
wait ( 0.05 );
|
|
||||||
level endon( "game_ended" );
|
level endon( "game_ended" );
|
||||||
|
|
||||||
level waittill( level.notifyTypes.integrationBootstrapInitialized );
|
// it's possible that the notify type has not been defined yet so we have to hard code it
|
||||||
|
level waittill( "IntegrationBootstrapInitialized" );
|
||||||
|
|
||||||
level.commonFunctions.changeTeam = "ChangeTeam";
|
level.commonFunctions.changeTeam = "ChangeTeam";
|
||||||
level.commonFunctions.getTeamCounts = "GetTeamCounts";
|
level.commonFunctions.getTeamCounts = "GetTeamCounts";
|
||||||
@ -17,10 +18,7 @@ Setup()
|
|||||||
level.commonFunctions.getClientTeam = "GetClientTeam";
|
level.commonFunctions.getClientTeam = "GetClientTeam";
|
||||||
level.commonFunctions.getClientKillStreak = "GetClientKillStreak";
|
level.commonFunctions.getClientKillStreak = "GetClientKillStreak";
|
||||||
level.commonFunctions.backupRestoreClientKillStreakData = "BackupRestoreClientKillStreakData";
|
level.commonFunctions.backupRestoreClientKillStreakData = "BackupRestoreClientKillStreakData";
|
||||||
level.commonFunctions.getTotalShotsFired = "GetTotalShotsFired";
|
|
||||||
level.commonFunctions.waitTillAnyTimeout = "WaitTillAnyTimeout";
|
level.commonFunctions.waitTillAnyTimeout = "WaitTillAnyTimeout";
|
||||||
level.commonFunctions.isBot = "IsBot";
|
|
||||||
level.commonFunctions.getXuid = "GetXuid";
|
|
||||||
|
|
||||||
level.overrideMethods[level.commonFunctions.changeTeam] = scripts\_integration_base::NotImplementedFunction;
|
level.overrideMethods[level.commonFunctions.changeTeam] = scripts\_integration_base::NotImplementedFunction;
|
||||||
level.overrideMethods[level.commonFunctions.getTeamCounts] = scripts\_integration_base::NotImplementedFunction;
|
level.overrideMethods[level.commonFunctions.getTeamCounts] = scripts\_integration_base::NotImplementedFunction;
|
||||||
@ -30,52 +28,30 @@ Setup()
|
|||||||
level.overrideMethods[level.commonFunctions.getClientKillStreak] = scripts\_integration_base::NotImplementedFunction;
|
level.overrideMethods[level.commonFunctions.getClientKillStreak] = scripts\_integration_base::NotImplementedFunction;
|
||||||
level.overrideMethods[level.commonFunctions.backupRestoreClientKillStreakData] = scripts\_integration_base::NotImplementedFunction;
|
level.overrideMethods[level.commonFunctions.backupRestoreClientKillStreakData] = scripts\_integration_base::NotImplementedFunction;
|
||||||
level.overrideMethods[level.commonFunctions.waitTillAnyTimeout] = scripts\_integration_base::NotImplementedFunction;
|
level.overrideMethods[level.commonFunctions.waitTillAnyTimeout] = scripts\_integration_base::NotImplementedFunction;
|
||||||
level.overrideMethods[level.commonFunctions.getXuid] = scripts\_integration_base::NotImplementedFunction;
|
level.overrideMethods["GetPlayerFromClientNum"] = ::GetPlayerFromClientNum;
|
||||||
level.overrideMethods[level.commonFunctions.isBot] = scripts\_integration_base::NotImplementedFunction;
|
|
||||||
|
|
||||||
// these can be overridden per game if needed
|
// these can be overridden per game if needed
|
||||||
level.commonKeys.team1 = "allies";
|
level.commonKeys.team1 = "allies";
|
||||||
level.commonKeys.team2 = "axis";
|
level.commonKeys.team2 = "axis";
|
||||||
level.commonKeys.teamSpectator = "spectator";
|
level.commonKeys.teamSpectator = "spectator";
|
||||||
level.commonKeys.autoBalance = "sv_iw4madmin_autobalance";
|
|
||||||
|
|
||||||
level.eventTypes.connect = "connected";
|
level.eventTypes.connect = "connected";
|
||||||
level.eventTypes.disconnect = "disconnect";
|
level.eventTypes.disconnect = "disconnect";
|
||||||
level.eventTypes.joinTeam = "joined_team";
|
level.eventTypes.joinTeam = "joined_team";
|
||||||
level.eventTypes.joinSpec = "joined_spectators";
|
|
||||||
level.eventTypes.spawned = "spawned_player";
|
level.eventTypes.spawned = "spawned_player";
|
||||||
level.eventTypes.gameEnd = "game_ended";
|
level.eventTypes.gameEnd = "game_ended";
|
||||||
|
|
||||||
level.eventTypes.urlRequested = "UrlRequested";
|
|
||||||
level.eventTypes.urlRequestCompleted = "UrlRequestCompleted";
|
|
||||||
level.eventTypes.registerCommandRequested = "RegisterCommandRequested";
|
|
||||||
level.eventTypes.getCommandsRequested = "GetCommandsRequested";
|
|
||||||
level.eventTypes.getBusModeRequested = "GetBusModeRequested";
|
|
||||||
|
|
||||||
level.eventCallbacks[level.eventTypes.urlRequestCompleted] = ::OnUrlRequestCompletedCallback;
|
|
||||||
level.eventCallbacks[level.eventTypes.getCommandsRequested] = ::OnCommandsRequestedCallback;
|
|
||||||
level.eventCallbacks[level.eventTypes.getBusModeRequested] = ::OnBusModeRequestedCallback;
|
|
||||||
|
|
||||||
level.iw4madminIntegrationDefaultPerformance = 200;
|
level.iw4madminIntegrationDefaultPerformance = 200;
|
||||||
level.notifyEntities = [];
|
|
||||||
level.customCommands = [];
|
|
||||||
|
|
||||||
level notify( level.notifyTypes.sharedFunctionsInitialized );
|
level notify( level.notifyTypes.sharedFunctionsInitialized );
|
||||||
level waittill( level.notifyTypes.gameFunctionsInitialized );
|
level waittill( level.notifyTypes.gameFunctionsInitialized );
|
||||||
|
|
||||||
scripts\_integration_base::_SetDvarIfUninitialized( level.commonKeys.autoBalance, 0 );
|
if ( GetDvarInt( "sv_iw4madmin_integration_enabled" ) != 1 )
|
||||||
|
|
||||||
if ( GetDvarInt( level.commonKeys.enabled ) != 1 )
|
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
thread OnPlayerConnect();
|
level thread OnPlayerConnect();
|
||||||
}
|
|
||||||
|
|
||||||
_IsBot( player )
|
|
||||||
{
|
|
||||||
return [[level.overrideMethods[level.commonFunctions.isBot]]]( player );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
OnPlayerConnect()
|
OnPlayerConnect()
|
||||||
@ -86,23 +62,17 @@ OnPlayerConnect()
|
|||||||
{
|
{
|
||||||
level waittill( level.eventTypes.connect, player );
|
level waittill( level.eventTypes.connect, player );
|
||||||
|
|
||||||
if ( _IsBot( player ) )
|
if ( scripts\_integration_base::_IsBot( player ) )
|
||||||
{
|
{
|
||||||
// we don't want to track bots
|
// we don't want to track bots
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !IsDefined( player.pers[level.clientDataKey] ) )
|
|
||||||
{
|
|
||||||
player.pers[level.clientDataKey] = spawnstruct();
|
|
||||||
}
|
|
||||||
|
|
||||||
player thread OnPlayerSpawned();
|
|
||||||
player thread OnPlayerJoinedTeam();
|
player thread OnPlayerJoinedTeam();
|
||||||
player thread OnPlayerJoinedSpectators();
|
player thread OnPlayerJoinedSpectators();
|
||||||
player thread PlayerTrackingOnInterval();
|
player thread PlayerTrackingOnInterval();
|
||||||
|
|
||||||
if ( GetDvarInt( level.commonKeys.autoBalance ) != 1 || !IsDefined( [[level.overrideMethods[level.commonFunctions.getTeamBased]]]() ) )
|
if ( GetDvarInt( "sv_iw4madmin_autobalance" ) != 1 || !IsDefined( [[level.overrideMethods[level.commonFunctions.getTeamBased]]]() ) )
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -115,341 +85,13 @@ OnPlayerConnect()
|
|||||||
teamToJoin = player GetTeamToJoin();
|
teamToJoin = player GetTeamToJoin();
|
||||||
player [[level.overrideMethods[level.commonFunctions.changeTeam]]]( teamToJoin );
|
player [[level.overrideMethods[level.commonFunctions.changeTeam]]]( teamToJoin );
|
||||||
|
|
||||||
player thread OnPlayerFirstSpawn();
|
player thread OnClientFirstSpawn();
|
||||||
player thread OnPlayerDisconnect();
|
player thread OnClientJoinedTeam();
|
||||||
|
player thread OnClientDisconnect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerSpawnEvents()
|
OnClientDisconnect()
|
||||||
{
|
|
||||||
self endon( level.eventTypes.disconnect );
|
|
||||||
|
|
||||||
clientData = self.pers[level.clientDataKey];
|
|
||||||
|
|
||||||
// this gives IW4MAdmin some time to register the player before making the request;
|
|
||||||
// although probably not necessary some users might have a slow database or poll rate
|
|
||||||
wait ( 2 );
|
|
||||||
|
|
||||||
if ( IsDefined( clientData.state ) && clientData.state == "complete" )
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
self scripts\_integration_base::RequestClientBasicData();
|
|
||||||
|
|
||||||
self waittill( level.eventTypes.clientDataReceived, clientEvent );
|
|
||||||
|
|
||||||
if ( clientData.permissionLevel == "User" || clientData.permissionLevel == "Flagged" )
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
self IPrintLnBold( "Welcome, your level is ^5" + clientData.permissionLevel );
|
|
||||||
wait( 2.0 );
|
|
||||||
self IPrintLnBold( "You were last seen ^5" + clientData.lastConnection + " ago" );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
PlayerTrackingOnInterval()
|
|
||||||
{
|
|
||||||
self endon( level.eventTypes.disconnect );
|
|
||||||
|
|
||||||
for ( ;; )
|
|
||||||
{
|
|
||||||
wait ( 120 );
|
|
||||||
if ( IsAlive( self ) )
|
|
||||||
{
|
|
||||||
self SaveTrackingMetrics();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
SaveTrackingMetrics()
|
|
||||||
{
|
|
||||||
if ( !IsDefined( self.persistentClientId ) )
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
scripts\_integration_base::LogDebug( "Saving tracking metrics for " + self.persistentClientId );
|
|
||||||
|
|
||||||
if ( !IsDefined( self.lastShotCount ) )
|
|
||||||
{
|
|
||||||
self.lastShotCount = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
currentShotCount = self [[level.overrideMethods["GetTotalShotsFired"]]]();
|
|
||||||
change = currentShotCount - self.lastShotCount;
|
|
||||||
self.lastShotCount = currentShotCount;
|
|
||||||
|
|
||||||
scripts\_integration_base::LogDebug( "Total Shots Fired increased by " + change );
|
|
||||||
|
|
||||||
if ( !IsDefined( change ) )
|
|
||||||
{
|
|
||||||
change = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( change == 0 )
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
scripts\_integration_base::IncrementClientMeta( "TotalShotsFired", change, self.persistentClientId );
|
|
||||||
}
|
|
||||||
|
|
||||||
OnBusModeRequestedCallback( event )
|
|
||||||
{
|
|
||||||
data = [];
|
|
||||||
data["mode"] = GetDvar( level.commonKeys.busMode );
|
|
||||||
data["directory"] = GetDvar( level.commonKeys.busDir );
|
|
||||||
data["inLocation"] = level.eventBus.inLocation;
|
|
||||||
data["outLocation"] = level.eventBus.outLocation;
|
|
||||||
|
|
||||||
scripts\_integration_base::LogDebug( "Bus mode requested" );
|
|
||||||
|
|
||||||
busModeRequest = scripts\_integration_base::BuildEventRequest( false, level.eventTypes.getBusModeRequested, "", undefined, data );
|
|
||||||
scripts\_integration_base::QueueEvent( busModeRequest, level.eventTypes.getBusModeRequested, undefined );
|
|
||||||
|
|
||||||
scripts\_integration_base::LogDebug( "Bus mode updated" );
|
|
||||||
|
|
||||||
if ( GetDvar( level.commonKeys.busMode ) == "file" && GetDvar( level.commonKeys.busDir ) != "" )
|
|
||||||
{
|
|
||||||
level.busMethods[level.commonFunctions.getInboundData] = level.overrideMethods[level.commonFunctions.getInboundData];
|
|
||||||
level.busMethods[level.commonFunctions.getOutboundData] = level.overrideMethods[level.commonFunctions.getOutboundData];
|
|
||||||
level.busMethods[level.commonFunctions.setInboundData] = level.overrideMethods[level.commonFunctions.setInboundData];
|
|
||||||
level.busMethods[level.commonFunctions.setOutboundData] = level.overrideMethods[level.commonFunctions.setOutboundData];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// #region register script command
|
|
||||||
|
|
||||||
OnCommandsRequestedCallback( event )
|
|
||||||
{
|
|
||||||
scripts\_integration_base::LogDebug( "Get commands requested" );
|
|
||||||
thread SendCommands( event.data["name"] );
|
|
||||||
}
|
|
||||||
|
|
||||||
SendCommands( commandName )
|
|
||||||
{
|
|
||||||
level endon( level.eventTypes.gameEnd );
|
|
||||||
|
|
||||||
for ( i = 0; i < level.customCommands.size; i++ )
|
|
||||||
{
|
|
||||||
data = level.customCommands[i];
|
|
||||||
|
|
||||||
if ( IsDefined( commandName ) && commandName != data["name"] )
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
scripts\_integration_base::LogDebug( "Sending custom command " + ( i + 1 ) + "/" + level.customCommands.size + ": " + data["name"] );
|
|
||||||
commandRegisterRequest = scripts\_integration_base::BuildEventRequest( false, level.eventTypes.registerCommandRequested, "", undefined, data );
|
|
||||||
// not threading here as there might be a lot of commands to register
|
|
||||||
scripts\_integration_base::QueueEvent( commandRegisterRequest, level.eventTypes.registerCommandRequested, undefined );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
RegisterScriptCommandObject( command )
|
|
||||||
{
|
|
||||||
RegisterScriptCommand( command.eventKey, command.name, command.alias, command.description, command.minPermission, command.supportedGames, command.requiresTarget, command.handler );
|
|
||||||
}
|
|
||||||
|
|
||||||
RegisterScriptCommand( eventKey, name, alias, description, minPermission, supportedGames, requiresTarget, handler )
|
|
||||||
{
|
|
||||||
if ( !IsDefined( eventKey ) )
|
|
||||||
{
|
|
||||||
scripts\_integration_base::LogError( "eventKey must be provided for script command" );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
data = [];
|
|
||||||
|
|
||||||
data["eventKey"] = eventKey;
|
|
||||||
|
|
||||||
if ( IsDefined( name ) )
|
|
||||||
{
|
|
||||||
data["name"] = name;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
scripts\_integration_base::LogError( "name must be provided for script command" );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( IsDefined( alias ) )
|
|
||||||
{
|
|
||||||
data["alias"] = alias;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( IsDefined( description ) )
|
|
||||||
{
|
|
||||||
data["description"] = description;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( IsDefined( minPermission ) )
|
|
||||||
{
|
|
||||||
data["minPermission"] = minPermission;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( IsDefined( supportedGames ) )
|
|
||||||
{
|
|
||||||
data["supportedGames"] = supportedGames;
|
|
||||||
}
|
|
||||||
|
|
||||||
data["requiresTarget"] = false;
|
|
||||||
|
|
||||||
if ( IsDefined( requiresTarget ) )
|
|
||||||
{
|
|
||||||
data["requiresTarget"] = requiresTarget;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( IsDefined( handler ) )
|
|
||||||
{
|
|
||||||
level.clientCommandCallbacks[eventKey + "Execute"] = handler;
|
|
||||||
level.clientCommandRusAsTarget[eventKey + "Execute"] = data["requiresTarget"];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
scripts\_integration_base::LogWarning( "handler not defined for script command " + name );
|
|
||||||
}
|
|
||||||
|
|
||||||
level.customCommands[level.customCommands.size] = data;
|
|
||||||
}
|
|
||||||
|
|
||||||
// #end region
|
|
||||||
|
|
||||||
// #region web requests
|
|
||||||
|
|
||||||
RequestUrlObject( request )
|
|
||||||
{
|
|
||||||
return RequestUrl( request.url, request.method, request.body, request.headers, request );
|
|
||||||
}
|
|
||||||
|
|
||||||
RequestUrl( url, method, body, headers, webNotify )
|
|
||||||
{
|
|
||||||
if ( !IsDefined( webNotify ) )
|
|
||||||
{
|
|
||||||
webNotify = SpawnStruct();
|
|
||||||
webNotify.url = url;
|
|
||||||
webNotify.method = method;
|
|
||||||
webNotify.body = body;
|
|
||||||
webNotify.headers = headers;
|
|
||||||
}
|
|
||||||
|
|
||||||
webNotify.index = GetNextNotifyEntity();
|
|
||||||
|
|
||||||
scripts\_integration_base::LogDebug( "next notify index is " + webNotify.index );
|
|
||||||
level.notifyEntities[webNotify.index] = webNotify;
|
|
||||||
|
|
||||||
data = [];
|
|
||||||
data["url"] = webNotify.url;
|
|
||||||
data["entity"] = webNotify.index;
|
|
||||||
|
|
||||||
if ( IsDefined( method ) )
|
|
||||||
{
|
|
||||||
data["method"] = method;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( IsDefined( body ) )
|
|
||||||
{
|
|
||||||
data["body"] = body;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( IsDefined( headers ) )
|
|
||||||
{
|
|
||||||
headerString = "";
|
|
||||||
|
|
||||||
keys = GetArrayKeys( headers );
|
|
||||||
for ( i = 0; i < keys.size; i++ )
|
|
||||||
{
|
|
||||||
headerString = headerString + keys[i] + ":" + headers[keys[i]] + ",";
|
|
||||||
}
|
|
||||||
|
|
||||||
data["headers"] = headerString;
|
|
||||||
}
|
|
||||||
|
|
||||||
webNotifyEvent = scripts\_integration_base::BuildEventRequest( true, level.eventTypes.urlRequested, "", webNotify.index, data );
|
|
||||||
thread scripts\_integration_base::QueueEvent( webNotifyEvent, level.eventTypes.urlRequested, webNotify );
|
|
||||||
webNotify thread WaitForUrlRequestComplete();
|
|
||||||
|
|
||||||
return webNotify;
|
|
||||||
}
|
|
||||||
|
|
||||||
WaitForUrlRequestComplete()
|
|
||||||
{
|
|
||||||
level endon( level.eventTypes.gameEnd );
|
|
||||||
|
|
||||||
timeoutResult = self [[level.overrideMethods[level.commonFunctions.waitTillAnyTimeout]]]( 30, level.eventTypes.urlRequestCompleted );
|
|
||||||
|
|
||||||
if ( timeoutResult == level.eventBus.timeoutKey )
|
|
||||||
{
|
|
||||||
scripts\_integration_base::LogWarning( "Request to " + self.url + " timed out" );
|
|
||||||
self notify ( level.eventTypes.urlRequestCompleted, "error" );
|
|
||||||
}
|
|
||||||
|
|
||||||
scripts\_integration_base::LogDebug( "Request to " + self.url + " completed" );
|
|
||||||
|
|
||||||
level.notifyEntities[self.index] = undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
OnUrlRequestCompletedCallback( event )
|
|
||||||
{
|
|
||||||
if ( !IsDefined( event ) || !IsDefined( event.data ) )
|
|
||||||
{
|
|
||||||
scripts\_integration_base::LogWarning( "Incomplete data for url request callback. [1]" );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
notifyEnt = event.data["entity"];
|
|
||||||
response = event.data["response"];
|
|
||||||
|
|
||||||
if ( !IsDefined( notifyEnt ) || !IsDefined( response ) )
|
|
||||||
{
|
|
||||||
scripts\_integration_base::LogWarning( "Incomplete data for url request callback. [2] " + scripts\_integration_base::CoerceUndefined( notifyEnt ) + " , " + scripts\_integration_base::CoerceUndefined( response ) );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
webNotify = level.notifyEntities[int( notifyEnt )];
|
|
||||||
|
|
||||||
if ( !IsDefined( webNotify.response ) )
|
|
||||||
{
|
|
||||||
webNotify.response = response;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
webNotify.response = webNotify.response + response;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( int( event.data["remaining"] ) != 0 )
|
|
||||||
{
|
|
||||||
scripts\_integration_base::LogDebug( "Additional data available for url request " + notifyEnt + " (" + event.data["remaining"] + " chunks remaining)" );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
scripts\_integration_base::LogDebug( "Notifying " + notifyEnt + " that url request completed" );
|
|
||||||
webNotify notify( level.eventTypes.urlRequestCompleted, webNotify.response );
|
|
||||||
}
|
|
||||||
|
|
||||||
GetNextNotifyEntity()
|
|
||||||
{
|
|
||||||
max = level.notifyEntities.size + 1;
|
|
||||||
|
|
||||||
for ( i = 0; i < max; i++ )
|
|
||||||
{
|
|
||||||
if ( !IsDefined( level.notifyEntities[i] ) )
|
|
||||||
{
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return max;
|
|
||||||
}
|
|
||||||
|
|
||||||
// #end region
|
|
||||||
|
|
||||||
// #region team balance
|
|
||||||
|
|
||||||
OnPlayerDisconnect()
|
|
||||||
{
|
{
|
||||||
level endon( level.eventTypes.gameEnd );
|
level endon( level.eventTypes.gameEnd );
|
||||||
self endon( "disconnect_logic_end" );
|
self endon( "disconnect_logic_end" );
|
||||||
@ -464,7 +106,7 @@ OnPlayerDisconnect()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
OnPlayerJoinedTeam()
|
OnClientJoinedTeam()
|
||||||
{
|
{
|
||||||
self endon( level.eventTypes.disconnect );
|
self endon( level.eventTypes.disconnect );
|
||||||
|
|
||||||
@ -472,14 +114,6 @@ OnPlayerJoinedTeam()
|
|||||||
{
|
{
|
||||||
self waittill( level.eventTypes.joinTeam );
|
self waittill( level.eventTypes.joinTeam );
|
||||||
|
|
||||||
wait( 0.25 );
|
|
||||||
LogPrint( GenerateJoinTeamString( false ) );
|
|
||||||
|
|
||||||
if ( GetDvarInt( level.commonKeys.autoBalance ) != 1 )
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( IsDefined( self.wasAutoBalanced ) && self.wasAutoBalanced )
|
if ( IsDefined( self.wasAutoBalanced ) && self.wasAutoBalanced )
|
||||||
{
|
{
|
||||||
self.wasAutoBalanced = false;
|
self.wasAutoBalanced = false;
|
||||||
@ -507,34 +141,12 @@ OnPlayerJoinedTeam()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
OnPlayerSpawned()
|
OnClientFirstSpawn()
|
||||||
{
|
|
||||||
self endon( level.eventTypes.disconnect );
|
|
||||||
|
|
||||||
for ( ;; )
|
|
||||||
{
|
|
||||||
self waittill( level.eventTypes.spawned );
|
|
||||||
self thread PlayerSpawnEvents();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
OnPlayerJoinedSpectators()
|
|
||||||
{
|
|
||||||
self endon( level.eventTypes.disconnect );
|
|
||||||
|
|
||||||
for( ;; )
|
|
||||||
{
|
|
||||||
self waittill( level.eventTypes.joinSpec );
|
|
||||||
LogPrint( GenerateJoinTeamString( true ) );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
OnPlayerFirstSpawn()
|
|
||||||
{
|
{
|
||||||
self endon( level.eventTypes.disconnect );
|
self endon( level.eventTypes.disconnect );
|
||||||
timeoutResult = self [[level.overrideMethods[level.commonFunctions.waitTillAnyTimeout]]]( 30, level.eventTypes.spawned );
|
timeoutResult = self [[level.overrideMethods[level.commonFunctions.waitTillAnyTimeout]]]( 30, level.eventTypes.spawned );
|
||||||
|
|
||||||
if ( timeoutResult != level.eventBus.timeoutKey )
|
if ( timeoutResult != "timeout" )
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -855,6 +467,48 @@ GetClientPerformanceOrDefault()
|
|||||||
return performance;
|
return performance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GetPlayerFromClientNum( clientNum )
|
||||||
|
{
|
||||||
|
if ( clientNum < 0 )
|
||||||
|
{
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
for ( i = 0; i < level.players.size; i++ )
|
||||||
|
{
|
||||||
|
if ( level.players[i] getEntityNumber() == clientNum )
|
||||||
|
{
|
||||||
|
return level.players[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
OnPlayerJoinedTeam()
|
||||||
|
{
|
||||||
|
self endon( "disconnect" );
|
||||||
|
|
||||||
|
for( ;; )
|
||||||
|
{
|
||||||
|
self waittill( "joined_team" );
|
||||||
|
// join spec and join team occur at the same moment - out of order logging would be problematic
|
||||||
|
wait( 0.25 );
|
||||||
|
LogPrint( GenerateJoinTeamString( false ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
OnPlayerJoinedSpectators()
|
||||||
|
{
|
||||||
|
self endon( "disconnect" );
|
||||||
|
|
||||||
|
for( ;; )
|
||||||
|
{
|
||||||
|
self waittill( "joined_spectators" );
|
||||||
|
LogPrint( GenerateJoinTeamString( true ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
GenerateJoinTeamString( isSpectator )
|
GenerateJoinTeamString( isSpectator )
|
||||||
{
|
{
|
||||||
team = self.team;
|
team = self.team;
|
||||||
@ -886,4 +540,49 @@ GenerateJoinTeamString( isSpectator )
|
|||||||
return "JT;" + guid + ";" + self getEntityNumber() + ";" + team + ";" + self.name + "\n";
|
return "JT;" + guid + ";" + self getEntityNumber() + ";" + team + ";" + self.name + "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
// #end region
|
PlayerTrackingOnInterval()
|
||||||
|
{
|
||||||
|
self endon( "disconnect" );
|
||||||
|
|
||||||
|
for ( ;; )
|
||||||
|
{
|
||||||
|
wait ( 120 );
|
||||||
|
if ( IsAlive( self ) )
|
||||||
|
{
|
||||||
|
self SaveTrackingMetrics();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SaveTrackingMetrics()
|
||||||
|
{
|
||||||
|
if ( !IsDefined( self.persistentClientId ) )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
scripts\_integration_base::LogDebug( "Saving tracking metrics for " + self.persistentClientId );
|
||||||
|
|
||||||
|
if ( !IsDefined( self.lastShotCount ) )
|
||||||
|
{
|
||||||
|
self.lastShotCount = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
currentShotCount = self [[level.overrideMethods["GetTotalShotsFired"]]]();
|
||||||
|
change = currentShotCount - self.lastShotCount;
|
||||||
|
self.lastShotCount = currentShotCount;
|
||||||
|
|
||||||
|
scripts\_integration_base::LogDebug( "Total Shots Fired increased by " + change );
|
||||||
|
|
||||||
|
if ( !IsDefined( change ) )
|
||||||
|
{
|
||||||
|
change = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( change == 0 )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
scripts\_integration_base::IncrementClientMeta( "TotalShotsFired", change, self.persistentClientId );
|
||||||
|
}
|
@ -8,22 +8,49 @@ Init()
|
|||||||
Setup()
|
Setup()
|
||||||
{
|
{
|
||||||
level endon( "game_ended" );
|
level endon( "game_ended" );
|
||||||
waittillframeend;
|
|
||||||
|
|
||||||
level waittill( level.notifyTypes.sharedFunctionsInitialized );
|
// it's possible that the notify type has not been defined yet so we have to hard code it
|
||||||
|
level waittill( "SharedFunctionsInitialized" );
|
||||||
level.eventBus.gamename = "T5";
|
level.eventBus.gamename = "T5";
|
||||||
|
|
||||||
scripts\_integration_base::RegisterLogger( ::Log2Console );
|
scripts\_integration_base::RegisterLogger( ::Log2Console );
|
||||||
|
|
||||||
level.overrideMethods[level.commonFunctions.getTotalShotsFired] = ::GetTotalShotsFired;
|
level.overrideMethods["GetTotalShotsFired"] = ::GetTotalShotsFired;
|
||||||
level.overrideMethods[level.commonFunctions.setDvar] = ::SetDvarIfUninitializedWrapper;
|
level.overrideMethods["SetDvarIfUninitialized"] = ::_SetDvarIfUninitialized;
|
||||||
level.overrideMethods[level.commonFunctions.waittillNotifyOrTimeout] = ::WaitillNotifyOrTimeoutWrapper;
|
level.overrideMethods["waittill_notify_or_timeout"] = ::_waittill_notify_or_timeout;
|
||||||
level.overrideMethods[level.commonFunctions.isBot] = ::IsBotWrapper;
|
level.overrideMethods[level.commonFunctions.getXuid] = ::_GetXUID;
|
||||||
level.overrideMethods[level.commonFunctions.getXuid] = ::GetXuidWrapper;
|
|
||||||
|
|
||||||
RegisterClientCommands();
|
RegisterClientCommands();
|
||||||
|
|
||||||
|
_SetDvarIfUninitialized( "sv_iw4madmin_autobalance", 0 );
|
||||||
|
|
||||||
level notify( level.notifyTypes.gameFunctionsInitialized );
|
level notify( level.notifyTypes.gameFunctionsInitialized );
|
||||||
|
|
||||||
|
if ( GetDvarInt( "sv_iw4madmin_integration_enabled" ) != 1 )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
level thread OnPlayerConnect();
|
||||||
|
}
|
||||||
|
|
||||||
|
OnPlayerConnect()
|
||||||
|
{
|
||||||
|
level endon ( "game_ended" );
|
||||||
|
|
||||||
|
for ( ;; )
|
||||||
|
{
|
||||||
|
level waittill( "connected", player );
|
||||||
|
|
||||||
|
if ( scripts\_integration_base::_IsBot( player ) )
|
||||||
|
{
|
||||||
|
// we don't want to track bots
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
//player thread SetPersistentData();
|
||||||
|
player thread WaitForClientEvents();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RegisterClientCommands()
|
RegisterClientCommands()
|
||||||
@ -41,17 +68,39 @@ RegisterClientCommands()
|
|||||||
scripts\_integration_base::AddClientCommand( "NoClip", false, ::NoClipImpl );
|
scripts\_integration_base::AddClientCommand( "NoClip", false, ::NoClipImpl );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WaitForClientEvents()
|
||||||
|
{
|
||||||
|
self endon( "disconnect" );
|
||||||
|
|
||||||
|
// example of requesting a meta value
|
||||||
|
lastServerMetaKey = "LastServerPlayed";
|
||||||
|
// self scripts\_integration_base::RequestClientMeta( lastServerMetaKey );
|
||||||
|
|
||||||
|
for ( ;; )
|
||||||
|
{
|
||||||
|
self waittill( level.eventTypes.localClientEvent, event );
|
||||||
|
|
||||||
|
scripts\_integration_base::LogDebug( "Received client event " + event.type );
|
||||||
|
|
||||||
|
if ( event.type == level.eventTypes.clientDataReceived && event.data[0] == lastServerMetaKey )
|
||||||
|
{
|
||||||
|
clientData = self.pers[level.clientDataKey];
|
||||||
|
lastServerPlayed = clientData.meta[lastServerMetaKey];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
GetTotalShotsFired()
|
GetTotalShotsFired()
|
||||||
{
|
{
|
||||||
return maps\mp\gametypes\_persistence::statGet( "total_shots" );
|
return maps\mp\gametypes\_persistence::statGet( "total_shots" );
|
||||||
}
|
}
|
||||||
|
|
||||||
SetDvarIfUninitializedWrapper( dvar, value )
|
_SetDvarIfUninitialized(dvar, value)
|
||||||
{
|
{
|
||||||
maps\mp\_utility::set_dvar_if_unset(dvar, value);
|
maps\mp\_utility::set_dvar_if_unset(dvar, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
WaitillNotifyOrTimeoutWrapper( msg, timer )
|
_waittill_notify_or_timeout( msg, timer )
|
||||||
{
|
{
|
||||||
self endon( msg );
|
self endon( msg );
|
||||||
wait( timer );
|
wait( timer );
|
||||||
@ -64,6 +113,7 @@ Log2Console( logLevel, message )
|
|||||||
|
|
||||||
God()
|
God()
|
||||||
{
|
{
|
||||||
|
|
||||||
if ( !IsDefined( self.godmode ) )
|
if ( !IsDefined( self.godmode ) )
|
||||||
{
|
{
|
||||||
self.godmode = false;
|
self.godmode = false;
|
||||||
@ -81,16 +131,142 @@ God()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IsBotWrapper( client )
|
_GetXUID()
|
||||||
{
|
{
|
||||||
return client maps\mp\_utility::is_bot();
|
return self GetXUID();
|
||||||
}
|
}
|
||||||
|
|
||||||
GetXuidWrapper()
|
//////////////////////////////////
|
||||||
|
// GUID helpers
|
||||||
|
/////////////////////////////////
|
||||||
|
|
||||||
|
/*SetPersistentData()
|
||||||
{
|
{
|
||||||
return self GetGuid();
|
self endon( "disconnect" );
|
||||||
|
|
||||||
|
guidHigh = self GetPlayerData( "bests", "none" );
|
||||||
|
guidLow = self GetPlayerData( "awards", "none" );
|
||||||
|
persistentGuid = guidHigh + "," + guidLow;
|
||||||
|
guidIsStored = guidHigh != 0 && guidLow != 0;
|
||||||
|
|
||||||
|
if ( guidIsStored )
|
||||||
|
{
|
||||||
|
// give IW4MAdmin time to collect IP
|
||||||
|
wait( 15 );
|
||||||
|
scripts\_integration_base::LogDebug( "Uploading persistent guid " + persistentGuid );
|
||||||
|
scripts\_integration_base::SetClientMeta( "PersistentClientGuid", persistentGuid );
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
guid = self SplitGuid();
|
||||||
|
|
||||||
|
scripts\_integration_base::LogDebug( "Persisting client guid " + guidHigh + "," + guidLow );
|
||||||
|
|
||||||
|
self SetPlayerData( "bests", "none", guid["high"] );
|
||||||
|
self SetPlayerData( "awards", "none", guid["low"] );
|
||||||
|
}
|
||||||
|
|
||||||
|
SplitGuid()
|
||||||
|
{
|
||||||
|
guid = self GetGuid();
|
||||||
|
|
||||||
|
if ( isDefined( self.guid ) )
|
||||||
|
{
|
||||||
|
guid = self.guid;
|
||||||
|
}
|
||||||
|
|
||||||
|
firstPart = 0;
|
||||||
|
secondPart = 0;
|
||||||
|
stringLength = 17;
|
||||||
|
firstPartExp = 0;
|
||||||
|
secondPartExp = 0;
|
||||||
|
|
||||||
|
for ( i = stringLength - 1; i > 0; i-- )
|
||||||
|
{
|
||||||
|
char = GetSubStr( guid, i - 1, i );
|
||||||
|
if ( char == "" )
|
||||||
|
{
|
||||||
|
char = "0";
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( i > stringLength / 2 )
|
||||||
|
{
|
||||||
|
value = GetIntForHexChar( char );
|
||||||
|
power = Pow( 16, secondPartExp );
|
||||||
|
secondPart = secondPart + ( value * power );
|
||||||
|
secondPartExp++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
value = GetIntForHexChar( char );
|
||||||
|
power = Pow( 16, firstPartExp );
|
||||||
|
firstPart = firstPart + ( value * power );
|
||||||
|
firstPartExp++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
split = [];
|
||||||
|
split["low"] = int( secondPart );
|
||||||
|
split["high"] = int( firstPart );
|
||||||
|
|
||||||
|
return split;
|
||||||
|
}
|
||||||
|
|
||||||
|
Pow( num, exponent )
|
||||||
|
{
|
||||||
|
result = 1;
|
||||||
|
while( exponent != 0 )
|
||||||
|
{
|
||||||
|
result = result * num;
|
||||||
|
exponent--;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
GetIntForHexChar( char )
|
||||||
|
{
|
||||||
|
char = ToLower( char );
|
||||||
|
// generated by co-pilot because I can't be bothered to make it more "elegant"
|
||||||
|
switch( char )
|
||||||
|
{
|
||||||
|
case "0":
|
||||||
|
return 0;
|
||||||
|
case "1":
|
||||||
|
return 1;
|
||||||
|
case "2":
|
||||||
|
return 2;
|
||||||
|
case "3":
|
||||||
|
return 3;
|
||||||
|
case "4":
|
||||||
|
return 4;
|
||||||
|
case "5":
|
||||||
|
return 5;
|
||||||
|
case "6":
|
||||||
|
return 6;
|
||||||
|
case "7":
|
||||||
|
return 7;
|
||||||
|
case "8":
|
||||||
|
return 8;
|
||||||
|
case "9":
|
||||||
|
return 9;
|
||||||
|
case "a":
|
||||||
|
return 10;
|
||||||
|
case "b":
|
||||||
|
return 11;
|
||||||
|
case "c":
|
||||||
|
return 12;
|
||||||
|
case "d":
|
||||||
|
return 13;
|
||||||
|
case "e":
|
||||||
|
return 14;
|
||||||
|
case "f":
|
||||||
|
return 15;
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
//////////////////////////////////
|
//////////////////////////////////
|
||||||
// Command Implementations
|
// Command Implementations
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
|
@ -7,25 +7,50 @@ Init()
|
|||||||
|
|
||||||
Setup()
|
Setup()
|
||||||
{
|
{
|
||||||
level endon( "end_game" );
|
level endon( "game_ended" );
|
||||||
waittillframeend;
|
|
||||||
|
|
||||||
level waittill( level.notifyTypes.sharedFunctionsInitialized );
|
// it's possible that the notify type has not been defined yet so we have to hard code it
|
||||||
|
level waittill( "SharedFunctionsInitialized" );
|
||||||
level.eventBus.gamename = "T5";
|
level.eventBus.gamename = "T5";
|
||||||
level.eventTypes.gameEnd = "end_game";
|
|
||||||
|
|
||||||
scripts\_integration_base::RegisterLogger( ::Log2Console );
|
scripts\_integration_base::RegisterLogger( ::Log2Console );
|
||||||
|
|
||||||
level.overrideMethods[level.commonFunctions.getTotalShotsFired] = ::GetTotalShotsFired;
|
level.overrideMethods["GetTotalShotsFired"] = ::GetTotalShotsFired;
|
||||||
level.overrideMethods[level.commonFunctions.setDvar] = ::SetDvarIfUninitializedWrapper;
|
level.overrideMethods["SetDvarIfUninitialized"] = ::_SetDvarIfUninitialized;
|
||||||
level.overrideMethods[level.commonFunctions.waittillNotifyOrTimeout] = ::WaitillNotifyOrTimeoutWrapper;
|
level.overrideMethods["waittill_notify_or_timeout"] = ::_waittill_notify_or_timeout;
|
||||||
level.overrideMethods[level.commonFunctions.isBot] = ::IsBotWrapper;
|
level.overrideMethods["GetPlayerFromClientNum"] = ::_GetPlayerFromClientNum;
|
||||||
level.overrideMethods[level.commonFunctions.getXuid] = ::GetXuidWrapper;
|
|
||||||
level.overrideMethods[level.commonFunction.getPlayerFromClientNum] = ::_GetPlayerFromClientNum;
|
|
||||||
|
|
||||||
RegisterClientCommands();
|
RegisterClientCommands();
|
||||||
|
|
||||||
|
_SetDvarIfUninitialized( "sv_iw4madmin_autobalance", 0 );
|
||||||
|
|
||||||
level notify( level.notifyTypes.gameFunctionsInitialized );
|
level notify( level.notifyTypes.gameFunctionsInitialized );
|
||||||
|
|
||||||
|
if ( GetDvarInt( "sv_iw4madmin_integration_enabled" ) != 1 )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
level thread OnPlayerConnect();
|
||||||
|
}
|
||||||
|
|
||||||
|
OnPlayerConnect()
|
||||||
|
{
|
||||||
|
level endon ( "game_ended" );
|
||||||
|
|
||||||
|
for ( ;; )
|
||||||
|
{
|
||||||
|
level waittill( "connected", player );
|
||||||
|
|
||||||
|
if ( scripts\_integration_base::_IsBot( player ) )
|
||||||
|
{
|
||||||
|
// we don't want to track bots
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
//player thread SetPersistentData();
|
||||||
|
player thread WaitForClientEvents();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RegisterClientCommands()
|
RegisterClientCommands()
|
||||||
@ -43,12 +68,34 @@ RegisterClientCommands()
|
|||||||
scripts\_integration_base::AddClientCommand( "NoClip", false, ::NoClipImpl );
|
scripts\_integration_base::AddClientCommand( "NoClip", false, ::NoClipImpl );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WaitForClientEvents()
|
||||||
|
{
|
||||||
|
self endon( "disconnect" );
|
||||||
|
|
||||||
|
// example of requesting a meta value
|
||||||
|
lastServerMetaKey = "LastServerPlayed";
|
||||||
|
// self scripts\_integration_base::RequestClientMeta( lastServerMetaKey );
|
||||||
|
|
||||||
|
for ( ;; )
|
||||||
|
{
|
||||||
|
self waittill( level.eventTypes.localClientEvent, event );
|
||||||
|
|
||||||
|
scripts\_integration_base::LogDebug( "Received client event " + event.type );
|
||||||
|
|
||||||
|
if ( event.type == level.eventTypes.clientDataReceived && event.data[0] == lastServerMetaKey )
|
||||||
|
{
|
||||||
|
clientData = self.pers[level.clientDataKey];
|
||||||
|
lastServerPlayed = clientData.meta[lastServerMetaKey];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
GetTotalShotsFired()
|
GetTotalShotsFired()
|
||||||
{
|
{
|
||||||
return 0; //ZM has no shot tracking. TODO: add tracking function for event weapon_fired
|
return 0; //ZM has no shot tracking. TODO: add tracking function for event weapon_fired
|
||||||
}
|
}
|
||||||
|
|
||||||
SetDvarIfUninitializedWrapper( dvar, value )
|
_SetDvarIfUninitialized(dvar, value)
|
||||||
{
|
{
|
||||||
if (GetDvar(dvar)=="" )
|
if (GetDvar(dvar)=="" )
|
||||||
{
|
{
|
||||||
@ -59,7 +106,7 @@ SetDvarIfUninitializedWrapper( dvar, value )
|
|||||||
return GetDvar(dvar);
|
return GetDvar(dvar);
|
||||||
}
|
}
|
||||||
|
|
||||||
WaitillNotifyOrTimeoutWrapper( msg, timer )
|
_waittill_notify_or_timeout( msg, timer )
|
||||||
{
|
{
|
||||||
self endon( msg );
|
self endon( msg );
|
||||||
wait( timer );
|
wait( timer );
|
||||||
@ -72,6 +119,7 @@ Log2Console( logLevel, message )
|
|||||||
|
|
||||||
God()
|
God()
|
||||||
{
|
{
|
||||||
|
|
||||||
if ( !IsDefined( self.godmode ) )
|
if ( !IsDefined( self.godmode ) )
|
||||||
{
|
{
|
||||||
self.godmode = false;
|
self.godmode = false;
|
||||||
@ -89,16 +137,6 @@ God()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IsBotWrapper( client )
|
|
||||||
{
|
|
||||||
return ( IsDefined ( client.pers["isBot"] ) && client.pers["isBot"] != 0 );
|
|
||||||
}
|
|
||||||
|
|
||||||
GetXuidWrapper()
|
|
||||||
{
|
|
||||||
return self GetXUID();
|
|
||||||
}
|
|
||||||
|
|
||||||
_GetPlayerFromClientNum( clientNum )
|
_GetPlayerFromClientNum( clientNum )
|
||||||
{
|
{
|
||||||
if ( clientNum < 0 )
|
if ( clientNum < 0 )
|
||||||
@ -111,7 +149,6 @@ _GetPlayerFromClientNum( clientNum )
|
|||||||
for ( i = 0; i < players.size; i++ )
|
for ( i = 0; i < players.size; i++ )
|
||||||
{
|
{
|
||||||
scripts\_integration_base::LogDebug(i+"/"+players.size+ "=" + players[i].name);
|
scripts\_integration_base::LogDebug(i+"/"+players.size+ "=" + players[i].name);
|
||||||
|
|
||||||
if ( players[i] getEntityNumber() == clientNum )
|
if ( players[i] getEntityNumber() == clientNum )
|
||||||
{
|
{
|
||||||
return players[i];
|
return players[i];
|
||||||
@ -121,6 +158,137 @@ _GetPlayerFromClientNum( clientNum )
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////
|
||||||
|
// GUID helpers
|
||||||
|
/////////////////////////////////
|
||||||
|
|
||||||
|
/*SetPersistentData()
|
||||||
|
{
|
||||||
|
self endon( "disconnect" );
|
||||||
|
|
||||||
|
guidHigh = self GetPlayerData( "bests", "none" );
|
||||||
|
guidLow = self GetPlayerData( "awards", "none" );
|
||||||
|
persistentGuid = guidHigh + "," + guidLow;
|
||||||
|
guidIsStored = guidHigh != 0 && guidLow != 0;
|
||||||
|
|
||||||
|
if ( guidIsStored )
|
||||||
|
{
|
||||||
|
// give IW4MAdmin time to collect IP
|
||||||
|
wait( 15 );
|
||||||
|
scripts\_integration_base::LogDebug( "Uploading persistent guid " + persistentGuid );
|
||||||
|
scripts\_integration_base::SetClientMeta( "PersistentClientGuid", persistentGuid );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
guid = self SplitGuid();
|
||||||
|
|
||||||
|
scripts\_integration_base::LogDebug( "Persisting client guid " + guidHigh + "," + guidLow );
|
||||||
|
|
||||||
|
self SetPlayerData( "bests", "none", guid["high"] );
|
||||||
|
self SetPlayerData( "awards", "none", guid["low"] );
|
||||||
|
}
|
||||||
|
|
||||||
|
SplitGuid()
|
||||||
|
{
|
||||||
|
guid = self GetGuid();
|
||||||
|
|
||||||
|
if ( isDefined( self.guid ) )
|
||||||
|
{
|
||||||
|
guid = self.guid;
|
||||||
|
}
|
||||||
|
|
||||||
|
firstPart = 0;
|
||||||
|
secondPart = 0;
|
||||||
|
stringLength = 17;
|
||||||
|
firstPartExp = 0;
|
||||||
|
secondPartExp = 0;
|
||||||
|
|
||||||
|
for ( i = stringLength - 1; i > 0; i-- )
|
||||||
|
{
|
||||||
|
char = GetSubStr( guid, i - 1, i );
|
||||||
|
if ( char == "" )
|
||||||
|
{
|
||||||
|
char = "0";
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( i > stringLength / 2 )
|
||||||
|
{
|
||||||
|
value = GetIntForHexChar( char );
|
||||||
|
power = Pow( 16, secondPartExp );
|
||||||
|
secondPart = secondPart + ( value * power );
|
||||||
|
secondPartExp++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
value = GetIntForHexChar( char );
|
||||||
|
power = Pow( 16, firstPartExp );
|
||||||
|
firstPart = firstPart + ( value * power );
|
||||||
|
firstPartExp++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
split = [];
|
||||||
|
split["low"] = int( secondPart );
|
||||||
|
split["high"] = int( firstPart );
|
||||||
|
|
||||||
|
return split;
|
||||||
|
}
|
||||||
|
|
||||||
|
Pow( num, exponent )
|
||||||
|
{
|
||||||
|
result = 1;
|
||||||
|
while( exponent != 0 )
|
||||||
|
{
|
||||||
|
result = result * num;
|
||||||
|
exponent--;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
GetIntForHexChar( char )
|
||||||
|
{
|
||||||
|
char = ToLower( char );
|
||||||
|
// generated by co-pilot because I can't be bothered to make it more "elegant"
|
||||||
|
switch( char )
|
||||||
|
{
|
||||||
|
case "0":
|
||||||
|
return 0;
|
||||||
|
case "1":
|
||||||
|
return 1;
|
||||||
|
case "2":
|
||||||
|
return 2;
|
||||||
|
case "3":
|
||||||
|
return 3;
|
||||||
|
case "4":
|
||||||
|
return 4;
|
||||||
|
case "5":
|
||||||
|
return 5;
|
||||||
|
case "6":
|
||||||
|
return 6;
|
||||||
|
case "7":
|
||||||
|
return 7;
|
||||||
|
case "8":
|
||||||
|
return 8;
|
||||||
|
case "9":
|
||||||
|
return 9;
|
||||||
|
case "a":
|
||||||
|
return 10;
|
||||||
|
case "b":
|
||||||
|
return 11;
|
||||||
|
case "c":
|
||||||
|
return 12;
|
||||||
|
case "d":
|
||||||
|
return 13;
|
||||||
|
case "e":
|
||||||
|
return 14;
|
||||||
|
case "f":
|
||||||
|
return 15;
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
//////////////////////////////////
|
//////////////////////////////////
|
||||||
// Command Implementations
|
// Command Implementations
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
|
@ -9,29 +9,49 @@ Init()
|
|||||||
Setup()
|
Setup()
|
||||||
{
|
{
|
||||||
level endon( "game_ended" );
|
level endon( "game_ended" );
|
||||||
level endon( "end_game" );
|
|
||||||
waittillframeend;
|
|
||||||
|
|
||||||
level waittill( level.notifyTypes.sharedFunctionsInitialized );
|
// it's possible that the notify type has not been defined yet so we have to hard code it
|
||||||
|
level waittill( "SharedFunctionsInitialized" );
|
||||||
level.eventBus.gamename = "T6";
|
level.eventBus.gamename = "T6";
|
||||||
|
|
||||||
if ( sessionmodeiszombiesgame() )
|
|
||||||
{
|
|
||||||
level.eventTypes.gameEnd = "end_game";
|
|
||||||
}
|
|
||||||
|
|
||||||
scripts\_integration_base::RegisterLogger( ::Log2Console );
|
scripts\_integration_base::RegisterLogger( ::Log2Console );
|
||||||
|
|
||||||
level.overrideMethods[level.commonFunctions.getTotalShotsFired] = ::GetTotalShotsFired;
|
level.overrideMethods["GetTotalShotsFired"] = ::GetTotalShotsFired;
|
||||||
level.overrideMethods[level.commonFunctions.setDvar] = ::SetDvarIfUninitializedWrapper;
|
level.overrideMethods["SetDvarIfUninitialized"] = ::_SetDvarIfUninitialized;
|
||||||
level.overrideMethods[level.commonFunctions.waittillNotifyOrTimeout] = ::WaitillNotifyOrTimeoutWrapper;
|
level.overrideMethods["waittill_notify_or_timeout"] = ::_waittill_notify_or_timeout;
|
||||||
level.overrideMethods[level.commonFunctions.isBot] = ::IsBotWrapper;
|
level.overrideMethods[level.commonFunctions.getXuid] = ::_GetXUID;
|
||||||
level.overrideMethods[level.commonFunctions.getXuid] = ::GetXuidWrapper;
|
|
||||||
level.overrideMethods[level.commonFunctions.waitTillAnyTimeout] = ::WaitTillAnyTimeout;
|
|
||||||
|
|
||||||
RegisterClientCommands();
|
RegisterClientCommands();
|
||||||
|
|
||||||
|
_SetDvarIfUninitialized( "sv_iw4madmin_autobalance", 0 );
|
||||||
|
|
||||||
level notify( level.notifyTypes.gameFunctionsInitialized );
|
level notify( level.notifyTypes.gameFunctionsInitialized );
|
||||||
|
|
||||||
|
if ( GetDvarInt( "sv_iw4madmin_integration_enabled" ) != 1 )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
level thread OnPlayerConnect();
|
||||||
|
}
|
||||||
|
|
||||||
|
OnPlayerConnect()
|
||||||
|
{
|
||||||
|
level endon ( "game_ended" );
|
||||||
|
|
||||||
|
for ( ;; )
|
||||||
|
{
|
||||||
|
level waittill( "connected", player );
|
||||||
|
|
||||||
|
if ( scripts\_integration_base::_IsBot( player ) )
|
||||||
|
{
|
||||||
|
// we don't want to track bots
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
//player thread SetPersistentData();
|
||||||
|
player thread WaitForClientEvents();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RegisterClientCommands()
|
RegisterClientCommands()
|
||||||
@ -49,17 +69,39 @@ RegisterClientCommands()
|
|||||||
scripts\_integration_base::AddClientCommand( "NoClip", false, ::NoClipImpl );
|
scripts\_integration_base::AddClientCommand( "NoClip", false, ::NoClipImpl );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WaitForClientEvents()
|
||||||
|
{
|
||||||
|
self endon( "disconnect" );
|
||||||
|
|
||||||
|
// example of requesting a meta value
|
||||||
|
lastServerMetaKey = "LastServerPlayed";
|
||||||
|
// self scripts\_integration_base::RequestClientMeta( lastServerMetaKey );
|
||||||
|
|
||||||
|
for ( ;; )
|
||||||
|
{
|
||||||
|
self waittill( level.eventTypes.localClientEvent, event );
|
||||||
|
|
||||||
|
scripts\_integration_base::LogDebug( "Received client event " + event.type );
|
||||||
|
|
||||||
|
if ( event.type == level.eventTypes.clientDataReceived && event.data[0] == lastServerMetaKey )
|
||||||
|
{
|
||||||
|
clientData = self.pers[level.clientDataKey];
|
||||||
|
lastServerPlayed = clientData.meta[lastServerMetaKey];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
GetTotalShotsFired()
|
GetTotalShotsFired()
|
||||||
{
|
{
|
||||||
return self.pers[ "total_shots" ];
|
return self.pers[ "total_shots" ];
|
||||||
}
|
}
|
||||||
|
|
||||||
SetDvarIfUninitializedWrapper( dvar, value )
|
_SetDvarIfUninitialized(dvar, value)
|
||||||
{
|
{
|
||||||
maps\mp\_utility::set_dvar_if_unset(dvar, value);
|
maps\mp\_utility::set_dvar_if_unset(dvar, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
WaitillNotifyOrTimeoutWrapper( msg, timer )
|
_waittill_notify_or_timeout( msg, timer )
|
||||||
{
|
{
|
||||||
self endon( msg );
|
self endon( msg );
|
||||||
wait( timer );
|
wait( timer );
|
||||||
@ -72,6 +114,7 @@ Log2Console( logLevel, message )
|
|||||||
|
|
||||||
God()
|
God()
|
||||||
{
|
{
|
||||||
|
|
||||||
if ( !IsDefined( self.godmode ) )
|
if ( !IsDefined( self.godmode ) )
|
||||||
{
|
{
|
||||||
self.godmode = false;
|
self.godmode = false;
|
||||||
@ -89,21 +132,142 @@ God()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IsBotWrapper( client )
|
_GetXUID()
|
||||||
{
|
|
||||||
return client maps\mp\_utility::is_bot();
|
|
||||||
}
|
|
||||||
|
|
||||||
GetXuidWrapper()
|
|
||||||
{
|
{
|
||||||
return self GetXUID();
|
return self GetXUID();
|
||||||
}
|
}
|
||||||
|
|
||||||
WaitTillAnyTimeout( timeOut, string1, string2, string3, string4, string5 )
|
//////////////////////////////////
|
||||||
|
// GUID helpers
|
||||||
|
/////////////////////////////////
|
||||||
|
|
||||||
|
/*SetPersistentData()
|
||||||
{
|
{
|
||||||
return common_scripts\utility::waittill_any_timeout( timeOut, string1, string2, string3, string4, string5 );
|
self endon( "disconnect" );
|
||||||
|
|
||||||
|
guidHigh = self GetPlayerData( "bests", "none" );
|
||||||
|
guidLow = self GetPlayerData( "awards", "none" );
|
||||||
|
persistentGuid = guidHigh + "," + guidLow;
|
||||||
|
guidIsStored = guidHigh != 0 && guidLow != 0;
|
||||||
|
|
||||||
|
if ( guidIsStored )
|
||||||
|
{
|
||||||
|
// give IW4MAdmin time to collect IP
|
||||||
|
wait( 15 );
|
||||||
|
scripts\_integration_base::LogDebug( "Uploading persistent guid " + persistentGuid );
|
||||||
|
scripts\_integration_base::SetClientMeta( "PersistentClientGuid", persistentGuid );
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
guid = self SplitGuid();
|
||||||
|
|
||||||
|
scripts\_integration_base::LogDebug( "Persisting client guid " + guidHigh + "," + guidLow );
|
||||||
|
|
||||||
|
self SetPlayerData( "bests", "none", guid["high"] );
|
||||||
|
self SetPlayerData( "awards", "none", guid["low"] );
|
||||||
|
}
|
||||||
|
|
||||||
|
SplitGuid()
|
||||||
|
{
|
||||||
|
guid = self GetGuid();
|
||||||
|
|
||||||
|
if ( isDefined( self.guid ) )
|
||||||
|
{
|
||||||
|
guid = self.guid;
|
||||||
|
}
|
||||||
|
|
||||||
|
firstPart = 0;
|
||||||
|
secondPart = 0;
|
||||||
|
stringLength = 17;
|
||||||
|
firstPartExp = 0;
|
||||||
|
secondPartExp = 0;
|
||||||
|
|
||||||
|
for ( i = stringLength - 1; i > 0; i-- )
|
||||||
|
{
|
||||||
|
char = GetSubStr( guid, i - 1, i );
|
||||||
|
if ( char == "" )
|
||||||
|
{
|
||||||
|
char = "0";
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( i > stringLength / 2 )
|
||||||
|
{
|
||||||
|
value = GetIntForHexChar( char );
|
||||||
|
power = Pow( 16, secondPartExp );
|
||||||
|
secondPart = secondPart + ( value * power );
|
||||||
|
secondPartExp++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
value = GetIntForHexChar( char );
|
||||||
|
power = Pow( 16, firstPartExp );
|
||||||
|
firstPart = firstPart + ( value * power );
|
||||||
|
firstPartExp++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
split = [];
|
||||||
|
split["low"] = int( secondPart );
|
||||||
|
split["high"] = int( firstPart );
|
||||||
|
|
||||||
|
return split;
|
||||||
|
}
|
||||||
|
|
||||||
|
Pow( num, exponent )
|
||||||
|
{
|
||||||
|
result = 1;
|
||||||
|
while( exponent != 0 )
|
||||||
|
{
|
||||||
|
result = result * num;
|
||||||
|
exponent--;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
GetIntForHexChar( char )
|
||||||
|
{
|
||||||
|
char = ToLower( char );
|
||||||
|
// generated by co-pilot because I can't be bothered to make it more "elegant"
|
||||||
|
switch( char )
|
||||||
|
{
|
||||||
|
case "0":
|
||||||
|
return 0;
|
||||||
|
case "1":
|
||||||
|
return 1;
|
||||||
|
case "2":
|
||||||
|
return 2;
|
||||||
|
case "3":
|
||||||
|
return 3;
|
||||||
|
case "4":
|
||||||
|
return 4;
|
||||||
|
case "5":
|
||||||
|
return 5;
|
||||||
|
case "6":
|
||||||
|
return 6;
|
||||||
|
case "7":
|
||||||
|
return 7;
|
||||||
|
case "8":
|
||||||
|
return 8;
|
||||||
|
case "9":
|
||||||
|
return 9;
|
||||||
|
case "a":
|
||||||
|
return 10;
|
||||||
|
case "b":
|
||||||
|
return 11;
|
||||||
|
case "c":
|
||||||
|
return 12;
|
||||||
|
case "d":
|
||||||
|
return 13;
|
||||||
|
case "e":
|
||||||
|
return 14;
|
||||||
|
case "f":
|
||||||
|
return 15;
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
//////////////////////////////////
|
//////////////////////////////////
|
||||||
// Command Implementations
|
// Command Implementations
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
@ -292,7 +456,17 @@ HideImpl( event, data )
|
|||||||
|
|
||||||
AlertImpl( event, data )
|
AlertImpl( event, data )
|
||||||
{
|
{
|
||||||
|
/*if ( !sessionmodeiszombiesgame() )
|
||||||
|
{*/
|
||||||
self thread oldNotifyMessage( data["alertType"], data["message"], undefined, ( 1, 0, 0 ), "mpl_sab_ui_suitcasebomb_timer", 7.5 );
|
self thread oldNotifyMessage( data["alertType"], data["message"], undefined, ( 1, 0, 0 ), "mpl_sab_ui_suitcasebomb_timer", 7.5 );
|
||||||
|
/*}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
self IPrintLnBold( data["alertType"] );
|
||||||
|
self IPrintLnBold( data["message"] );
|
||||||
|
}*/
|
||||||
|
|
||||||
|
|
||||||
return "Sent alert to " + self.name;
|
return "Sent alert to " + self.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -308,7 +482,7 @@ GotoImpl( event, data )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GotoCoordImpl( data )
|
GotoCoordImpl( event, data )
|
||||||
{
|
{
|
||||||
if ( !IsAlive( self ) )
|
if ( !IsAlive( self ) )
|
||||||
{
|
{
|
||||||
@ -376,7 +550,7 @@ SetSpectatorImpl( event, data )
|
|||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
|
|
||||||
/*
|
/*
|
||||||
1:1 the same on MP and ZM but in different includes. Since we probably want to be able to send Alerts on non teambased wagermatches use our own copy.
|
1:1 the same on MP and ZM but in different includes. Since we probably want to be able to send Alerts on non teambased wagermatechs use our own copy.
|
||||||
*/
|
*/
|
||||||
oldnotifymessage( titletext, notifytext, iconname, glowcolor, sound, duration )
|
oldnotifymessage( titletext, notifytext, iconname, glowcolor, sound, duration )
|
||||||
{
|
{
|
||||||
@ -393,3 +567,5 @@ oldnotifymessage( titletext, notifytext, iconname, glowcolor, sound, duration )
|
|||||||
self.startmessagenotifyqueue[ self.startmessagenotifyqueue.size ] = notifydata;
|
self.startmessagenotifyqueue[ self.startmessagenotifyqueue.size ] = notifydata;
|
||||||
self notify( "received award" );
|
self notify( "received award" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,73 +0,0 @@
|
|||||||
/*********************************************************************************
|
|
||||||
* DISCLAIMER: *
|
|
||||||
* *
|
|
||||||
* This script is optional and not required for *
|
|
||||||
* standard functionality. To use this script, a third-party *
|
|
||||||
* plugin named "t6-gsc-utils" must be installed on the *
|
|
||||||
* game server in the "*\storage\t6\plugins" folder *
|
|
||||||
* *
|
|
||||||
* The "t6-gsc-utils" plugin can be obtained from the GitHub *
|
|
||||||
* repository at: *
|
|
||||||
* https://github.com/fedddddd/t6-gsc-utils *
|
|
||||||
* *
|
|
||||||
* Please make sure to install the plugin before running this *
|
|
||||||
* script. *
|
|
||||||
*********************************************************************************/
|
|
||||||
|
|
||||||
/*********************************************************************************
|
|
||||||
* FUNCTIONALITY: *
|
|
||||||
* *
|
|
||||||
* This script extends the game interface to support the "file" *
|
|
||||||
* bus mode for Plutonium T6, which allows the game server and IW4M-Admin *
|
|
||||||
* to communicate via files, rather than over rcon using *
|
|
||||||
* dvars. *
|
|
||||||
* *
|
|
||||||
* By enabling the "file" bus mode, IW4M-Admin can send *
|
|
||||||
* commands and receive responses from the game server by *
|
|
||||||
* reading and writing to specific files. This provides a *
|
|
||||||
* flexible and efficient communication channel. *
|
|
||||||
* *
|
|
||||||
* Make sure to configure the server to use the "file" bus *
|
|
||||||
* mode and set the appropriate file path to *
|
|
||||||
* establish the communication between IW4M-Admin and the *
|
|
||||||
* game server. *
|
|
||||||
* *
|
|
||||||
* The wiki page for the setup of the game interface, and the bus mode *
|
|
||||||
* can be found on GitHub at: *
|
|
||||||
* https://github.com/RaidMax/IW4M-Admin/wiki/GameInterface#configuring-bus-mode *
|
|
||||||
*********************************************************************************/
|
|
||||||
|
|
||||||
Init()
|
|
||||||
{
|
|
||||||
thread Setup();
|
|
||||||
}
|
|
||||||
|
|
||||||
Setup()
|
|
||||||
{
|
|
||||||
level waittill( level.notifyTypes.sharedFunctionsInitialized );
|
|
||||||
level.overrideMethods[level.commonFunctions.getInboundData] = ::GetInboundData;
|
|
||||||
level.overrideMethods[level.commonFunctions.getOutboundData] = ::GetOutboundData;
|
|
||||||
level.overrideMethods[level.commonFunctions.setInboundData] = ::SetInboundData;
|
|
||||||
level.overrideMethods[level.commonFunctions.setOutboundData] = ::SetOutboundData;
|
|
||||||
scripts\_integration_base::_SetDvarIfUninitialized( level.commonKeys.busdir, GetDvar( "fs_homepath" ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
GetInboundData( location )
|
|
||||||
{
|
|
||||||
return readFile( location );
|
|
||||||
}
|
|
||||||
|
|
||||||
GetOutboundData( location )
|
|
||||||
{
|
|
||||||
return readFile( location );
|
|
||||||
}
|
|
||||||
|
|
||||||
SetInboundData( location, data )
|
|
||||||
{
|
|
||||||
writeFile( location, data );
|
|
||||||
}
|
|
||||||
|
|
||||||
SetOutboundData( location, data )
|
|
||||||
{
|
|
||||||
writeFile( location, data );
|
|
||||||
}
|
|
@ -1,48 +1,45 @@
|
|||||||
Init()
|
init()
|
||||||
{
|
{
|
||||||
|
|
||||||
level.startmessagedefaultduration = 2;
|
level.startmessagedefaultduration = 2;
|
||||||
level.regulargamemessages = spawnstruct();
|
level.regulargamemessages = spawnstruct();
|
||||||
level.regulargamemessages.waittime = 6;
|
level.regulargamemessages.waittime = 6;
|
||||||
|
|
||||||
thread OnPlayerConnect();
|
|
||||||
|
level thread onplayerconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
OnPlayerConnect()
|
onplayerconnect()
|
||||||
{
|
{
|
||||||
for ( ;; )
|
for ( ;; )
|
||||||
{
|
{
|
||||||
level waittill( "connecting", player );
|
level waittill( "connecting", player );
|
||||||
player thread DisplayPopupsWaiter();
|
player thread displaypopupswaiter();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DisplayPopupsWaiter()
|
displaypopupswaiter()
|
||||||
{
|
{
|
||||||
self endon( "disconnect" );
|
self endon( "disconnect" );
|
||||||
self.ranknotifyqueue = [];
|
self.ranknotifyqueue = [];
|
||||||
|
if ( !isDefined( self.pers[ "challengeNotifyQueue" ] ) )
|
||||||
if ( !IsDefined( self.pers[ "challengeNotifyQueue" ] ) )
|
|
||||||
{
|
{
|
||||||
self.pers[ "challengeNotifyQueue" ] = [];
|
self.pers[ "challengeNotifyQueue" ] = [];
|
||||||
}
|
}
|
||||||
if ( !IsDefined( self.pers[ "contractNotifyQueue" ] ) )
|
if ( !isDefined( self.pers[ "contractNotifyQueue" ] ) )
|
||||||
{
|
{
|
||||||
self.pers[ "contractNotifyQueue" ] = [];
|
self.pers[ "contractNotifyQueue" ] = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
self.messagenotifyqueue = [];
|
self.messagenotifyqueue = [];
|
||||||
self.startmessagenotifyqueue = [];
|
self.startmessagenotifyqueue = [];
|
||||||
self.wagernotifyqueue = [];
|
self.wagernotifyqueue = [];
|
||||||
|
|
||||||
while ( !level.gameended )
|
while ( !level.gameended )
|
||||||
{
|
{
|
||||||
if ( self.startmessagenotifyqueue.size == 0 && self.messagenotifyqueue.size == 0 )
|
if ( self.startmessagenotifyqueue.size == 0 && self.messagenotifyqueue.size == 0 )
|
||||||
{
|
{
|
||||||
self waittill( "received award" );
|
self waittill( "received award" );
|
||||||
}
|
}
|
||||||
|
|
||||||
waittillframeend;
|
waittillframeend;
|
||||||
|
|
||||||
if ( level.gameended )
|
if ( level.gameended )
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@ -53,7 +50,7 @@ DisplayPopupsWaiter()
|
|||||||
{
|
{
|
||||||
nextnotifydata = self.startmessagenotifyqueue[ 0 ];
|
nextnotifydata = self.startmessagenotifyqueue[ 0 ];
|
||||||
arrayremoveindex( self.startmessagenotifyqueue, 0, 0 );
|
arrayremoveindex( self.startmessagenotifyqueue, 0, 0 );
|
||||||
if ( IsDefined( nextnotifydata.duration ) )
|
if ( isDefined( nextnotifydata.duration ) )
|
||||||
{
|
{
|
||||||
duration = nextnotifydata.duration;
|
duration = nextnotifydata.duration;
|
||||||
}
|
}
|
||||||
@ -61,18 +58,15 @@ DisplayPopupsWaiter()
|
|||||||
{
|
{
|
||||||
duration = level.startmessagedefaultduration;
|
duration = level.startmessagedefaultduration;
|
||||||
}
|
}
|
||||||
|
|
||||||
self maps\mp\gametypes_zm\_hud_message::shownotifymessage( nextnotifydata, duration );
|
self maps\mp\gametypes_zm\_hud_message::shownotifymessage( nextnotifydata, duration );
|
||||||
wait ( duration );
|
wait duration;
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if ( self.messagenotifyqueue.size > 0 )
|
else if ( self.messagenotifyqueue.size > 0 )
|
||||||
{
|
{
|
||||||
nextnotifydata = self.messagenotifyqueue[ 0 ];
|
nextnotifydata = self.messagenotifyqueue[ 0 ];
|
||||||
arrayremoveindex( self.messagenotifyqueue, 0, 0 );
|
arrayremoveindex( self.messagenotifyqueue, 0, 0 );
|
||||||
|
if ( isDefined( nextnotifydata.duration ) )
|
||||||
if ( IsDefined( nextnotifydata.duration ) )
|
|
||||||
{
|
{
|
||||||
duration = nextnotifydata.duration;
|
duration = nextnotifydata.duration;
|
||||||
}
|
}
|
||||||
@ -80,13 +74,12 @@ DisplayPopupsWaiter()
|
|||||||
{
|
{
|
||||||
duration = level.regulargamemessages.waittime;
|
duration = level.regulargamemessages.waittime;
|
||||||
}
|
}
|
||||||
|
|
||||||
self maps\mp\gametypes_zm\_hud_message::shownotifymessage( nextnotifydata, duration );
|
self maps\mp\gametypes_zm\_hud_message::shownotifymessage( nextnotifydata, duration );
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
wait ( 1 );
|
wait 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,40 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file contains reusable preprocessor directives meant to be used on
|
|
||||||
* Plutonium & AlterWare clients that are up to date with the latest version.
|
|
||||||
* Older versions of Plutonium or other clients do not have support for loading
|
|
||||||
* or parsing "gsh" files.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Turn off assertions by removing the following define
|
|
||||||
* gsc-tool will only emit assertions if developer_script dvar is set to 1
|
|
||||||
* In short, you should not need to remove this define. Just turn them off
|
|
||||||
* by using the dvar
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define _INTEGRATION_DEBUG
|
|
||||||
|
|
||||||
#ifdef _INTEGRATION_DEBUG
|
|
||||||
|
|
||||||
#define _VERIFY( cond, msg ) \
|
|
||||||
assertEx( cond, msg )
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
// This works as an "empty" define here with gsc-tool
|
|
||||||
#define _VERIFY( cond, msg )
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// This function is meant to be used inside "client commands"
|
|
||||||
// If the client is not alive it shall return an error message
|
|
||||||
#define _IS_ALIVE( ent ) \
|
|
||||||
_VERIFY( ent, "player entity is not defined" ); \
|
|
||||||
if ( !IsAlive( ent ) ) \
|
|
||||||
{ \
|
|
||||||
return ent.name + "^7 is not alive"; \
|
|
||||||
}
|
|
||||||
|
|
||||||
// This function should be used to verify if a player entity is defined
|
|
||||||
#define _VERIFY_PLAYER_ENT( ent ) \
|
|
||||||
_VERIFY( ent, "player entity is not defined" )
|
|
@ -1,88 +0,0 @@
|
|||||||
Init()
|
|
||||||
{
|
|
||||||
// this gives the game interface time to setup
|
|
||||||
waittillframeend;
|
|
||||||
thread ModuleSetup();
|
|
||||||
}
|
|
||||||
|
|
||||||
ModuleSetup()
|
|
||||||
{
|
|
||||||
// waiting until the game specific functions are ready
|
|
||||||
level waittill( level.notifyTypes.gameFunctionsInitialized );
|
|
||||||
|
|
||||||
RegisterCustomCommands();
|
|
||||||
}
|
|
||||||
|
|
||||||
RegisterCustomCommands()
|
|
||||||
{
|
|
||||||
command = SpawnStruct();
|
|
||||||
|
|
||||||
// unique key for each command (how iw4madmin identifies the command)
|
|
||||||
command.eventKey = "PrintLineCommand";
|
|
||||||
|
|
||||||
// name of the command (cannot conflict with existing command names)
|
|
||||||
command.name = "println";
|
|
||||||
|
|
||||||
// short version of the command (cannot conflcit with existing command aliases)
|
|
||||||
command.alias = "pl";
|
|
||||||
|
|
||||||
// description of what the command does
|
|
||||||
command.description = "prints line to game";
|
|
||||||
|
|
||||||
// minimum permision required to execute
|
|
||||||
// valid values: User, Trusted, Moderator, Administrator, SeniorAdmin, Owner
|
|
||||||
command.minPermission = "Trusted";
|
|
||||||
|
|
||||||
// games the command is supported on
|
|
||||||
// separate with comma or don't define for all
|
|
||||||
// valid values: IW3, IW4, IW5, IW6, T4, T5, T6, T7, SHG1, CSGO, H1
|
|
||||||
command.supportedGames = "IW4,IW5,T5,T6";
|
|
||||||
|
|
||||||
// indicates if a target player must be provided to execvute on
|
|
||||||
command.requiresTarget = false;
|
|
||||||
|
|
||||||
// code to run when the command is executed
|
|
||||||
command.handler = ::PrintLnCommandCallback;
|
|
||||||
|
|
||||||
// register the command with integration to be send to iw4madmin
|
|
||||||
scripts\_integration_shared::RegisterScriptCommandObject( command );
|
|
||||||
|
|
||||||
// you can also register via parameters
|
|
||||||
scripts\_integration_shared::RegisterScriptCommand( "AffirmationCommand", "affirm", "af", "provide affirmations", "User", undefined, false, ::AffirmationCommandCallback );
|
|
||||||
}
|
|
||||||
|
|
||||||
PrintLnCommandCallback( event )
|
|
||||||
{
|
|
||||||
if ( IsDefined( event.data["args"] ) )
|
|
||||||
{
|
|
||||||
IPrintLnBold( event.data["args"] );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
scripts\_integration_base::LogDebug( "No data was provided for PrintLnCallback" );
|
|
||||||
}
|
|
||||||
|
|
||||||
AffirmationCommandCallback( event, _ )
|
|
||||||
{
|
|
||||||
level endon( level.eventTypes.gameEnd );
|
|
||||||
|
|
||||||
request = SpawnStruct();
|
|
||||||
request.url = "https://www.affirmations.dev";
|
|
||||||
request.method = "GET";
|
|
||||||
|
|
||||||
// If making a post request you can also provide more data
|
|
||||||
// request.body = "Body of the post message";
|
|
||||||
// request.headers = [];
|
|
||||||
// request.headers["Authorization"] = "api-key";
|
|
||||||
|
|
||||||
scripts\_integration_shared::RequestUrlObject( request );
|
|
||||||
request waittill( level.eventTypes.urlRequestCompleted, response );
|
|
||||||
|
|
||||||
// horrible json parsing.. but it's just an example
|
|
||||||
parsedResponse = strtok( response, "\"" );
|
|
||||||
|
|
||||||
if ( IsPlayer( self ) )
|
|
||||||
{
|
|
||||||
self IPrintLnBold ( "^5" + parsedResponse[parsedResponse.size - 2] );
|
|
||||||
}
|
|
||||||
}
|
|
@ -3,7 +3,14 @@
|
|||||||
Allows integration of IW4M-Admin to GSC, mainly used for special commands that need to use GSC in order to work.
|
Allows integration of IW4M-Admin to GSC, mainly used for special commands that need to use GSC in order to work.
|
||||||
But can also be used to read / write metadata from / to a profile and to get the player permission level.
|
But can also be used to read / write metadata from / to a profile and to get the player permission level.
|
||||||
|
|
||||||
## Installation Guide
|
|
||||||
|
## Installation Plutonium IW5
|
||||||
|
|
||||||
|
|
||||||
The documentation can be found here: [GameInterface](https://github.com/RaidMax/IW4M-Admin/wiki/GameInterface)
|
Move `_integration.gsc` to `%localappdata%\Plutonium\storage\iw5\scripts\`
|
||||||
|
|
||||||
|
|
||||||
|
## Installation IW4x
|
||||||
|
|
||||||
|
|
||||||
|
Move `_integration.gsc` to `IW4x/userraw/scripts`, `IW4x` being the root folder of your game server.
|
@ -4,7 +4,6 @@ ECHO "Pluto IW5"
|
|||||||
xcopy /y .\GameInterface\_integration_base.gsc "%LOCALAPPDATA%\Plutonium\storage\iw5\scripts"
|
xcopy /y .\GameInterface\_integration_base.gsc "%LOCALAPPDATA%\Plutonium\storage\iw5\scripts"
|
||||||
xcopy /y .\GameInterface\_integration_shared.gsc "%LOCALAPPDATA%\Plutonium\storage\iw5\scripts"
|
xcopy /y .\GameInterface\_integration_shared.gsc "%LOCALAPPDATA%\Plutonium\storage\iw5\scripts"
|
||||||
xcopy /y .\GameInterface\_integration_iw5.gsc "%LOCALAPPDATA%\Plutonium\storage\iw5\scripts"
|
xcopy /y .\GameInterface\_integration_iw5.gsc "%LOCALAPPDATA%\Plutonium\storage\iw5\scripts"
|
||||||
xcopy /y .\GameInterface\_integration_utility.gsh "%LOCALAPPDATA%\Plutonium\storage\iw5\scripts"
|
|
||||||
xcopy /y .\AntiCheat\IW5\storage\iw5\scripts\_customcallbacks.gsc "%LOCALAPPDATA%\Plutonium\storage\iw5\scripts\mp"
|
xcopy /y .\AntiCheat\IW5\storage\iw5\scripts\_customcallbacks.gsc "%LOCALAPPDATA%\Plutonium\storage\iw5\scripts\mp"
|
||||||
|
|
||||||
ECHO "Pluto T5"
|
ECHO "Pluto T5"
|
||||||
@ -14,8 +13,8 @@ xcopy /y .\GameInterface\_integration_t5.gsc "%LOCALAPPDATA%\Plutonium\storage\t
|
|||||||
xcopy /y .\GameInterface\_integration_t5zm.gsc "%LOCALAPPDATA%\Plutonium\storage\t5\scripts\sp\zom"
|
xcopy /y .\GameInterface\_integration_t5zm.gsc "%LOCALAPPDATA%\Plutonium\storage\t5\scripts\sp\zom"
|
||||||
|
|
||||||
ECHO "Pluto T6"
|
ECHO "Pluto T6"
|
||||||
|
xcopy /y .\AntiCheat\PT6\storage\t6\scripts\mp\_customcallbacks.gsc "%LOCALAPPDATA%\Plutonium\storage\t6\scripts\mp"
|
||||||
xcopy /y .\GameInterface\_integration_base.gsc "%LOCALAPPDATA%\Plutonium\storage\t6\scripts"
|
xcopy /y .\GameInterface\_integration_base.gsc "%LOCALAPPDATA%\Plutonium\storage\t6\scripts"
|
||||||
xcopy /y .\GameInterface\_integration_shared.gsc "%LOCALAPPDATA%\Plutonium\storage\t6\scripts"
|
xcopy /y .\GameInterface\_integration_shared.gsc "%LOCALAPPDATA%\Plutonium\storage\t6\scripts"
|
||||||
xcopy /y .\GameInterface\_integration_t6.gsc "%LOCALAPPDATA%\Plutonium\storage\t6\scripts"
|
xcopy /y .\GameInterface\_integration_t6.gsc "%LOCALAPPDATA%\Plutonium\storage\t6\scripts"
|
||||||
xcopy /y .\GameInterface\_integration_t6zm_helper.gsc "%LOCALAPPDATA%\Plutonium\storage\t6\scripts\zm"
|
xcopy /y .\GameInterface\_integration_t6zm_helper.gsc "%LOCALAPPDATA%\Plutonium\storage\t6\scripts\zm"
|
||||||
xcopy /y .\AntiCheat\PT6\storage\t6\scripts\mp\_customcallbacks.gsc "%LOCALAPPDATA%\Plutonium\storage\t6\scripts\mp"
|
|
||||||
|
@ -53,7 +53,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ScriptPlugins", "ScriptPlug
|
|||||||
Plugins\ScriptPlugins\ParserPlutoniumT5.js = Plugins\ScriptPlugins\ParserPlutoniumT5.js
|
Plugins\ScriptPlugins\ParserPlutoniumT5.js = Plugins\ScriptPlugins\ParserPlutoniumT5.js
|
||||||
Plugins\ScriptPlugins\ServerBanner.js = Plugins\ScriptPlugins\ServerBanner.js
|
Plugins\ScriptPlugins\ServerBanner.js = Plugins\ScriptPlugins\ServerBanner.js
|
||||||
Plugins\ScriptPlugins\ParserBOIII.js = Plugins\ScriptPlugins\ParserBOIII.js
|
Plugins\ScriptPlugins\ParserBOIII.js = Plugins\ScriptPlugins\ParserBOIII.js
|
||||||
Plugins\ScriptPlugins\ParserL4D2SM.js = Plugins\ScriptPlugins\ParserL4D2SM.js
|
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutomessageFeed", "Plugins\AutomessageFeed\AutomessageFeed.csproj", "{F5815359-CFC7-44B4-9A3B-C04BACAD5836}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutomessageFeed", "Plugins\AutomessageFeed\AutomessageFeed.csproj", "{F5815359-CFC7-44B4-9A3B-C04BACAD5836}"
|
||||||
@ -73,9 +72,6 @@ EndProject
|
|||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mute", "Plugins\Mute\Mute.csproj", "{259824F3-D860-4233-91D6-FF73D4DD8B18}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mute", "Plugins\Mute\Mute.csproj", "{259824F3-D860-4233-91D6-FF73D4DD8B18}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "GameFiles", "GameFiles", "{6CBF412C-EFEE-45F7-80FD-AC402C22CDB9}"
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "GameFiles", "GameFiles", "{6CBF412C-EFEE-45F7-80FD-AC402C22CDB9}"
|
||||||
ProjectSection(SolutionItems) = preProject
|
|
||||||
GameFiles\deploy.bat = GameFiles\deploy.bat
|
|
||||||
EndProjectSection
|
|
||||||
EndProject
|
EndProject
|
||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "GameInterface", "GameInterface", "{5C2BE2A8-EA1D-424F-88E1-7FC33EEC2E55}"
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "GameInterface", "GameInterface", "{5C2BE2A8-EA1D-424F-88E1-7FC33EEC2E55}"
|
||||||
ProjectSection(SolutionItems) = preProject
|
ProjectSection(SolutionItems) = preProject
|
||||||
@ -84,11 +80,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "GameInterface", "GameInterf
|
|||||||
GameFiles\GameInterface\_integration_iw5.gsc = GameFiles\GameInterface\_integration_iw5.gsc
|
GameFiles\GameInterface\_integration_iw5.gsc = GameFiles\GameInterface\_integration_iw5.gsc
|
||||||
GameFiles\GameInterface\_integration_shared.gsc = GameFiles\GameInterface\_integration_shared.gsc
|
GameFiles\GameInterface\_integration_shared.gsc = GameFiles\GameInterface\_integration_shared.gsc
|
||||||
GameFiles\GameInterface\_integration_t5.gsc = GameFiles\GameInterface\_integration_t5.gsc
|
GameFiles\GameInterface\_integration_t5.gsc = GameFiles\GameInterface\_integration_t5.gsc
|
||||||
GameFiles\GameInterface\_integration_t5zm.gsc = GameFiles\GameInterface\_integration_t5zm.gsc
|
|
||||||
GameFiles\GameInterface\_integration_t6.gsc = GameFiles\GameInterface\_integration_t6.gsc
|
|
||||||
GameFiles\GameInterface\_integration_t6zm_helper.gsc = GameFiles\GameInterface\_integration_t6zm_helper.gsc
|
|
||||||
GameFiles\GameInterface\example_module.gsc = GameFiles\GameInterface\example_module.gsc
|
|
||||||
GameFiles\GameInterface\_integration_t6_file_bus.gsc = GameFiles\GameInterface\_integration_t6_file_bus.gsc
|
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "AntiCheat", "AntiCheat", "{AB83BAC0-C539-424A-BF00-78487C10753C}"
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "AntiCheat", "AntiCheat", "{AB83BAC0-C539-424A-BF00-78487C10753C}"
|
||||||
|
@ -8,7 +8,6 @@ using System.Text;
|
|||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Integrations.Cod.SecureRcon;
|
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Serilog.Context;
|
using Serilog.Context;
|
||||||
using SharedLibraryCore;
|
using SharedLibraryCore;
|
||||||
@ -25,7 +24,6 @@ namespace Integrations.Cod
|
|||||||
public class CodRConConnection : IRConConnection
|
public class CodRConConnection : IRConConnection
|
||||||
{
|
{
|
||||||
private static readonly ConcurrentDictionary<EndPoint, ConnectionState> ActiveQueries = new();
|
private static readonly ConcurrentDictionary<EndPoint, ConnectionState> ActiveQueries = new();
|
||||||
private const string PkPattern = "-----BEGIN PRIVATE KEY-----";
|
|
||||||
public IPEndPoint Endpoint { get; }
|
public IPEndPoint Endpoint { get; }
|
||||||
public string RConPassword { get; }
|
public string RConPassword { get; }
|
||||||
|
|
||||||
@ -154,28 +152,32 @@ namespace Integrations.Cod
|
|||||||
{
|
{
|
||||||
case StaticHelpers.QueryType.GET_DVAR:
|
case StaticHelpers.QueryType.GET_DVAR:
|
||||||
waitForResponse = true;
|
waitForResponse = true;
|
||||||
payload = BuildPayload(_config.CommandPrefixes.RConGetDvar, convertedRConPassword,
|
payload = string
|
||||||
convertedParameters);
|
.Format(_config.CommandPrefixes.RConGetDvar, convertedRConPassword,
|
||||||
|
convertedParameters + '\0').Select(Convert.ToByte).ToArray();
|
||||||
break;
|
break;
|
||||||
case StaticHelpers.QueryType.SET_DVAR:
|
case StaticHelpers.QueryType.SET_DVAR:
|
||||||
payload = BuildPayload(_config.CommandPrefixes.RConSetDvar, convertedRConPassword,
|
payload = string
|
||||||
convertedParameters);
|
.Format(_config.CommandPrefixes.RConSetDvar, convertedRConPassword,
|
||||||
|
convertedParameters + '\0').Select(Convert.ToByte).ToArray();
|
||||||
break;
|
break;
|
||||||
case StaticHelpers.QueryType.COMMAND:
|
case StaticHelpers.QueryType.COMMAND:
|
||||||
payload = BuildPayload(_config.CommandPrefixes.RConCommand, convertedRConPassword,
|
payload = string
|
||||||
convertedParameters);
|
.Format(_config.CommandPrefixes.RConCommand, convertedRConPassword,
|
||||||
|
convertedParameters + '\0').Select(Convert.ToByte).ToArray();
|
||||||
break;
|
break;
|
||||||
case StaticHelpers.QueryType.GET_STATUS:
|
case StaticHelpers.QueryType.GET_STATUS:
|
||||||
waitForResponse = true;
|
waitForResponse = true;
|
||||||
payload = (_config.CommandPrefixes.RConGetStatus + '\0').Select(Helpers.SafeConversion).ToArray();
|
payload = (_config.CommandPrefixes.RConGetStatus + '\0').Select(Convert.ToByte).ToArray();
|
||||||
break;
|
break;
|
||||||
case StaticHelpers.QueryType.GET_INFO:
|
case StaticHelpers.QueryType.GET_INFO:
|
||||||
waitForResponse = true;
|
waitForResponse = true;
|
||||||
payload = (_config.CommandPrefixes.RConGetInfo + '\0').Select(Helpers.SafeConversion).ToArray();
|
payload = (_config.CommandPrefixes.RConGetInfo + '\0').Select(Convert.ToByte).ToArray();
|
||||||
break;
|
break;
|
||||||
case StaticHelpers.QueryType.COMMAND_STATUS:
|
case StaticHelpers.QueryType.COMMAND_STATUS:
|
||||||
waitForResponse = true;
|
waitForResponse = true;
|
||||||
payload = BuildPayload(_config.CommandPrefixes.RConCommand, convertedRConPassword, "status");
|
payload = string.Format(_config.CommandPrefixes.RConCommand, convertedRConPassword, "status\0")
|
||||||
|
.Select(Convert.ToByte).ToArray();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -320,27 +322,6 @@ namespace Integrations.Cod
|
|||||||
return validatedResponse;
|
return validatedResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
private byte[] BuildPayload(string queryTemplate, string convertedRConPassword, string convertedParameters)
|
|
||||||
{
|
|
||||||
byte[] payload;
|
|
||||||
if (!RConPassword.StartsWith(PkPattern))
|
|
||||||
{
|
|
||||||
payload = string
|
|
||||||
.Format(queryTemplate, convertedRConPassword,
|
|
||||||
convertedParameters + '\0').Select(Helpers.SafeConversion).ToArray();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var textContent = string
|
|
||||||
.Format(queryTemplate, "", convertedParameters)
|
|
||||||
.Replace("rcon", "rconSafe ")
|
|
||||||
.Replace(" ", "").Split(" ");
|
|
||||||
payload = Helpers.BuildSafeRconPayload(textContent[0], textContent[1], RConPassword);
|
|
||||||
}
|
|
||||||
|
|
||||||
return payload;
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task<byte[][]> SendPayloadAsync(Socket rconSocket, byte[] payload, bool waitForResponse,
|
private async Task<byte[][]> SendPayloadAsync(Socket rconSocket, byte[] payload, bool waitForResponse,
|
||||||
CancellationToken token = default)
|
CancellationToken token = default)
|
||||||
{
|
{
|
||||||
|
@ -16,8 +16,4 @@
|
|||||||
<ProjectReference Include="..\..\SharedLibraryCore\SharedLibraryCore.csproj" />
|
<ProjectReference Include="..\..\SharedLibraryCore\SharedLibraryCore.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="protobuf-net" Version="3.2.26" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -1,57 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Security.Cryptography;
|
|
||||||
using ProtoBuf;
|
|
||||||
|
|
||||||
namespace Integrations.Cod.SecureRcon;
|
|
||||||
|
|
||||||
public static class Helpers
|
|
||||||
{
|
|
||||||
private static byte[] ToSerializedMessage(this SecureCommand command)
|
|
||||||
{
|
|
||||||
using var ms = new MemoryStream();
|
|
||||||
Serializer.Serialize(ms, command);
|
|
||||||
return ms.ToArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static byte[] SignData(byte[] data, string privateKey)
|
|
||||||
{
|
|
||||||
using var rsa = new RSACryptoServiceProvider();
|
|
||||||
rsa.ImportFromPem(privateKey);
|
|
||||||
var rsaFormatter = new RSAPKCS1SignatureFormatter(rsa);
|
|
||||||
rsaFormatter.SetHashAlgorithm("SHA512");
|
|
||||||
var hash = SHA512.Create();
|
|
||||||
var hashedData = hash.ComputeHash(data);
|
|
||||||
var signature = rsaFormatter.CreateSignature(hashedData);
|
|
||||||
|
|
||||||
return signature;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static byte SafeConversion(char c)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return Convert.ToByte(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
return (byte)'.';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static byte[] BuildSafeRconPayload(string prefix, string command, string signingKey)
|
|
||||||
{
|
|
||||||
var message = command.Select(SafeConversion).ToArray();
|
|
||||||
var header = (prefix + "\n").Select(SafeConversion).ToArray();
|
|
||||||
|
|
||||||
var secureCommand = new SecureCommand
|
|
||||||
{
|
|
||||||
SecMessage = message,
|
|
||||||
Signature = SignData(message, signingKey)
|
|
||||||
};
|
|
||||||
|
|
||||||
return header.Concat(secureCommand.ToSerializedMessage()).ToArray();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,13 +0,0 @@
|
|||||||
using ProtoBuf;
|
|
||||||
|
|
||||||
namespace Integrations.Cod.SecureRcon;
|
|
||||||
|
|
||||||
[ProtoContract]
|
|
||||||
public class SecureCommand
|
|
||||||
{
|
|
||||||
[ProtoMember(1)]
|
|
||||||
public byte[] SecMessage { get; set; }
|
|
||||||
|
|
||||||
[ProtoMember(2)]
|
|
||||||
public byte[] Signature { get; set; }
|
|
||||||
}
|
|
@ -104,7 +104,7 @@ namespace Integrations.Source
|
|||||||
}
|
}
|
||||||
|
|
||||||
var split = response.TrimEnd('\n').Split('\n');
|
var split = response.TrimEnd('\n').Split('\n');
|
||||||
return split.Take(Math.Max(1, split.Length - 1)).ToArray();
|
return split.Take(split.Length - 1).ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
catch (TaskCanceledException)
|
catch (TaskCanceledException)
|
||||||
|
@ -2,61 +2,34 @@
|
|||||||
const inDvar = 'sv_iw4madmin_in';
|
const inDvar = 'sv_iw4madmin_in';
|
||||||
const outDvar = 'sv_iw4madmin_out';
|
const outDvar = 'sv_iw4madmin_out';
|
||||||
const integrationEnabledDvar = 'sv_iw4madmin_integration_enabled';
|
const integrationEnabledDvar = 'sv_iw4madmin_integration_enabled';
|
||||||
const groupSeparatorChar = '\x1d';
|
const pollingRate = 300;
|
||||||
const recordSeparatorChar = '\x1e';
|
|
||||||
const unitSeparatorChar = '\x1f';
|
|
||||||
|
|
||||||
let busFileIn = '';
|
const init = (registerNotify, serviceResolver, config) => {
|
||||||
let busFileOut = '';
|
|
||||||
let busMode = 'rcon';
|
|
||||||
let busDir = '';
|
|
||||||
|
|
||||||
const init = (registerNotify, serviceResolver, config, scriptHelper) => {
|
|
||||||
registerNotify('IManagementEventSubscriptions.ClientStateInitialized', (clientEvent, _) => plugin.onClientEnteredMatch(clientEvent));
|
registerNotify('IManagementEventSubscriptions.ClientStateInitialized', (clientEvent, _) => plugin.onClientEnteredMatch(clientEvent));
|
||||||
registerNotify('IGameServerEventSubscriptions.ServerValueReceived', (serverValueEvent, _) => plugin.onServerValueReceived(serverValueEvent));
|
registerNotify('IGameServerEventSubscriptions.ServerValueReceived', (serverValueEvent, _) => plugin.onServerValueReceived(serverValueEvent));
|
||||||
registerNotify('IGameServerEventSubscriptions.ServerValueSetCompleted', (serverValueEvent, _) => plugin.onServerValueSetCompleted(serverValueEvent));
|
registerNotify('IGameServerEventSubscriptions.ServerValueSetCompleted', (serverValueEvent, _) => plugin.onServerValueSetCompleted(serverValueEvent));
|
||||||
registerNotify('IGameServerEventSubscriptions.MonitoringStarted', (monitorStartEvent, _) => plugin.onServerMonitoringStart(monitorStartEvent));
|
registerNotify('IGameServerEventSubscriptions.MonitoringStarted', (monitorStartEvent, _) => plugin.onServerMonitoringStart(monitorStartEvent));
|
||||||
registerNotify('IGameEventSubscriptions.MatchStarted', (matchStartEvent, _) => plugin.onMatchStart(matchStartEvent));
|
|
||||||
registerNotify('IManagementEventSubscriptions.ClientPenaltyAdministered', (penaltyEvent, _) => plugin.onPenalty(penaltyEvent));
|
registerNotify('IManagementEventSubscriptions.ClientPenaltyAdministered', (penaltyEvent, _) => plugin.onPenalty(penaltyEvent));
|
||||||
|
|
||||||
plugin.onLoad(serviceResolver, config, scriptHelper);
|
plugin.onLoad(serviceResolver, config);
|
||||||
return plugin;
|
return plugin;
|
||||||
};
|
};
|
||||||
|
|
||||||
const plugin = {
|
const plugin = {
|
||||||
author: 'RaidMax',
|
author: 'RaidMax',
|
||||||
version: '2.1',
|
version: '2.0',
|
||||||
name: 'Game Interface',
|
name: 'Game Interface',
|
||||||
serviceResolver: null,
|
serviceResolver: null,
|
||||||
eventManager: null,
|
eventManager: null,
|
||||||
logger: null,
|
logger: null,
|
||||||
commands: null,
|
commands: null,
|
||||||
scriptHelper: null,
|
|
||||||
configWrapper: null,
|
|
||||||
config: {
|
|
||||||
pollingRate: 300
|
|
||||||
},
|
|
||||||
|
|
||||||
onLoad: function (serviceResolver, configWrapper, scriptHelper) {
|
onLoad: function (serviceResolver, config) {
|
||||||
this.serviceResolver = serviceResolver;
|
this.serviceResolver = serviceResolver;
|
||||||
this.eventManager = serviceResolver.resolveService('IManager');
|
this.eventManager = serviceResolver.resolveService('IManager');
|
||||||
this.logger = serviceResolver.resolveService('ILogger', ['ScriptPluginV2']);
|
this.logger = serviceResolver.resolveService('ILogger', ['ScriptPluginV2']);
|
||||||
this.commands = commands;
|
this.commands = commands;
|
||||||
this.configWrapper = configWrapper;
|
this.config = config;
|
||||||
this.scriptHelper = scriptHelper;
|
|
||||||
|
|
||||||
const storedConfig = this.configWrapper.getValue('config', newConfig => {
|
|
||||||
if (newConfig) {
|
|
||||||
plugin.logger.logInformation('{Name} config reloaded.', plugin.name);
|
|
||||||
plugin.config = newConfig;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (storedConfig != null) {
|
|
||||||
this.config = storedConfig
|
|
||||||
} else {
|
|
||||||
this.configWrapper.setValue('config', this.config);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
onClientEnteredMatch: function (clientEvent) {
|
onClientEnteredMatch: function (clientEvent) {
|
||||||
@ -92,9 +65,6 @@ const plugin = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
onServerValueSetCompleted: async function (serverValueEvent) {
|
onServerValueSetCompleted: async function (serverValueEvent) {
|
||||||
this.logger.logDebug('Set {dvarName}={dvarValue} success={success} from {server}', serverValueEvent.valueName,
|
|
||||||
serverValueEvent.value, serverValueEvent.success, serverValueEvent.server.id);
|
|
||||||
|
|
||||||
if (serverValueEvent.valueName !== inDvar && serverValueEvent.valueName !== outDvar) {
|
if (serverValueEvent.valueName !== inDvar && serverValueEvent.valueName !== outDvar) {
|
||||||
this.logger.logDebug('Ignoring set complete of {name}', serverValueEvent.valueName);
|
this.logger.logDebug('Ignoring set complete of {name}', serverValueEvent.valueName);
|
||||||
return;
|
return;
|
||||||
@ -117,7 +87,9 @@ const plugin = {
|
|||||||
const input = serverState.inQueue.shift();
|
const input = serverState.inQueue.shift();
|
||||||
|
|
||||||
// if we queued an event then the next loop will be at the value set complete
|
// if we queued an event then the next loop will be at the value set complete
|
||||||
await this.processEventMessage(input, serverValueEvent.server);
|
if (await this.processEventMessage(input, serverValueEvent.server)) {
|
||||||
|
// return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.logger.logDebug('loop complete');
|
this.logger.logDebug('loop complete');
|
||||||
@ -125,15 +97,6 @@ const plugin = {
|
|||||||
this.requestGetDvar(inDvar, serverValueEvent.server);
|
this.requestGetDvar(inDvar, serverValueEvent.server);
|
||||||
},
|
},
|
||||||
|
|
||||||
onServerMonitoringStart: function (monitorStartEvent) {
|
|
||||||
this.initializeServer(monitorStartEvent.server);
|
|
||||||
},
|
|
||||||
|
|
||||||
onMatchStart: function (matchStartEvent) {
|
|
||||||
busMode = 'rcon';
|
|
||||||
this.sendEventMessage(matchStartEvent.server, true, 'GetBusModeRequested', null, null, null, {});
|
|
||||||
},
|
|
||||||
|
|
||||||
initializeServer: function (server) {
|
initializeServer: function (server) {
|
||||||
servers[server.id] = {
|
servers[server.id] = {
|
||||||
enabled: false,
|
enabled: false,
|
||||||
@ -163,11 +126,6 @@ const plugin = {
|
|||||||
serverState.running = true;
|
serverState.running = true;
|
||||||
serverState.initializationInProgress = false;
|
serverState.initializationInProgress = false;
|
||||||
|
|
||||||
// todo: this might not work for all games
|
|
||||||
responseEvent.server.rconParser.configuration.floodProtectInterval = 150;
|
|
||||||
|
|
||||||
this.sendEventMessage(responseEvent.server, true, 'GetBusModeRequested', null, null, null, {});
|
|
||||||
this.sendEventMessage(responseEvent.server, true, 'GetCommandsRequested', null, null, null, {});
|
|
||||||
this.requestGetDvar(inDvar, responseEvent.server);
|
this.requestGetDvar(inDvar, responseEvent.server);
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -178,9 +136,7 @@ const plugin = {
|
|||||||
const serverState = servers[responseEvent.server.id];
|
const serverState = servers[responseEvent.server.id];
|
||||||
serverState.outQueue.shift();
|
serverState.outQueue.shift();
|
||||||
|
|
||||||
const utilities = importNamespace('SharedLibraryCore.Utilities');
|
if (responseEvent.server.connectedClients.count === 0) {
|
||||||
|
|
||||||
if (responseEvent.server.connectedClients.count === 0 && !utilities.isDevelopment) {
|
|
||||||
// no clients connected so we don't need to query
|
// no clients connected so we don't need to query
|
||||||
serverState.running = false;
|
serverState.running = false;
|
||||||
return;
|
return;
|
||||||
@ -223,8 +179,8 @@ const plugin = {
|
|||||||
let messageQueued = false;
|
let messageQueued = false;
|
||||||
const event = parseEvent(input);
|
const event = parseEvent(input);
|
||||||
|
|
||||||
this.logger.logDebug('Processing input... {eventType} {subType} {@data} {clientNumber}', event.eventType,
|
this.logger.logDebug('Processing input... {eventType} {subType} {data} {clientNumber}', event.eventType,
|
||||||
event.subType, event.data, event.clientNumber);
|
event.subType, event.data.toString(), event.clientNumber);
|
||||||
|
|
||||||
const metaService = this.serviceResolver.ResolveService('IMetaServiceV2');
|
const metaService = this.serviceResolver.ResolveService('IMetaServiceV2');
|
||||||
const threading = importNamespace('System.Threading');
|
const threading = importNamespace('System.Threading');
|
||||||
@ -252,7 +208,7 @@ const plugin = {
|
|||||||
data = {
|
data = {
|
||||||
level: client.level,
|
level: client.level,
|
||||||
clientId: client.clientId,
|
clientId: client.clientId,
|
||||||
lastConnection: client.timeSinceLastConnectionString,
|
lastConnection: client.lastConnection,
|
||||||
tag: tagMeta?.value ?? '',
|
tag: tagMeta?.value ?? '',
|
||||||
performance: clientStats?.performance ?? 200.0
|
performance: clientStats?.performance ?? 200.0
|
||||||
};
|
};
|
||||||
@ -331,74 +287,17 @@ const plugin = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.eventType === 'UrlRequested') {
|
|
||||||
const urlRequest = this.parseUrlRequest(event);
|
|
||||||
|
|
||||||
this.logger.logDebug('Making gamescript web request {@Request}', urlRequest);
|
|
||||||
|
|
||||||
this.scriptHelper.requestUrl(urlRequest, response => {
|
|
||||||
this.logger.logDebug('Got response for gamescript web request - {Response}', response);
|
|
||||||
|
|
||||||
if (typeof response !== 'string' && !(response instanceof String)) {
|
|
||||||
response = JSON.stringify(response);
|
|
||||||
}
|
|
||||||
|
|
||||||
const max = 10;
|
|
||||||
this.logger.logDebug(`response length ${response.length}`);
|
|
||||||
|
|
||||||
let quoteReplace = '\\"';
|
|
||||||
// todo: may be more than just T6
|
|
||||||
if (server.gameCode === 'T6') {
|
|
||||||
quoteReplace = '\\\\"';
|
|
||||||
}
|
|
||||||
|
|
||||||
let chunks = chunkString(response.replace(/"/gm, quoteReplace).replace(/[\n|\t]/gm, ''), 800);
|
|
||||||
if (chunks.length > max) {
|
|
||||||
this.logger.logWarning(`Response chunks greater than max (${max}). Data truncated!`);
|
|
||||||
chunks = chunks.slice(0, max);
|
|
||||||
}
|
|
||||||
this.logger.logDebug(`chunk size ${chunks.length}`);
|
|
||||||
|
|
||||||
for (let i = 0; i < chunks.length; i++) {
|
|
||||||
this.sendEventMessage(server, false, 'UrlRequestCompleted', null, null,
|
|
||||||
null, { entity: event.data.entity, remaining: chunks.length - (i + 1), response: chunks[i]});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (event.eventType === 'RegisterCommandRequested') {
|
|
||||||
this.registerDynamicCommand(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (event.eventType === 'GetBusModeRequested') {
|
|
||||||
if (event.data?.directory && event.data?.mode) {
|
|
||||||
busMode = event.data.mode;
|
|
||||||
busDir = event.data.directory.replace('\'', '').replace('"', '');
|
|
||||||
if (event.data?.inLocation && event.data?.outLocation) {
|
|
||||||
busFileIn = event.data?.inLocation;
|
|
||||||
busFileOut = event.data?.outLocation;
|
|
||||||
}
|
|
||||||
this.logger.logDebug('Setting bus mode to {mode} {dir}', busMode, busDir);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tokenSource.dispose();
|
tokenSource.dispose();
|
||||||
return messageQueued;
|
return messageQueued;
|
||||||
},
|
},
|
||||||
|
|
||||||
sendEventMessage: function (server, responseExpected, event, subtype, origin, target, data) {
|
sendEventMessage: function (server, responseExpected, event, subtype, origin, target, data) {
|
||||||
let targetClientNumber = -1;
|
let targetClientNumber = -1;
|
||||||
let originClientNumber = -1;
|
|
||||||
|
|
||||||
if (target != null) {
|
if (target != null) {
|
||||||
targetClientNumber = target.clientNumber;
|
targetClientNumber = target.ClientNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (origin != null) {
|
const output = `${responseExpected ? '1' : '0'};${event};${subtype};${origin.ClientNumber};${targetClientNumber};${buildDataString(data)}`;
|
||||||
originClientNumber = origin.clientNumber
|
|
||||||
}
|
|
||||||
|
|
||||||
const output = `${responseExpected ? '1' : '0'}${groupSeparatorChar}${event}${groupSeparatorChar}${subtype}${groupSeparatorChar}${originClientNumber}${groupSeparatorChar}${targetClientNumber}${groupSeparatorChar}${buildDataString(data)}`;
|
|
||||||
this.logger.logDebug('Queuing output for server {output}', output);
|
this.logger.logDebug('Queuing output for server {output}', output);
|
||||||
|
|
||||||
servers[server.id].commandQueue.push(output);
|
servers[server.id].commandQueue.push(output);
|
||||||
@ -406,40 +305,9 @@ const plugin = {
|
|||||||
|
|
||||||
requestGetDvar: function (dvarName, server) {
|
requestGetDvar: function (dvarName, server) {
|
||||||
const serverState = servers[server.id];
|
const serverState = servers[server.id];
|
||||||
|
|
||||||
if (dvarName !== integrationEnabledDvar && busMode === 'file') {
|
|
||||||
this.scriptHelper.requestNotifyAfterDelay(250, () => {
|
|
||||||
const io = importNamespace('System.IO');
|
|
||||||
serverState.outQueue.push({});
|
|
||||||
try {
|
|
||||||
const content = io.File.ReadAllText(`${busDir}/${fileForDvar(dvarName)}`);
|
|
||||||
plugin.onServerValueReceived({
|
|
||||||
server: server,
|
|
||||||
source: server,
|
|
||||||
success: true,
|
|
||||||
response: {
|
|
||||||
name: dvarName,
|
|
||||||
value: content
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} catch (e) {
|
|
||||||
plugin.logger.logError('Could not get bus data {exception}', e.toString());
|
|
||||||
plugin.onServerValueReceived({
|
|
||||||
server: server,
|
|
||||||
success: false,
|
|
||||||
response: {
|
|
||||||
name: dvarName
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const serverEvents = importNamespace('SharedLibraryCore.Events.Server');
|
const serverEvents = importNamespace('SharedLibraryCore.Events.Server');
|
||||||
const requestEvent = new serverEvents.ServerValueRequestEvent(dvarName, server);
|
const requestEvent = new serverEvents.ServerValueRequestEvent(dvarName, server);
|
||||||
requestEvent.delayMs = this.config.pollingRate;
|
requestEvent.delayMs = pollingRate;
|
||||||
requestEvent.timeoutMs = 2000;
|
requestEvent.timeoutMs = 2000;
|
||||||
requestEvent.source = this.name;
|
requestEvent.source = this.name;
|
||||||
|
|
||||||
@ -449,7 +317,7 @@ const plugin = {
|
|||||||
const diff = new Date().getTime() - end.getTime();
|
const diff = new Date().getTime() - end.getTime();
|
||||||
|
|
||||||
if (diff < extraDelay) {
|
if (diff < extraDelay) {
|
||||||
requestEvent.delayMs = (extraDelay - diff) + this.config.pollingRate;
|
requestEvent.delayMs = (extraDelay - diff) + pollingRate;
|
||||||
this.logger.logDebug('Increasing delay time to {Delay}ms due to recent map change', requestEvent.delayMs);
|
this.logger.logDebug('Increasing delay time to {Delay}ms due to recent map change', requestEvent.delayMs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -468,38 +336,9 @@ const plugin = {
|
|||||||
requestSetDvar: function (dvarName, dvarValue, server) {
|
requestSetDvar: function (dvarName, dvarValue, server) {
|
||||||
const serverState = servers[server.id];
|
const serverState = servers[server.id];
|
||||||
|
|
||||||
if ( busMode === 'file' ) {
|
|
||||||
this.scriptHelper.requestNotifyAfterDelay(250, async () => {
|
|
||||||
const io = importNamespace('System.IO');
|
|
||||||
try {
|
|
||||||
const path = `${busDir}/${fileForDvar(dvarName)}`;
|
|
||||||
plugin.logger.logDebug('writing {value} to {file}', dvarValue, path);
|
|
||||||
io.File.WriteAllText(path, dvarValue);
|
|
||||||
serverState.outQueue.push({});
|
|
||||||
await plugin.onServerValueSetCompleted({
|
|
||||||
server: server,
|
|
||||||
source: server,
|
|
||||||
success: true,
|
|
||||||
value: dvarValue,
|
|
||||||
valueName: dvarName,
|
|
||||||
});
|
|
||||||
} catch (e) {
|
|
||||||
plugin.logger.logError('Could not set bus data {exception}', e.toString());
|
|
||||||
await plugin.onServerValueSetCompleted({
|
|
||||||
server: server,
|
|
||||||
success: false,
|
|
||||||
valueName: dvarName,
|
|
||||||
value: dvarValue
|
|
||||||
});
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const serverEvents = importNamespace('SharedLibraryCore.Events.Server');
|
const serverEvents = importNamespace('SharedLibraryCore.Events.Server');
|
||||||
const requestEvent = new serverEvents.ServerValueSetRequestEvent(dvarName, dvarValue, server);
|
const requestEvent = new serverEvents.ServerValueSetRequestEvent(dvarName, dvarValue, server);
|
||||||
requestEvent.delayMs = this.config.pollingRate;
|
requestEvent.delayMs = pollingRate;
|
||||||
requestEvent.timeoutMs = 2000;
|
requestEvent.timeoutMs = 2000;
|
||||||
requestEvent.source = this.name;
|
requestEvent.source = this.name;
|
||||||
|
|
||||||
@ -509,7 +348,7 @@ const plugin = {
|
|||||||
const diff = new Date().getTime() - end.getTime();
|
const diff = new Date().getTime() - end.getTime();
|
||||||
|
|
||||||
if (diff < extraDelay) {
|
if (diff < extraDelay) {
|
||||||
requestEvent.delayMs = (extraDelay - diff) + this.config.pollingRate;
|
requestEvent.delayMs = (extraDelay - diff) + pollingRate;
|
||||||
this.logger.logDebug('Increasing delay time to {Delay}ms due to recent map change', requestEvent.delayMs);
|
this.logger.logDebug('Increasing delay time to {Delay}ms due to recent map change', requestEvent.delayMs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -526,64 +365,8 @@ const plugin = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
parseUrlRequest: function(event) {
|
onServerMonitoringStart: function (monitorStartEvent) {
|
||||||
const url = event.data?.url;
|
this.initializeServer(monitorStartEvent.server);
|
||||||
|
|
||||||
if (url === undefined) {
|
|
||||||
this.logger.logWarning('No url provided for gamescript web request - {Event}', event);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const body = event.data?.body;
|
|
||||||
const method = event.data?.method || 'GET';
|
|
||||||
const contentType = event.data?.contentType || 'text/plain';
|
|
||||||
const headers = event.data?.headers;
|
|
||||||
|
|
||||||
const dictionary = System.Collections.Generic.Dictionary(System.String, System.String);
|
|
||||||
const headerDict = new dictionary();
|
|
||||||
|
|
||||||
if (headers) {
|
|
||||||
const eachHeader = headers.split(',');
|
|
||||||
|
|
||||||
for (let eachKeyValue of eachHeader) {
|
|
||||||
const keyValueSplit = eachKeyValue.split(':');
|
|
||||||
if (keyValueSplit.length === 2) {
|
|
||||||
headerDict.add(keyValueSplit[0], keyValueSplit[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const script = importNamespace('IW4MAdmin.Application.Plugin.Script');
|
|
||||||
return new script.ScriptPluginWebRequest(url, body, method, contentType, headerDict);
|
|
||||||
},
|
|
||||||
|
|
||||||
registerDynamicCommand: function(event) {
|
|
||||||
const commandWrapper = {
|
|
||||||
commands: [{
|
|
||||||
name: event.data['name'] || 'DEFAULT',
|
|
||||||
description: event.data['description'] || 'DEFAULT',
|
|
||||||
alias: event.data['alias'] || 'DEFAULT',
|
|
||||||
permission: event.data['minPermission'] || 'DEFAULT',
|
|
||||||
targetRequired: (event.data['targetRequired'] || '0') === '1',
|
|
||||||
supportedGames: (event.data['supportedGames'] || '').split(','),
|
|
||||||
|
|
||||||
execute: (gameEvent) => {
|
|
||||||
if (!validateEnabled(gameEvent.owner, gameEvent.origin)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (gameEvent.data === '--reload' && gameEvent.origin.level === 'Owner') {
|
|
||||||
this.sendEventMessage(gameEvent.owner, true, 'GetCommandsRequested', null, null, null, { name: gameEvent.extra.name });
|
|
||||||
} else {
|
|
||||||
sendScriptCommand(gameEvent.owner, `${event.data['eventKey']}Execute`, gameEvent.origin, gameEvent.target, {
|
|
||||||
args: gameEvent.data
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}]
|
|
||||||
}
|
|
||||||
|
|
||||||
this.scriptHelper.registerDynamicCommand(commandWrapper);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -851,7 +634,7 @@ const parseEvent = (input) => {
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
const eventInfo = input.split(groupSeparatorChar);
|
const eventInfo = input.split(';');
|
||||||
|
|
||||||
return {
|
return {
|
||||||
eventType: eventInfo[1],
|
eventType: eventInfo[1],
|
||||||
@ -869,7 +652,7 @@ const buildDataString = data => {
|
|||||||
let formattedData = '';
|
let formattedData = '';
|
||||||
|
|
||||||
for (let [key, value] of Object.entries(data)) {
|
for (let [key, value] of Object.entries(data)) {
|
||||||
formattedData += `${key}${unitSeparatorChar}${value}${recordSeparatorChar}`;
|
formattedData += `${key}=${value}|`;
|
||||||
}
|
}
|
||||||
|
|
||||||
return formattedData.slice(0, -1);
|
return formattedData.slice(0, -1);
|
||||||
@ -881,11 +664,11 @@ const parseDataString = data => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const dict = {};
|
const dict = {};
|
||||||
const split = data.split(recordSeparatorChar);
|
const split = data.split('|');
|
||||||
|
|
||||||
for (let i = 0; i < split.length; i++) {
|
for (let i = 0; i < split.length; i++) {
|
||||||
const segment = split[i];
|
const segment = split[i];
|
||||||
const keyValue = segment.split(unitSeparatorChar);
|
const keyValue = segment.split('=');
|
||||||
if (keyValue.length !== 2) {
|
if (keyValue.length !== 2) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -906,20 +689,3 @@ const validateEnabled = (server, origin) => {
|
|||||||
const isEmpty = (value) => {
|
const isEmpty = (value) => {
|
||||||
return value == null || false || value === '' || value === 'null';
|
return value == null || false || value === '' || value === 'null';
|
||||||
};
|
};
|
||||||
|
|
||||||
const chunkString = (str, chunkSize) => {
|
|
||||||
const result = [];
|
|
||||||
for (let i = 0; i < str.length; i += chunkSize) {
|
|
||||||
result.push(str.slice(i, i + chunkSize));
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
const fileForDvar = (dvar) => {
|
|
||||||
if (dvar === inDvar) {
|
|
||||||
return busFileIn;
|
|
||||||
}
|
|
||||||
|
|
||||||
return busFileOut;
|
|
||||||
}
|
|
||||||
|
@ -22,10 +22,10 @@ const plugin = {
|
|||||||
rconParser.Configuration.MapStatus.AddMapping(111, 1);
|
rconParser.Configuration.MapStatus.AddMapping(111, 1);
|
||||||
|
|
||||||
rconParser.Configuration.HostnameStatus.Pattern = '^hostname: +(.+)$';
|
rconParser.Configuration.HostnameStatus.Pattern = '^hostname: +(.+)$';
|
||||||
rconParser.Configuration.HostnameStatus.AddMapping(113, 1);
|
rconParser.Configuration.MapStatus.AddMapping(113, 1);
|
||||||
|
|
||||||
rconParser.Configuration.MaxPlayersStatus.Pattern = '^players *: +\\d+ humans, \\d+ bots \\((\\d+).+';
|
rconParser.Configuration.MaxPlayersStatus.Pattern = '^players *: +\\d+ humans, \\d+ bots \\((\\d+).+';
|
||||||
rconParser.Configuration.MaxPlayersStatus.AddMapping(114, 1);
|
rconParser.Configuration.MapStatus.AddMapping(114, 1);
|
||||||
|
|
||||||
rconParser.Configuration.Dvar.Pattern = '^"(.+)" = "(.+)" (?:\\( def. "(.*)" \\))?(?: |\\w)+- (.+)$';
|
rconParser.Configuration.Dvar.Pattern = '^"(.+)" = "(.+)" (?:\\( def. "(.*)" \\))?(?: |\\w)+- (.+)$';
|
||||||
rconParser.Configuration.Dvar.AddMapping(106, 1);
|
rconParser.Configuration.Dvar.AddMapping(106, 1);
|
||||||
|
@ -3,7 +3,7 @@ let eventParser;
|
|||||||
|
|
||||||
const plugin = {
|
const plugin = {
|
||||||
author: 'RaidMax',
|
author: 'RaidMax',
|
||||||
version: 0.7,
|
version: 0.6,
|
||||||
name: 'CS:GO (SourceMod) Parser',
|
name: 'CS:GO (SourceMod) Parser',
|
||||||
engine: 'Source',
|
engine: 'Source',
|
||||||
isParser: true,
|
isParser: true,
|
||||||
@ -22,10 +22,10 @@ const plugin = {
|
|||||||
rconParser.Configuration.MapStatus.AddMapping(111, 1);
|
rconParser.Configuration.MapStatus.AddMapping(111, 1);
|
||||||
|
|
||||||
rconParser.Configuration.HostnameStatus.Pattern = '^hostname: +(.+)$';
|
rconParser.Configuration.HostnameStatus.Pattern = '^hostname: +(.+)$';
|
||||||
rconParser.Configuration.HostnameStatus.AddMapping(113, 1);
|
rconParser.Configuration.MapStatus.AddMapping(113, 1);
|
||||||
|
|
||||||
rconParser.Configuration.MaxPlayersStatus.Pattern = '^players *: +\\d+ humans, \\d+ bots \\((\\d+).+';
|
rconParser.Configuration.MaxPlayersStatus.Pattern = '^players *: +\\d+ humans, \\d+ bots \\((\\d+).+';
|
||||||
rconParser.Configuration.MaxPlayersStatus.AddMapping(114, 1);
|
rconParser.Configuration.MapStatus.AddMapping(114, 1);
|
||||||
|
|
||||||
rconParser.Configuration.Dvar.Pattern = '^"(.+)" = "(.+)" (?:\\( def. "(.*)" \\))?(?: |\\w)+- (.+)$';
|
rconParser.Configuration.Dvar.Pattern = '^"(.+)" = "(.+)" (?:\\( def. "(.*)" \\))?(?: |\\w)+- (.+)$';
|
||||||
rconParser.Configuration.Dvar.AddMapping(106, 1);
|
rconParser.Configuration.Dvar.AddMapping(106, 1);
|
||||||
|
@ -1,135 +0,0 @@
|
|||||||
let rconParser;
|
|
||||||
let eventParser;
|
|
||||||
|
|
||||||
const plugin = {
|
|
||||||
author: 'RaidMax',
|
|
||||||
version: 0.1,
|
|
||||||
name: 'L4D2 (SourceMod) Parser',
|
|
||||||
engine: 'Source',
|
|
||||||
isParser: true,
|
|
||||||
|
|
||||||
onEventAsync: function (gameEvent, server) {
|
|
||||||
},
|
|
||||||
|
|
||||||
onLoadAsync: function (manager) {
|
|
||||||
rconParser = manager.GenerateDynamicRConParser(this.name);
|
|
||||||
eventParser = manager.GenerateDynamicEventParser(this.name);
|
|
||||||
rconParser.RConEngine = this.engine;
|
|
||||||
|
|
||||||
rconParser.Configuration.StatusHeader.Pattern = '# userid name uniqueid connected ping loss state rate adr';
|
|
||||||
|
|
||||||
rconParser.Configuration.MapStatus.Pattern = '^map *: +(.+)$';
|
|
||||||
rconParser.Configuration.MapStatus.AddMapping(111, 1);
|
|
||||||
|
|
||||||
rconParser.Configuration.HostnameStatus.Pattern = '^hostname: +(.+)$';
|
|
||||||
rconParser.Configuration.HostnameStatus.AddMapping(113, 1);
|
|
||||||
|
|
||||||
rconParser.Configuration.MaxPlayersStatus.Pattern = '^players *: +\\d+ humans, \\d+ bots \\((\\d+).+';
|
|
||||||
rconParser.Configuration.MaxPlayersStatus.AddMapping(114, 1);
|
|
||||||
|
|
||||||
rconParser.Configuration.Dvar.Pattern = '^\\"(.+)\\" (?:=|is) \\"(.+)\\"(?: (?:\\( def. \\"(.*)\\" \\)))?$';
|
|
||||||
rconParser.Configuration.Dvar.AddMapping(106, 1);
|
|
||||||
rconParser.Configuration.Dvar.AddMapping(107, 2);
|
|
||||||
rconParser.Configuration.Dvar.AddMapping(108, 3);
|
|
||||||
rconParser.Configuration.Dvar.AddMapping(109, 3);
|
|
||||||
|
|
||||||
rconParser.Configuration.Status.Pattern = '^#\\s*(\\d+) (\\d+) "(.+)" (\\S+) +(\\d+:\\d+(?::\\d+)?) (\\d+) (\\S+) (\\S+) (\\d+) (\\d+\\.\\d+\\.\\d+\\.\\d+:\\d+)$';
|
|
||||||
rconParser.Configuration.Status.AddMapping(100, 2);
|
|
||||||
rconParser.Configuration.Status.AddMapping(101, -1);
|
|
||||||
rconParser.Configuration.Status.AddMapping(102, 6);
|
|
||||||
rconParser.Configuration.Status.AddMapping(103, 4)
|
|
||||||
rconParser.Configuration.Status.AddMapping(104, 3);
|
|
||||||
rconParser.Configuration.Status.AddMapping(105, 10);
|
|
||||||
rconParser.Configuration.Status.AddMapping(200, 1);
|
|
||||||
|
|
||||||
rconParser.Configuration.DefaultDvarValues.Add('sv_running', '1');
|
|
||||||
rconParser.Configuration.DefaultDvarValues.Add('bugfix_no_version', this.engine);
|
|
||||||
rconParser.Configuration.DefaultDvarValues.Add('fs_basepath', '');
|
|
||||||
rconParser.Configuration.DefaultDvarValues.Add('fs_basegame', '');
|
|
||||||
rconParser.Configuration.DefaultDvarValues.Add('fs_homepath', '');
|
|
||||||
rconParser.Configuration.DefaultDvarValues.Add('g_log', '');
|
|
||||||
rconParser.Configuration.DefaultDvarValues.Add('net_ip', 'localhost');
|
|
||||||
rconParser.Configuration.DefaultDvarValues.Add('g_gametype', '');
|
|
||||||
rconParser.Configuration.DefaultDvarValues.Add('fs_game', '');
|
|
||||||
|
|
||||||
rconParser.Configuration.OverrideDvarNameMapping.Add('sv_hostname', 'hostname');
|
|
||||||
rconParser.Configuration.OverrideDvarNameMapping.Add('mapname', 'host_map');
|
|
||||||
rconParser.Configuration.OverrideDvarNameMapping.Add('sv_maxclients', 'maxplayers');
|
|
||||||
rconParser.Configuration.OverrideDvarNameMapping.Add('g_password', 'sv_password');
|
|
||||||
rconParser.Configuration.OverrideDvarNameMapping.Add('version', 'bugfix_no_version');
|
|
||||||
|
|
||||||
rconParser.Configuration.ColorCodeMapping.Clear();
|
|
||||||
rconParser.Configuration.ColorCodeMapping.Add('White', '\x01');
|
|
||||||
rconParser.Configuration.ColorCodeMapping.Add('Red', '\x07');
|
|
||||||
rconParser.Configuration.ColorCodeMapping.Add('LightRed', '\x0F');
|
|
||||||
rconParser.Configuration.ColorCodeMapping.Add('DarkRed', '\x02');
|
|
||||||
rconParser.Configuration.ColorCodeMapping.Add('Blue', '\x0B');
|
|
||||||
rconParser.Configuration.ColorCodeMapping.Add('DarkBlue', '\x0C');
|
|
||||||
rconParser.Configuration.ColorCodeMapping.Add('Purple', '\x03');
|
|
||||||
rconParser.Configuration.ColorCodeMapping.Add('Orchid', '\x0E');
|
|
||||||
rconParser.Configuration.ColorCodeMapping.Add('Yellow', '\x09');
|
|
||||||
rconParser.Configuration.ColorCodeMapping.Add('Gold', '\x10');
|
|
||||||
rconParser.Configuration.ColorCodeMapping.Add('LightGreen', '\x05');
|
|
||||||
rconParser.Configuration.ColorCodeMapping.Add('Green', '\x04');
|
|
||||||
rconParser.Configuration.ColorCodeMapping.Add('Lime', '\x06');
|
|
||||||
rconParser.Configuration.ColorCodeMapping.Add('Grey', '\x08');
|
|
||||||
rconParser.Configuration.ColorCodeMapping.Add('Grey2', '\x0D');
|
|
||||||
// only adding there here for the default accent color
|
|
||||||
rconParser.Configuration.ColorCodeMapping.Add('Cyan', '\x0B');
|
|
||||||
|
|
||||||
rconParser.Configuration.NoticeLineSeparator = '. ';
|
|
||||||
rconParser.Configuration.DefaultRConPort = 27015;
|
|
||||||
rconParser.CanGenerateLogPath = false;
|
|
||||||
|
|
||||||
rconParser.Configuration.CommandPrefixes.RConGetInfo = undefined;
|
|
||||||
rconParser.Configuration.CommandPrefixes.Kick = 'sm_kick #{0} {1}';
|
|
||||||
rconParser.Configuration.CommandPrefixes.Ban = 'sm_kick #{0} {1}';
|
|
||||||
rconParser.Configuration.CommandPrefixes.TempBan = 'sm_kick #{0} {1}';
|
|
||||||
rconParser.Configuration.CommandPrefixes.Say = 'sm_say {0}';
|
|
||||||
rconParser.Configuration.CommandPrefixes.Tell = 'sm_psay #{0} "{1}"';
|
|
||||||
|
|
||||||
eventParser.Configuration.Say.Pattern = '^"(.+)<(\\d+)><(.+)><(.*?)>" (?:say|say_team) "(.*)"$';
|
|
||||||
eventParser.Configuration.Say.AddMapping(5, 1);
|
|
||||||
eventParser.Configuration.Say.AddMapping(3, 2);
|
|
||||||
eventParser.Configuration.Say.AddMapping(1, 3);
|
|
||||||
eventParser.Configuration.Say.AddMapping(7, 4);
|
|
||||||
eventParser.Configuration.Say.AddMapping(13, 5);
|
|
||||||
|
|
||||||
eventParser.Configuration.Kill.Pattern = '^"(.+)<(\\d+)><(.+)><(.*)>" \\[-?\\d+ -?\\d+ -?\\d+\\] killed "(.+)<(\\d+)><(.+)><(.*)>" \\[-?\\d+ -?\\d+ -?\\d+\\] with "(\\S*)" *(?:\\((\\w+)((?: ).+)?\\))?$';
|
|
||||||
eventParser.Configuration.Kill.AddMapping(5, 1);
|
|
||||||
eventParser.Configuration.Kill.AddMapping(3, 2);
|
|
||||||
eventParser.Configuration.Kill.AddMapping(1, 3);
|
|
||||||
eventParser.Configuration.Kill.AddMapping(7, 4);
|
|
||||||
eventParser.Configuration.Kill.AddMapping(6, 5);
|
|
||||||
eventParser.Configuration.Kill.AddMapping(4, 6);
|
|
||||||
eventParser.Configuration.Kill.AddMapping(2, 7);
|
|
||||||
eventParser.Configuration.Kill.AddMapping(8, 8);
|
|
||||||
eventParser.Configuration.Kill.AddMapping(9, 9);
|
|
||||||
eventParser.Configuration.Kill.AddMapping(12, 10);
|
|
||||||
|
|
||||||
eventParser.Configuration.MapEnd.Pattern = '^World triggered "Match_Start" on "(.+)"$';
|
|
||||||
|
|
||||||
eventParser.Configuration.JoinTeam.Pattern = '^"(.+)<(\\d+)><(.*)>" switched from team <(.+)> to <(.+)>$';
|
|
||||||
eventParser.Configuration.JoinTeam.AddMapping(5, 1);
|
|
||||||
eventParser.Configuration.JoinTeam.AddMapping(3, 2);
|
|
||||||
eventParser.Configuration.JoinTeam.AddMapping(1, 3);
|
|
||||||
eventParser.Configuration.JoinTeam.AddMapping(7, 5);
|
|
||||||
|
|
||||||
eventParser.Configuration.TeamMapping.Add('CT', 2);
|
|
||||||
eventParser.Configuration.TeamMapping.Add('TERRORIST', 3);
|
|
||||||
|
|
||||||
eventParser.Configuration.Time.Pattern = '^L [01]\\d/[0-3]\\d/\\d+ - [0-2]\\d:[0-5]\\d:[0-5]\\d:';
|
|
||||||
|
|
||||||
rconParser.Version = 'L4D2SM';
|
|
||||||
rconParser.GameName = 12; // L4D2
|
|
||||||
eventParser.Version = 'L4D2SM';
|
|
||||||
eventParser.GameName = 12; // L4D2
|
|
||||||
eventParser.URLProtocolFormat = 'steam://connect/{{ip}}:{{port}}';
|
|
||||||
},
|
|
||||||
|
|
||||||
onUnloadAsync: function () {
|
|
||||||
},
|
|
||||||
|
|
||||||
onTickAsync: function (server) {
|
|
||||||
}
|
|
||||||
};
|
|
@ -25,24 +25,10 @@ namespace Stats.Dtos
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public DateTime? SentAfter { get; set; }
|
public DateTime? SentAfter { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The time associated with SentAfter date
|
|
||||||
/// </summary>
|
|
||||||
public string SentAfterTime { get; set; }
|
|
||||||
|
|
||||||
public DateTime? SentAfterDateTime => SentAfter?.Add(string.IsNullOrEmpty(SentAfterTime) ? TimeSpan.Zero : TimeSpan.Parse(SentAfterTime));
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// only look for messages sent before this date0
|
/// only look for messages sent before this date0
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public DateTime SentBefore { get; set; } = DateTime.UtcNow.Date;
|
public DateTime SentBefore { get; set; } = DateTime.UtcNow;
|
||||||
|
|
||||||
public string SentBeforeTime { get; set; }
|
|
||||||
|
|
||||||
public DateTime? SentBeforeDateTime =>
|
|
||||||
SentBefore.Add(string.IsNullOrEmpty(SentBeforeTime) ? TimeSpan.Zero : TimeSpan.Parse(SentBeforeTime));
|
|
||||||
|
|
||||||
public bool IsExactMatch { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// indicates if the chat is on the meta page
|
/// indicates if the chat is on the meta page
|
||||||
|
@ -13,6 +13,7 @@ namespace IW4MAdmin.Plugins.Stats
|
|||||||
{
|
{
|
||||||
private const int ZScoreRange = 3;
|
private const int ZScoreRange = 3;
|
||||||
private const int RankIconDivisions = 24;
|
private const int RankIconDivisions = 24;
|
||||||
|
private const int MaxMessages = 100;
|
||||||
|
|
||||||
public class LogParams
|
public class LogParams
|
||||||
{
|
{
|
||||||
@ -126,5 +127,70 @@ namespace IW4MAdmin.Plugins.Stats
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// todo: lets abstract this out to a generic buildable query
|
||||||
|
/// this is just a dirty PoC
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="query"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static ChatSearchQuery ParseSearchInfo(this string query, int count, int offset)
|
||||||
|
{
|
||||||
|
string[] filters = query.Split('|');
|
||||||
|
var searchRequest = new ChatSearchQuery
|
||||||
|
{
|
||||||
|
Filter = query,
|
||||||
|
Count = count,
|
||||||
|
Offset = offset
|
||||||
|
};
|
||||||
|
|
||||||
|
// sanity checks
|
||||||
|
searchRequest.Count = Math.Min(searchRequest.Count, MaxMessages);
|
||||||
|
searchRequest.Count = Math.Max(searchRequest.Count, 0);
|
||||||
|
searchRequest.Offset = Math.Max(searchRequest.Offset, 0);
|
||||||
|
|
||||||
|
if (filters.Length > 1)
|
||||||
|
{
|
||||||
|
if (filters[0].ToLower() != "chat")
|
||||||
|
{
|
||||||
|
throw new ArgumentException("Query is not compatible with chat");
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (string filter in filters.Skip(1))
|
||||||
|
{
|
||||||
|
string[] args = filter.Split(' ');
|
||||||
|
|
||||||
|
if (args.Length > 1)
|
||||||
|
{
|
||||||
|
string recombinedArgs = string.Join(' ', args.Skip(1));
|
||||||
|
switch (args[0].ToLower())
|
||||||
|
{
|
||||||
|
case "before":
|
||||||
|
searchRequest.SentBefore = DateTime.Parse(recombinedArgs);
|
||||||
|
break;
|
||||||
|
case "after":
|
||||||
|
searchRequest.SentAfter = DateTime.Parse(recombinedArgs);
|
||||||
|
break;
|
||||||
|
case "server":
|
||||||
|
searchRequest.ServerId = args[1];
|
||||||
|
break;
|
||||||
|
case "client":
|
||||||
|
searchRequest.ClientId = int.Parse(args[1]);
|
||||||
|
break;
|
||||||
|
case "contains":
|
||||||
|
searchRequest.MessageContains = string.Join(' ', args.Skip(1));
|
||||||
|
break;
|
||||||
|
case "sort":
|
||||||
|
searchRequest.Direction = Enum.Parse<SortDirection>(args[1], ignoreCase: true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return searchRequest;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new ArgumentException("No filters specified for chat search");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,11 +53,11 @@ namespace Stats.Helpers
|
|||||||
}
|
}
|
||||||
|
|
||||||
var iqMessages = context.Set<EFClientMessage>()
|
var iqMessages = context.Set<EFClientMessage>()
|
||||||
.Where(message => message.TimeSent < query.SentBeforeDateTime);
|
.Where(message => message.TimeSent < query.SentBefore);
|
||||||
|
|
||||||
if (query.SentAfterDateTime is not null)
|
if (query.SentAfter is not null)
|
||||||
{
|
{
|
||||||
iqMessages = iqMessages.Where(message => message.TimeSent >= query.SentAfterDateTime);
|
iqMessages = iqMessages.Where(message => message.TimeSent >= query.SentAfter);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (query.ClientId is not null)
|
if (query.ClientId is not null)
|
||||||
@ -72,10 +72,7 @@ namespace Stats.Helpers
|
|||||||
|
|
||||||
if (!string.IsNullOrEmpty(query.MessageContains))
|
if (!string.IsNullOrEmpty(query.MessageContains))
|
||||||
{
|
{
|
||||||
iqMessages = query.IsExactMatch
|
iqMessages = iqMessages.Where(message => EF.Functions.Like(message.Message.ToLower(), $"%{query.MessageContains.ToLower()}%"));
|
||||||
? iqMessages.Where(message => message.Message.ToLower() == query.MessageContains.ToLower())
|
|
||||||
: iqMessages.Where(message =>
|
|
||||||
EF.Functions.Like(message.Message.ToLower(), $"%{query.MessageContains.ToLower()}%"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var iqResponse = iqMessages
|
var iqResponse = iqMessages
|
||||||
|
@ -469,8 +469,6 @@ public class Plugin : IPluginV2
|
|||||||
ClientId = request.ClientId,
|
ClientId = request.ClientId,
|
||||||
Before = request.Before,
|
Before = request.Before,
|
||||||
SentBefore = request.Before ?? DateTime.UtcNow,
|
SentBefore = request.Before ?? DateTime.UtcNow,
|
||||||
SentAfter = request.After,
|
|
||||||
After = request.After,
|
|
||||||
Count = request.Count,
|
Count = request.Count,
|
||||||
IsProfileMeta = true
|
IsProfileMeta = true
|
||||||
};
|
};
|
||||||
|
@ -56,4 +56,4 @@ Feel free to join the **IW4MAdmin** [Discord](https://discord.gg/ZZFK5p3)
|
|||||||
If you come across an issue, bug, or feature request please post an [issue](https://github.com/RaidMax/IW4M-Admin/issues)
|
If you come across an issue, bug, or feature request please post an [issue](https://github.com/RaidMax/IW4M-Admin/issues)
|
||||||
|
|
||||||
|
|
||||||
#### Explore the [wiki](https://git.rimmyscorner.com/Parasyn/IW4M-Admin/wiki) to find more information.
|
#### Explore the [wiki](https://github.com/RaidMax/IW4M-Admin/wiki) to find more information.
|
||||||
|
@ -179,7 +179,6 @@ namespace SharedLibraryCore
|
|||||||
server.Reports.Count(report => DateTime.UtcNow - report.ReportedOn <= TimeSpan.FromHours(24)));
|
server.Reports.Count(report => DateTime.UtcNow - report.ReportedOn <= TimeSpan.FromHours(24)));
|
||||||
ViewBag.PermissionsSet = PermissionsSet;
|
ViewBag.PermissionsSet = PermissionsSet;
|
||||||
ViewBag.Alerts = AlertManager.RetrieveAlerts(Client);
|
ViewBag.Alerts = AlertManager.RetrieveAlerts(Client);
|
||||||
ViewBag.Manager = Manager;
|
|
||||||
|
|
||||||
base.OnActionExecuting(context);
|
base.OnActionExecuting(context);
|
||||||
}
|
}
|
||||||
|
@ -206,7 +206,7 @@ namespace SharedLibraryCore.Configuration
|
|||||||
: ManualWebfrontUrl;
|
: ManualWebfrontUrl;
|
||||||
|
|
||||||
[ConfigurationIgnore] public bool IgnoreServerConnectionLost { get; set; }
|
[ConfigurationIgnore] public bool IgnoreServerConnectionLost { get; set; }
|
||||||
[ConfigurationIgnore] public Uri MasterUrl { get; set; } = new("https://master.iw4.zip");
|
[ConfigurationIgnore] public Uri MasterUrl { get; set; } = new("http://api.raidmax.org:5000");
|
||||||
|
|
||||||
public IBaseConfiguration Generate()
|
public IBaseConfiguration Generate()
|
||||||
{
|
{
|
||||||
|
@ -67,7 +67,7 @@ namespace SharedLibraryCore.Configuration.Validation
|
|||||||
|
|
||||||
RuleFor(_app => _app.MasterUrl)
|
RuleFor(_app => _app.MasterUrl)
|
||||||
.NotNull()
|
.NotNull()
|
||||||
.Must(_url => _url != null && (_url.Scheme == Uri.UriSchemeHttp || _url.Scheme == Uri.UriSchemeHttps));
|
.Must(_url => _url != null && _url.Scheme == Uri.UriSchemeHttp);
|
||||||
|
|
||||||
RuleFor(_app => _app.CommandPrefix)
|
RuleFor(_app => _app.CommandPrefix)
|
||||||
.NotEmpty();
|
.NotEmpty();
|
||||||
|
@ -117,9 +117,6 @@ namespace SharedLibraryCore.Database.Models
|
|||||||
[NotMapped] public TeamType Team { get; set; }
|
[NotMapped] public TeamType Team { get; set; }
|
||||||
[NotMapped] public string TeamName { get; set; }
|
[NotMapped] public string TeamName { get; set; }
|
||||||
|
|
||||||
[NotMapped]
|
|
||||||
public string TimeSinceLastConnectionString => (DateTime.UtcNow - LastConnection).HumanizeForCurrentCulture();
|
|
||||||
|
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
// this is kinda dirty, but I need localizable level names
|
// this is kinda dirty, but I need localizable level names
|
||||||
public ClientPermission ClientPermission => new ClientPermission
|
public ClientPermission ClientPermission => new ClientPermission
|
||||||
|
@ -35,8 +35,7 @@ namespace SharedLibraryCore
|
|||||||
T7 = 8,
|
T7 = 8,
|
||||||
SHG1 = 9,
|
SHG1 = 9,
|
||||||
CSGO = 10,
|
CSGO = 10,
|
||||||
H1 = 11,
|
H1 = 11
|
||||||
L4D2 = 12
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// only here for performance
|
// only here for performance
|
||||||
|
@ -50,8 +50,8 @@ namespace SharedLibraryCore
|
|||||||
public static char[] DirectorySeparatorChars = { '\\', '/' };
|
public static char[] DirectorySeparatorChars = { '\\', '/' };
|
||||||
public static char CommandPrefix { get; set; } = '!';
|
public static char CommandPrefix { get; set; } = '!';
|
||||||
|
|
||||||
public static string ToStandardFormat(this DateTime? time) => time?.ToString("yyyy-MM-dd HH:mm:ss UTC");
|
public static string ToStandardFormat(this DateTime? time) => time?.ToString("yyyy-MM-dd H:mm:ss UTC");
|
||||||
public static string ToStandardFormat(this DateTime time) => time.ToString("yyyy-MM-dd HH:mm:ss UTC");
|
public static string ToStandardFormat(this DateTime time) => time.ToString("yyyy-MM-dd H:mm:ss UTC");
|
||||||
|
|
||||||
public static EFClient IW4MAdminClient(Server server = null)
|
public static EFClient IW4MAdminClient(Server server = null)
|
||||||
{
|
{
|
||||||
@ -195,7 +195,7 @@ namespace SharedLibraryCore
|
|||||||
}
|
}
|
||||||
|
|
||||||
var output = str;
|
var output = str;
|
||||||
var colorCodeMatches = Regex.Matches(output, @"\(Color::(\w{1,16})\)",
|
var colorCodeMatches = Regex.Matches(output, @"\(Color::(.{1,16})\)",
|
||||||
RegexOptions.IgnoreCase | RegexOptions.Compiled);
|
RegexOptions.IgnoreCase | RegexOptions.Compiled);
|
||||||
foreach (var match in colorCodeMatches.Where(m => m.Success))
|
foreach (var match in colorCodeMatches.Where(m => m.Success))
|
||||||
{
|
{
|
||||||
|
@ -250,7 +250,6 @@ namespace WebfrontCore.Controllers
|
|||||||
ViewBag.Title = Localization["WEBFRONT_SEARCH_RESULTS_TITLE"];
|
ViewBag.Title = Localization["WEBFRONT_SEARCH_RESULTS_TITLE"];
|
||||||
ViewBag.ClientResourceRequest = request;
|
ViewBag.ClientResourceRequest = request;
|
||||||
|
|
||||||
request.RequesterPermission = Client.Level;
|
|
||||||
var response = await _clientResourceHelper.QueryResource(request);
|
var response = await _clientResourceHelper.QueryResource(request);
|
||||||
return request.Offset > 0
|
return request.Offset > 0
|
||||||
? PartialView("Find/_AdvancedFindList", response.Results)
|
? PartialView("Find/_AdvancedFindList", response.Results)
|
||||||
|
@ -17,7 +17,6 @@ using Microsoft.Extensions.Logging;
|
|||||||
using ILogger = Microsoft.Extensions.Logging.ILogger;
|
using ILogger = Microsoft.Extensions.Logging.ILogger;
|
||||||
using Data.Abstractions;
|
using Data.Abstractions;
|
||||||
using Stats.Config;
|
using Stats.Config;
|
||||||
using WebfrontCore.QueryHelpers.Models;
|
|
||||||
|
|
||||||
namespace IW4MAdmin.Plugins.Web.StatsWeb.Controllers
|
namespace IW4MAdmin.Plugins.Web.StatsWeb.Controllers
|
||||||
{
|
{
|
||||||
@ -122,7 +121,7 @@ namespace IW4MAdmin.Plugins.Web.StatsWeb.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("Message/Find")]
|
[HttpGet("Message/Find")]
|
||||||
public async Task<IActionResult> FindMessage([FromQuery] ChatResourceRequest query)
|
public async Task<IActionResult> FindMessage([FromQuery] string query)
|
||||||
{
|
{
|
||||||
ViewBag.Localization = _translationLookup;
|
ViewBag.Localization = _translationLookup;
|
||||||
ViewBag.EnableColorCodes = _manager.GetApplicationSettings().Configuration().EnableColorCodes;
|
ViewBag.EnableColorCodes = _manager.GetApplicationSettings().Configuration().EnableColorCodes;
|
||||||
@ -131,15 +130,53 @@ namespace IW4MAdmin.Plugins.Web.StatsWeb.Controllers
|
|||||||
ViewBag.Title = _translationLookup["WEBFRONT_STATS_MESSAGES_TITLE"];
|
ViewBag.Title = _translationLookup["WEBFRONT_STATS_MESSAGES_TITLE"];
|
||||||
ViewBag.Error = null;
|
ViewBag.Error = null;
|
||||||
ViewBag.IsFluid = true;
|
ViewBag.IsFluid = true;
|
||||||
|
ChatSearchQuery searchRequest = null;
|
||||||
|
|
||||||
var result = query != null ? await _chatResourceQueryHelper.QueryResource(query) : null;
|
try
|
||||||
|
{
|
||||||
|
searchRequest = query.ParseSearchInfo(int.MaxValue, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
catch (ArgumentException e)
|
||||||
|
{
|
||||||
|
_logger.LogWarning(e, "Could not parse chat message search query {query}", query);
|
||||||
|
ViewBag.Error = e;
|
||||||
|
}
|
||||||
|
|
||||||
|
catch (FormatException e)
|
||||||
|
{
|
||||||
|
_logger.LogWarning(e, "Could not parse chat message search query filter format {query}", query);
|
||||||
|
ViewBag.Error = e;
|
||||||
|
}
|
||||||
|
|
||||||
|
var result = searchRequest != null ? await _chatResourceQueryHelper.QueryResource(searchRequest) : null;
|
||||||
return View("~/Views/Client/Message/Find.cshtml", result);
|
return View("~/Views/Client/Message/Find.cshtml", result);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("Message/FindNext")]
|
[HttpGet("Message/FindNext")]
|
||||||
public async Task<IActionResult> FindNextMessages(ChatResourceRequest query)
|
public async Task<IActionResult> FindNextMessages([FromQuery] string query, [FromQuery] int count,
|
||||||
|
[FromQuery] int offset)
|
||||||
{
|
{
|
||||||
var result = await _chatResourceQueryHelper.QueryResource(query);
|
ChatSearchQuery searchRequest;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
searchRequest = query.ParseSearchInfo(count, offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
catch (ArgumentException e)
|
||||||
|
{
|
||||||
|
_logger.LogWarning(e, "Could not parse chat message search query {query}", query);
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
|
||||||
|
catch (FormatException e)
|
||||||
|
{
|
||||||
|
_logger.LogWarning(e, "Could not parse chat message search query filter format {query}", query);
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
|
||||||
|
var result = await _chatResourceQueryHelper.QueryResource(searchRequest);
|
||||||
return PartialView("~/Views/Client/Message/_Item.cshtml", result.Results);
|
return PartialView("~/Views/Client/Message/_Item.cshtml", result.Results);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,9 +0,0 @@
|
|||||||
using Stats.Dtos;
|
|
||||||
|
|
||||||
namespace WebfrontCore.QueryHelpers.Models;
|
|
||||||
|
|
||||||
public class ChatResourceRequest : ChatSearchQuery
|
|
||||||
{
|
|
||||||
public bool HasData => !string.IsNullOrEmpty(MessageContains) || !string.IsNullOrEmpty(ServerId) ||
|
|
||||||
ClientId is not null || SentAfterDateTime is not null;
|
|
||||||
}
|
|
@ -16,9 +16,4 @@ public class ClientResourceRequest : ClientPaginationRequest
|
|||||||
public EFClient.Permission? ClientLevel { get; set; }
|
public EFClient.Permission? ClientLevel { get; set; }
|
||||||
public Reference.Game? GameName { get; set; }
|
public Reference.Game? GameName { get; set; }
|
||||||
public bool IncludeGeolocationData { get; set; } = true;
|
public bool IncludeGeolocationData { get; set; } = true;
|
||||||
|
|
||||||
public EFClient.Permission RequesterPermission { get; set; } = EFClient.Permission.User;
|
|
||||||
|
|
||||||
public bool HasData => !string.IsNullOrEmpty(ClientName) || !string.IsNullOrEmpty(ClientIp) ||
|
|
||||||
!string.IsNullOrEmpty(ClientGuid) || ClientLevel is not null || GameName is not null;
|
|
||||||
}
|
}
|
||||||
|
@ -26,14 +26,14 @@ else
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<div id="loaderLoad" class="mt-10 m-auto text-center">
|
<div id="loaderLoad" class="mt-10 m-auto text-center d-none d-lg-block">
|
||||||
<i class="loader-load-more oi oi-chevron-bottom"></i>
|
<i class="loader-load-more oi oi-chevron-bottom"></i>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@section scripts {
|
@section scripts {
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
initLoader(`/Message/FindNext${window.location.search}`, '#message_table_body', @Model.RetrievedResultCount, 30);
|
initLoader('/Message/FindNext?query=@ViewBag.Query', '#message_table_body', @Model.RetrievedResultCount, @ViewBag.QueryLimit);
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
}
|
}
|
||||||
|
@ -1,88 +0,0 @@
|
|||||||
@using WebfrontCore.QueryHelpers.Models
|
|
||||||
@using SharedLibraryCore.Interfaces
|
|
||||||
@using System.Globalization
|
|
||||||
@using Microsoft.AspNetCore.Mvc.TagHelpers
|
|
||||||
@model string
|
|
||||||
@{
|
|
||||||
var existingChatFilter = ViewBag.Query as ChatResourceRequest;
|
|
||||||
var manager = ViewBag.Manager as IManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
<div id="chatSearchWrapper@(Model)" data-has-data="@(existingChatFilter?.HasData ?? false)" >
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="messageContains@(Model)">@ViewBag.Localization["WEBFRONT_ACTION_LABEL_MESSAGE"]</label>
|
|
||||||
<div class="d-flex">
|
|
||||||
<input type="text" class="form-control" name="messageContains" id="messageContains@(Model)}"
|
|
||||||
placeholder="Contains" value="@existingChatFilter?.MessageContains"/>
|
|
||||||
<div class="custom-control ml-10 align-self-center">
|
|
||||||
<div class="custom-switch">
|
|
||||||
@if (existingChatFilter?.IsExactMatch ?? false)
|
|
||||||
{
|
|
||||||
<input type="checkbox" id="isExactMatch@(Model)" name="isExactMatch" value="true"
|
|
||||||
checked="checked">
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
<input type="checkbox" id="isExactMatch@(Model)" name="isExactMatch" value="true">
|
|
||||||
}
|
|
||||||
|
|
||||||
<label for="isExactMatch@(Model)">@ViewBag.Localization["WEBFRONT_ADVANCED_SEARCH_LABEL_EXACT"]</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="serverId@(Model)" class="w-quarter">@ViewBag.Localization["WEBFRONT_BAN_MGMT_FORM_ID"]</label>
|
|
||||||
<label for="clientId@(Model)" class="">@ViewBag.Localization["WEBFRONT_CONTEXT_MENU_GLOBAL_SERVER"]</label>
|
|
||||||
|
|
||||||
<div class="d-flex">
|
|
||||||
<input type="text" class="form-control w-quarter" name="clientId" id="clientId@(Model)}"
|
|
||||||
placeholder="Id" value="@existingChatFilter?.ClientId"/>
|
|
||||||
<select class="form-control w-three-quarter ml-10" id="serverId@(Model)" name="serverId">
|
|
||||||
<option value="">@ViewBag.Localization["WEBFRONT_ADVANCED_SEARCH_SELECT_PERMISSIONS_ANY"]</option>
|
|
||||||
@foreach (var server in manager!.GetServers())
|
|
||||||
{
|
|
||||||
<option value="@server.Id" selected="@(server.Id == existingChatFilter?.ServerId)">
|
|
||||||
[@server.GameName.ToString()] @server.ServerName.StripColors()
|
|
||||||
</option>
|
|
||||||
}
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="sentAfter@(Model)">@ViewBag.Localization["WEBFRONT_ADVANCED_SEARCH_LABEL_SENT_AFTER"]</label>
|
|
||||||
@{
|
|
||||||
var afterDate = existingChatFilter?.SentAfterDateTime ?? DateTime.UtcNow.AddHours(-1);
|
|
||||||
}
|
|
||||||
<div class="d-flex">
|
|
||||||
<input type="text" class="form-control date-picker-input w-half" name="sentAfter"
|
|
||||||
id="sentAfter@(Model)" data-date="@afterDate.ToString("s", CultureInfo.InvariantCulture)"
|
|
||||||
value="@afterDate.ToString("s", CultureInfo.InvariantCulture)"/>
|
|
||||||
<input type="time" class="form-control w-half ml-10" name="sentAfterTime"
|
|
||||||
id="sentAfterTime@(Model)"
|
|
||||||
style="color-scheme: dark;"
|
|
||||||
value="@afterDate.ToString("HH:mm")"/>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="sentAfter@(Model)">@ViewBag.Localization["WEBFRONT_ADVANCED_SEARCH_LABEL_SENT_BEFORE"]</label>
|
|
||||||
@{
|
|
||||||
var beforeDate = existingChatFilter?.SentBeforeDateTime ?? DateTime.UtcNow;
|
|
||||||
}
|
|
||||||
<div class="d-flex">
|
|
||||||
<input type="text" class="form-control date-picker-input w-half" name="sentBefore"
|
|
||||||
id="sentBefore@(Model)" data-date="@beforeDate.ToString("s", CultureInfo.InvariantCulture)"
|
|
||||||
value="@beforeDate.ToString("s", CultureInfo.InvariantCulture)"/>
|
|
||||||
<input type="time" class="form-control w-half ml-10" name="sentBeforeTime"
|
|
||||||
id="sentBeforeTime@(Model)"
|
|
||||||
style="color-scheme: dark;"
|
|
||||||
value="@beforeDate.ToString("HH:mm")"/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<input type="submit" class="btn btn-primary" value="@ViewBag.Localization["WEBFRONT_ADVANCED_SEARCH_BUTTON_SUBMIT"]"/>
|
|
||||||
</div>
|
|
@ -1,116 +0,0 @@
|
|||||||
@using WebfrontCore.QueryHelpers.Models
|
|
||||||
@using System.Globalization
|
|
||||||
@using Data.Models
|
|
||||||
@using Data.Models.Client
|
|
||||||
@using Microsoft.AspNetCore.Mvc.TagHelpers
|
|
||||||
@using SharedLibraryCore.Dtos
|
|
||||||
@model string
|
|
||||||
@{
|
|
||||||
var existingClientFilter = ViewBag.ClientResourceRequest as ClientResourceRequest;
|
|
||||||
}
|
|
||||||
|
|
||||||
<div id="clientSearchWrapper@(Model)" data-has-data="@(existingClientFilter?.HasData ?? false)" >
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="clientName@(Model)">@ViewBag.Localization["WEBFRONT_ADVANCED_SEARCH_LABEL_NAME"]</label>
|
|
||||||
<div class="d-flex">
|
|
||||||
<input type="text" class="form-control" name="clientName" id="clientName@(Model)"
|
|
||||||
placeholder="Unknown Soldier" value="@existingClientFilter?.ClientName"/>
|
|
||||||
<div class="custom-control ml-10 align-self-center">
|
|
||||||
<div class="custom-switch">
|
|
||||||
@if (existingClientFilter?.IsExactClientName ?? false)
|
|
||||||
{
|
|
||||||
<input type="checkbox" id="isExactClientName@(Model)" name="isExactClientName" value="true"
|
|
||||||
checked="checked">
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
<input type="checkbox" id="isExactClientName@(Model)" name="isExactClientName" value="true">
|
|
||||||
}
|
|
||||||
<label for="isExactClientName@(Model)">@ViewBag.Localization["WEBFRONT_ADVANCED_SEARCH_LABEL_EXACT"]</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="clientIP@(Model)">@ViewBag.Localization["WEBFRONT_ADVANCED_SEARCH_LABEL_IP"]</label>
|
|
||||||
<div class="d-flex">
|
|
||||||
<input type="text" class="form-control" name="clientIP" id="clientIP@(Model)" placeholder="1.1.1.1"
|
|
||||||
value="@existingClientFilter?.ClientIp">
|
|
||||||
<div class="custom-control ml-10 align-self-center">
|
|
||||||
<div class="custom-switch">
|
|
||||||
@if (existingClientFilter?.IsExactClientIp ?? false)
|
|
||||||
{
|
|
||||||
<input type="checkbox" id="isExactClientIP@(Model)" name="isExactClientIP" value="true"
|
|
||||||
checked="checked">
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
<input type="checkbox" id="isExactClientIP@(Model)" name="isExactClientIP" value="true">
|
|
||||||
}
|
|
||||||
<label for="isExactClientIP@(Model)">@ViewBag.Localization["WEBFRONT_ADVANCED_SEARCH_LABEL_EXACT"]</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="clientGuid@(Model)">GUID <span class="text-primary">•</span> XUID <span class="text-primary">•</span> NetworkID</label>
|
|
||||||
<input type="text" class="form-control" name="clientGuid" id="clientGuid@(Model)"
|
|
||||||
placeholder="110000100000001" value="@existingClientFilter?.ClientGuid"/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="clientLevel@(Model)" class="w-half">@ViewBag.Localization["WEBFRONT_ADVANCED_SEARCH_LABEL_PERMISSION"]</label>
|
|
||||||
<label for="clientGameName@(Model)">@ViewBag.Localization["WEBFRONT_ADVANCED_SEARCH_LABEL_GAME"]</label>
|
|
||||||
|
|
||||||
<div class="d-flex">
|
|
||||||
<select class="form-control w-half" id="clientLevel@(Model)" name="clientLevel">
|
|
||||||
<option value="">@ViewBag.Localization["WEBFRONT_ADVANCED_SEARCH_SELECT_PERMISSIONS_ANY"]</option>
|
|
||||||
@foreach (EFClient.Permission permission in Enum.GetValues(typeof(EFClient.Permission)))
|
|
||||||
{
|
|
||||||
<option value="@((int)permission)" selected="@(permission == existingClientFilter?.ClientLevel)">
|
|
||||||
@permission.ToLocalizedLevelName()
|
|
||||||
</option>
|
|
||||||
}
|
|
||||||
</select>
|
|
||||||
<select class="form-control w-half ml-10" id="clientGameName@(Model)" name="gameName">
|
|
||||||
<option value="">@ViewBag.Localization["WEBFRONT_ADVANCED_SEARCH_SELECT_PERMISSIONS_ANY"]</option>
|
|
||||||
@foreach (Reference.Game game in Enum.GetValues(typeof(Reference.Game)))
|
|
||||||
{
|
|
||||||
<option value="@((int)game)" selected="@(game == existingClientFilter?.GameName)">
|
|
||||||
@ViewBag.Localization["GAME_" + game]
|
|
||||||
</option>
|
|
||||||
}
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="clientConnected@(Model)">@ViewBag.Localization["WEBFRONT_ADVANCED_SEARCH_LABEL_CONNECTED_SINCE"]</label>
|
|
||||||
<div class="d-flex">
|
|
||||||
@{ var presetDate = (existingClientFilter?.ClientConnected ?? DateTime.UtcNow.AddYears(-1)).ToString("s", CultureInfo.InvariantCulture); }
|
|
||||||
<input type="text" class="form-control date-picker-input w-half" name="clientConnected"
|
|
||||||
id="clientConnected@(Model)" data-date="@presetDate"
|
|
||||||
value="@presetDate"/>
|
|
||||||
|
|
||||||
<div class="custom-control ml-10 align-self-center">
|
|
||||||
<div class="custom-switch">
|
|
||||||
@if ((existingClientFilter?.Direction ?? SortDirection.Descending) is SortDirection.Descending)
|
|
||||||
{
|
|
||||||
<input type="checkbox" id="resultOrder@(Model)" name="direction"
|
|
||||||
value="@((int)SortDirection.Ascending)">
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
<input type="checkbox" id="resultOrder@(Model)" name="direction"
|
|
||||||
value="@((int)SortDirection.Ascending)" checked="checked">
|
|
||||||
}
|
|
||||||
<label for="resultOrder@(Model)">@ViewBag.Localization["WEBFRONT_ADVANCED_SEARCH_LABEL_OLDEST_FIRST"]</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<input type="submit" class="btn btn-primary" value="@ViewBag.Localization["WEBFRONT_ADVANCED_SEARCH_BUTTON_SUBMIT"]"/>
|
|
||||||
</div>
|
|
@ -1,21 +1,126 @@
|
|||||||
|
@using Data.Models.Client
|
||||||
|
@using SharedLibraryCore.Dtos
|
||||||
|
@using WebfrontCore.QueryHelpers.Models
|
||||||
|
@using Data.Models
|
||||||
|
@using System.Globalization
|
||||||
@model string
|
@model string
|
||||||
|
@{
|
||||||
|
var existingClientFilter = ViewBag.ClientResourceRequest as ClientResourceRequest;
|
||||||
|
}
|
||||||
<h6 class="dropdown-header">@ViewBag.Localization["WEBFRONT_ADVANCED_SEARCH_TITLE"]</h6>
|
<h6 class="dropdown-header">@ViewBag.Localization["WEBFRONT_ADVANCED_SEARCH_TITLE"]</h6>
|
||||||
<div class="dropdown-divider"></div>
|
<div class="dropdown-divider"></div>
|
||||||
<div class="dropdown-content">
|
<div class="dropdown-content">
|
||||||
|
<form asp-controller="Client" asp-action="AdvancedFind" method="get" id="advancedSearchDropdownContent@(Model)" onsubmit="showLoader()">
|
||||||
<div class="form-group" id="searchTypeSelectorParent">
|
<div class="form-group">
|
||||||
<label for="searchType@(Model)">@ViewBag.Localization["WEBFRONT_ADVANCED_SEARCH_LABEL_FOR"]</label>
|
<label for="searchType@(Model)">@ViewBag.Localization["WEBFRONT_ADVANCED_SEARCH_LABEL_FOR"]</label>
|
||||||
<br/>
|
<br/>
|
||||||
<select class="form-control" id="searchType@(Model)" name="searchType">
|
<select class="form-control" id="searchType@(Model)" name="searchType" disabled="disabled">
|
||||||
<option value="client">@ViewBag.Localization["WEBFRONT_ADVANCED_SEARCH_SELECT_TYPE_PLAYERS"]</option>
|
<option value="client">@ViewBag.Localization["WEBFRONT_ADVANCED_SEARCH_SELECT_TYPE_PLAYERS"]</option>
|
||||||
<option value="chat">@ViewBag.Localization["WEBFRONT_ADVANCED_SEARCH_SELECT_TYPE_CHAT"]</option>
|
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<form asp-controller="Client" asp-action="AdvancedFind" method="get" id="advancedSearchDropdownContent@(Model)" onsubmit="showLoader()">
|
|
||||||
<partial name="Search/_ClientSearch.cshtml" model="@Model"/>
|
<div class="form-group">
|
||||||
</form>
|
<label for="clientName@(Model)">@ViewBag.Localization["WEBFRONT_ADVANCED_SEARCH_LABEL_NAME"]</label>
|
||||||
<form asp-controller="Stats" asp-action="FindMessage" method="get" onsubmit="showLoader()">
|
<div class="d-flex">
|
||||||
<partial name="Search/_ChatSearch.cshtml" model="@Model"/>
|
<input type="text" class="form-control" name="clientName" id="clientName@(Model)"
|
||||||
|
placeholder="Unknown Soldier" value="@existingClientFilter?.ClientName"/>
|
||||||
|
<div class="custom-control ml-10 align-self-center">
|
||||||
|
<div class="custom-switch">
|
||||||
|
@if (existingClientFilter?.IsExactClientName ?? false)
|
||||||
|
{
|
||||||
|
<input type="checkbox" id="isExactClientName@(Model)" name="isExactClientName" value="true"
|
||||||
|
checked="checked">
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<input type="checkbox" id="isExactClientName@(Model)" name="isExactClientName" value="true">
|
||||||
|
}
|
||||||
|
<label for="isExactClientName@(Model)">@ViewBag.Localization["WEBFRONT_ADVANCED_SEARCH_LABEL_EXACT"]</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="clientIP@(Model)">@ViewBag.Localization["WEBFRONT_ADVANCED_SEARCH_LABEL_IP"]</label>
|
||||||
|
<div class="d-flex">
|
||||||
|
<input type="text" class="form-control" name="clientIP" id="clientIP@(Model)" placeholder="1.1.1.1"
|
||||||
|
value="@existingClientFilter?.ClientIp">
|
||||||
|
<div class="custom-control ml-10 align-self-center">
|
||||||
|
<div class="custom-switch">
|
||||||
|
@if (existingClientFilter?.IsExactClientIp ?? false)
|
||||||
|
{
|
||||||
|
<input type="checkbox" id="isExactClientIP@(Model)" name="isExactClientIP" value="true"
|
||||||
|
checked="checked">
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<input type="checkbox" id="isExactClientIP@(Model)" name="isExactClientIP" value="true">
|
||||||
|
}
|
||||||
|
<label for="isExactClientIP@(Model)">@ViewBag.Localization["WEBFRONT_ADVANCED_SEARCH_LABEL_EXACT"]</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="clientGuid@(Model)">GUID <span class="text-primary">•</span> XUID <span class="text-primary">•</span> NetworkID</label>
|
||||||
|
<input type="text" class="form-control" name="clientGuid" id="clientGuid@(Model)"
|
||||||
|
placeholder="110000100000001" value="@existingClientFilter?.ClientGuid"/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="clientLevel@(Model)" class="w-half">@ViewBag.Localization["WEBFRONT_ADVANCED_SEARCH_LABEL_PERMISSION"]</label>
|
||||||
|
<label for="clientGameName@(Model)">@ViewBag.Localization["WEBFRONT_ADVANCED_SEARCH_LABEL_GAME"]</label>
|
||||||
|
|
||||||
|
<div class="d-flex">
|
||||||
|
<select class="form-control w-half" id="clientLevel@(Model)" name="clientLevel">
|
||||||
|
<option value="">@ViewBag.Localization["WEBFRONT_ADVANCED_SEARCH_SELECT_PERMISSIONS_ANY"]</option>
|
||||||
|
@foreach (EFClient.Permission permission in Enum.GetValues(typeof(EFClient.Permission)))
|
||||||
|
{
|
||||||
|
<option value="@((int)permission)" selected="@(permission == existingClientFilter?.ClientLevel)">
|
||||||
|
@permission.ToLocalizedLevelName()
|
||||||
|
</option>
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
<select class="form-control w-half ml-10" id="clientGameName@(Model)" name="gameName">
|
||||||
|
<option value="">@ViewBag.Localization["WEBFRONT_ADVANCED_SEARCH_SELECT_PERMISSIONS_ANY"]</option>
|
||||||
|
@foreach (Reference.Game game in Enum.GetValues(typeof(Reference.Game)))
|
||||||
|
{
|
||||||
|
<option value="@((int)game)" selected="@(game == existingClientFilter?.GameName)">
|
||||||
|
@ViewBag.Localization["GAME_" + game]
|
||||||
|
</option>
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="clientConnected@(Model)">@ViewBag.Localization["WEBFRONT_ADVANCED_SEARCH_LABEL_CONNECTED_SINCE"]</label>
|
||||||
|
<div class="d-flex">
|
||||||
|
@{ var presetDate = (existingClientFilter?.ClientConnected ?? DateTime.UtcNow.AddYears(-1)).ToString("s", CultureInfo.InvariantCulture); }
|
||||||
|
<input type="text" class="form-control date-picker-input w-half" name="clientConnected"
|
||||||
|
id="clientConnected@(Model)" data-date="@presetDate"
|
||||||
|
value="@presetDate"/>
|
||||||
|
|
||||||
|
<div class="custom-control ml-10 align-self-center">
|
||||||
|
<div class="custom-switch">
|
||||||
|
@if ((existingClientFilter?.Direction ?? SortDirection.Descending) is SortDirection.Descending)
|
||||||
|
{
|
||||||
|
<input type="checkbox" id="resultOrder@(Model)" name="direction"
|
||||||
|
value="@((int)SortDirection.Ascending)">
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<input type="checkbox" id="resultOrder@(Model)" name="direction"
|
||||||
|
value="@((int)SortDirection.Ascending)" checked="checked">
|
||||||
|
}
|
||||||
|
<label for="resultOrder@(Model)">@ViewBag.Localization["WEBFRONT_ADVANCED_SEARCH_LABEL_OLDEST_FIRST"]</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<input type="submit" class="btn btn-primary" value="@ViewBag.Localization["WEBFRONT_ADVANCED_SEARCH_BUTTON_SUBMIT"]"/>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,4 +1,28 @@
|
|||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
|
$('.form-inline').submit(function (e) {
|
||||||
|
const id = $(e.currentTarget).find('input');
|
||||||
|
if ($(id).val().length < 3) {
|
||||||
|
e.preventDefault();
|
||||||
|
$(id)
|
||||||
|
.addClass('input-text-danger')
|
||||||
|
.delay(25)
|
||||||
|
.queue(function () {
|
||||||
|
$(this).addClass('input-border-transition').dequeue();
|
||||||
|
})
|
||||||
|
.delay(1000)
|
||||||
|
.queue(function () {
|
||||||
|
$(this).removeClass('input-text-danger').dequeue();
|
||||||
|
})
|
||||||
|
.delay(500)
|
||||||
|
.queue(function () {
|
||||||
|
$(this).removeClass('input-border-transition').dequeue();
|
||||||
|
});
|
||||||
|
} else if ($(id).val().startsWith("chat|")) {
|
||||||
|
e.preventDefault();
|
||||||
|
window.location = "/Message/Find?query=" + $(id).val();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
$('.date-picker-input').each((index, selector) => {
|
$('.date-picker-input').each((index, selector) => {
|
||||||
new Datepicker(selector, {
|
new Datepicker(selector, {
|
||||||
buttonClass: 'btn',
|
buttonClass: 'btn',
|
||||||
@ -7,37 +31,5 @@
|
|||||||
prevArrow: '<',
|
prevArrow: '<',
|
||||||
orientation: 'auto top'
|
orientation: 'auto top'
|
||||||
});
|
});
|
||||||
});
|
})
|
||||||
|
|
||||||
const clientSearchWrapper = $('*[id^="clientSearchWrapper"]');
|
|
||||||
const chatSearchWrapper = $('*[id^="chatSearchWrapper"]');
|
|
||||||
const searchTypeSelector = $('#searchTypeSelectorParent select');
|
|
||||||
let isClients = false;
|
|
||||||
|
|
||||||
searchTypeSelector.on('change', function () {
|
|
||||||
if (isClients) {
|
|
||||||
clientSearchWrapper.removeClass('d-none');
|
|
||||||
chatSearchWrapper.addClass('d-none');
|
|
||||||
} else {
|
|
||||||
chatSearchWrapper.removeClass('d-none');
|
|
||||||
clientSearchWrapper.addClass('d-none');
|
|
||||||
}
|
|
||||||
isClients = !isClients;
|
|
||||||
});
|
|
||||||
|
|
||||||
const isDefault = clientSearchWrapper.data('has-data') !== 'True' && chatSearchWrapper.data('has-data') !== 'True';
|
|
||||||
|
|
||||||
if (isDefault) {
|
|
||||||
isClients = false;
|
|
||||||
searchTypeSelector.val('client').change();
|
|
||||||
} else {
|
|
||||||
if (clientSearchWrapper.data('has-data') === 'True') {
|
|
||||||
isClients = false;
|
|
||||||
searchTypeSelector.val('client').change();
|
|
||||||
}
|
|
||||||
if (chatSearchWrapper.data('has-data') === 'True') {
|
|
||||||
isClients = true;
|
|
||||||
searchTypeSelector.val('chat').change();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 2.6 KiB |
Loading…
Reference in New Issue
Block a user