add join team and map change events to CSGO parser

This commit is contained in:
RaidMax 2022-03-28 18:05:18 -05:00
parent 770785e979
commit eafd7cb530
5 changed files with 48 additions and 9 deletions

View File

@ -97,7 +97,8 @@ namespace IW4MAdmin.Application.EventParsers
{Configuration.Say, GameEvent.EventType.Say}, {Configuration.Say, GameEvent.EventType.Say},
{Configuration.Kill, GameEvent.EventType.Kill}, {Configuration.Kill, GameEvent.EventType.Kill},
{Configuration.MapChange, GameEvent.EventType.MapChange}, {Configuration.MapChange, GameEvent.EventType.MapChange},
{Configuration.MapEnd, GameEvent.EventType.MapEnd} {Configuration.MapEnd, GameEvent.EventType.MapEnd},
{Configuration.JoinTeam, GameEvent.EventType.JoinTeam}
}; };
_eventTypeMap = new Dictionary<string, GameEvent.EventType> _eventTypeMap = new Dictionary<string, GameEvent.EventType>
@ -107,8 +108,8 @@ namespace IW4MAdmin.Application.EventParsers
{"K", GameEvent.EventType.Kill}, {"K", GameEvent.EventType.Kill},
{"D", GameEvent.EventType.Damage}, {"D", GameEvent.EventType.Damage},
{"J", GameEvent.EventType.PreConnect}, {"J", GameEvent.EventType.PreConnect},
{"JT", GameEvent.EventType.JoinTeam }, {"JT", GameEvent.EventType.JoinTeam},
{"Q", GameEvent.EventType.PreDisconnect}, {"Q", GameEvent.EventType.PreDisconnect}
}; };
} }
@ -340,6 +341,11 @@ namespace IW4MAdmin.Application.EventParsers
var originName = match.Values[Configuration.JoinTeam.GroupMapping[ParserRegex.GroupType.OriginName]]; var originName = match.Values[Configuration.JoinTeam.GroupMapping[ParserRegex.GroupType.OriginName]];
var team = match.Values[Configuration.JoinTeam.GroupMapping[ParserRegex.GroupType.OriginTeam]]; var team = match.Values[Configuration.JoinTeam.GroupMapping[ParserRegex.GroupType.OriginTeam]];
if (Configuration.TeamMapping.ContainsKey(team))
{
team = Configuration.TeamMapping[team].ToString();
}
var networkId = originIdString.IsBotGuid() ? var networkId = originIdString.IsBotGuid() ?
originName.GenerateGuidFromString() : originName.GenerateGuidFromString() :
originIdString.ConvertGuidToLong(Configuration.GuidNumberStyle); originIdString.ConvertGuidToLong(Configuration.GuidNumberStyle);

View File

@ -1,6 +1,8 @@
using SharedLibraryCore.Interfaces; using System.Collections.Generic;
using SharedLibraryCore.Interfaces;
using System.Globalization; using System.Globalization;
using SharedLibraryCore; using SharedLibraryCore;
using SharedLibraryCore.Database.Models;
namespace IW4MAdmin.Application.EventParsers namespace IW4MAdmin.Application.EventParsers
{ {
@ -23,6 +25,8 @@ namespace IW4MAdmin.Application.EventParsers
public ParserRegex MapEnd { get; set; } public ParserRegex MapEnd { get; set; }
public NumberStyles GuidNumberStyle { get; set; } = NumberStyles.HexNumber; public NumberStyles GuidNumberStyle { get; set; } = NumberStyles.HexNumber;
public Dictionary<string, EFClient.TeamType> TeamMapping { get; set; } = new();
public DynamicEventParserConfiguration(IParserRegexFactory parserRegexFactory) public DynamicEventParserConfiguration(IParserRegexFactory parserRegexFactory)
{ {
Say = parserRegexFactory.CreateParserRegex(); Say = parserRegexFactory.CreateParserRegex();

View File

@ -3,7 +3,7 @@ let eventParser;
const plugin = { const plugin = {
author: 'RaidMax', author: 'RaidMax',
version: 0.4, version: 0.5,
name: 'CS:GO Parser', name: 'CS:GO Parser',
engine: 'Source', engine: 'Source',
isParser: true, isParser: true,
@ -105,6 +105,17 @@ const plugin = {
eventParser.Configuration.Kill.AddMapping(8, 8); eventParser.Configuration.Kill.AddMapping(8, 8);
eventParser.Configuration.Kill.AddMapping(9, 9); eventParser.Configuration.Kill.AddMapping(9, 9);
eventParser.Configuration.Kill.AddMapping(12, 10); 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:'; eventParser.Configuration.Time.Pattern = '^L [01]\\d/[0-3]\\d/\\d+ - [0-2]\\d:[0-5]\\d:[0-5]\\d:';
@ -120,4 +131,4 @@ const plugin = {
onTickAsync: function (server) { onTickAsync: function (server) {
} }
}; };

View File

@ -3,7 +3,7 @@ let eventParser;
const plugin = { const plugin = {
author: 'RaidMax', author: 'RaidMax',
version: 0.5, version: 0.6,
name: 'CS:GO (SourceMod) Parser', name: 'CS:GO (SourceMod) Parser',
engine: 'Source', engine: 'Source',
isParser: true, isParser: true,
@ -105,7 +105,18 @@ const plugin = {
eventParser.Configuration.Kill.AddMapping(8, 8); eventParser.Configuration.Kill.AddMapping(8, 8);
eventParser.Configuration.Kill.AddMapping(9, 9); eventParser.Configuration.Kill.AddMapping(9, 9);
eventParser.Configuration.Kill.AddMapping(12, 10); 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:'; eventParser.Configuration.Time.Pattern = '^L [01]\\d/[0-3]\\d/\\d+ - [0-2]\\d:[0-5]\\d:[0-5]\\d:';
rconParser.Version = 'CSGOSM'; rconParser.Version = 'CSGOSM';
@ -120,4 +131,4 @@ const plugin = {
onTickAsync: function (server) { onTickAsync: function (server) {
} }
}; };

View File

@ -1,4 +1,6 @@
using System.Globalization; using System.Collections.Generic;
using System.Globalization;
using SharedLibraryCore.Database.Models;
namespace SharedLibraryCore.Interfaces namespace SharedLibraryCore.Interfaces
{ {
@ -63,5 +65,10 @@ namespace SharedLibraryCore.Interfaces
/// indicates the format expected for parsed guids /// indicates the format expected for parsed guids
/// </summary> /// </summary>
NumberStyles GuidNumberStyle { get; set; } NumberStyles GuidNumberStyle { get; set; }
/// <summary>
/// maps the team code name to a type type eg "CT" -> Allies
/// </summary>
Dictionary<string, EFClient.TeamType> TeamMapping { get; }
} }
} }