mirror of
https://github.com/RaidMax/IW4M-Admin.git
synced 2025-06-10 15:20:48 -05:00
Added high ping kick functionality to Welcome Plugin
Added response to RCON command if applicable Added more maps into the map config
This commit is contained in:
@ -14,8 +14,8 @@ namespace SharedLibrary
|
||||
Description = D;
|
||||
Alias = A;
|
||||
Permission = P;
|
||||
requiredArgNum = args;
|
||||
needsTarget = nT;
|
||||
RequiredArgumentCount = args;
|
||||
RequiresTarget = nT;
|
||||
}
|
||||
|
||||
//Execute the command
|
||||
@ -24,8 +24,8 @@ namespace SharedLibrary
|
||||
public String Name { get; private set; }
|
||||
public String Description { get; private set; }
|
||||
public String Alias { get; private set; }
|
||||
public int requiredArgNum { get; private set; }
|
||||
public bool needsTarget { get; private set; }
|
||||
public int RequiredArgumentCount { get; private set; }
|
||||
public bool RequiresTarget { get; private set; }
|
||||
public Player.Permission Permission { get; private set; }
|
||||
}
|
||||
}
|
||||
|
@ -496,9 +496,9 @@ namespace SharedLibrary.Commands
|
||||
public override async Task ExecuteAsync(Event E)
|
||||
{
|
||||
if (E.Owner.Reload())
|
||||
await E.Origin.Tell("Sucessfully reloaded configs!");
|
||||
await E.Origin.Tell("Sucessfully reloaded configuration files");
|
||||
else
|
||||
await E.Origin.Tell("Unable to reload configs :(");
|
||||
await E.Origin.Tell("Unable to reload configuration files");
|
||||
}
|
||||
}
|
||||
|
||||
@ -690,8 +690,11 @@ namespace SharedLibrary.Commands
|
||||
|
||||
public override async Task ExecuteAsync(Event E)
|
||||
{
|
||||
await E.Owner.ExecuteCommandAsync(E.Data.Trim());
|
||||
await E.Origin.Tell("Successfuly sent RCON command!");
|
||||
var Response = await E.Owner.ExecuteCommandAsync(E.Data.Trim());
|
||||
foreach (string S in Response)
|
||||
await E.Origin.Tell(S.StripColors());
|
||||
if (Response.Length == 0)
|
||||
await E.Origin.Tell("Successfully sent RCON command!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,28 +1,11 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace SharedLibrary
|
||||
namespace SharedLibrary
|
||||
{
|
||||
public struct dvar
|
||||
{
|
||||
public String name;
|
||||
public String description;
|
||||
public int flags;
|
||||
public short type;
|
||||
public String current;
|
||||
public String latched;
|
||||
public String _default;
|
||||
public int min;
|
||||
public int max;
|
||||
}
|
||||
|
||||
public class _DVAR<T>
|
||||
public class DVAR<T>
|
||||
{
|
||||
public string Name { get; private set; }
|
||||
public T Value;
|
||||
|
||||
public _DVAR(string name)
|
||||
public DVAR(string name)
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ namespace SharedLibrary
|
||||
Owner = S;
|
||||
}
|
||||
|
||||
public static Event requestEvent(String[] line, Server SV)
|
||||
public static Event ParseEventString(String[] line, Server SV)
|
||||
{
|
||||
#if DEBUG == false
|
||||
try
|
||||
@ -118,20 +118,20 @@ namespace SharedLibrary
|
||||
Data.Append(line[i] + ";");
|
||||
}
|
||||
|
||||
return new Event(GType.Kill, Data.ToString(), SV.clientFromEventLine(line, 6), SV.clientFromEventLine(line, 2), SV);
|
||||
return new Event(GType.Kill, Data.ToString(), SV.ParseClientFromString(line, 6), SV.ParseClientFromString(line, 2), SV);
|
||||
}
|
||||
|
||||
if (line[0].Substring(line[0].Length - 3).Trim() == "say")
|
||||
{
|
||||
Regex rgx = new Regex("[^a-zA-Z0-9 -! -_]");
|
||||
string message = rgx.Replace(line[4], "");
|
||||
return new Event(GType.Say, Utilities.removeNastyChars(message), SV.clientFromEventLine(line, 2), null, SV) { Message = Utilities.removeNastyChars(message) };
|
||||
return new Event(GType.Say, Utilities.removeNastyChars(message).StripColors(), SV.ParseClientFromString(line, 2), null, SV) { Message = Utilities.removeNastyChars(message).StripColors() };
|
||||
}
|
||||
|
||||
if (eventType == ":")
|
||||
return new Event(GType.MapEnd, line[0], new Player("WORLD", "WORLD", 0, 0), null, SV);
|
||||
|
||||
if (line[0].Contains("InitGame")) // blaze it
|
||||
if (line[0].Contains("InitGame"))
|
||||
return new Event(GType.MapChange, line[0], new Player("WORLD", "WORLD", 0, 0), null, SV);
|
||||
|
||||
|
||||
|
@ -1,7 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace SharedLibrary
|
||||
{
|
||||
|
@ -1,8 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SharedLibrary
|
||||
{
|
||||
|
@ -1,7 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace SharedLibrary
|
||||
{
|
||||
|
@ -1,7 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace SharedLibrary
|
||||
{
|
||||
@ -17,7 +14,7 @@ namespace SharedLibrary
|
||||
this.BType = BType;
|
||||
}
|
||||
|
||||
public String getWhen()
|
||||
public String GetWhenFormatted()
|
||||
{
|
||||
return When.ToString("MM/dd/yy HH:mm:ss"); ;
|
||||
}
|
||||
|
@ -20,34 +20,6 @@ namespace SharedLibrary.Network
|
||||
COMMAND,
|
||||
}
|
||||
|
||||
public static List<Player> PlayersFromStatus(String[] Status)
|
||||
{
|
||||
List<Player> StatusPlayers = new List<Player>();
|
||||
|
||||
foreach (String S in Status)
|
||||
{
|
||||
String responseLine = S.Trim();
|
||||
|
||||
if (Regex.Matches(responseLine, @"\d+$", RegexOptions.IgnoreCase).Count > 0 && responseLine.Length > 72) // its a client line!
|
||||
{
|
||||
String[] playerInfo = responseLine.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
int cID = -1;
|
||||
int Ping = -1;
|
||||
Int32.TryParse(playerInfo[2], out Ping);
|
||||
String cName = Utilities.StripColors(responseLine.Substring(46, 18)).Trim();
|
||||
String npID = responseLine.Substring(29, 17).Trim(); // DONT TOUCH PLZ
|
||||
int.TryParse(playerInfo[0], out cID);
|
||||
String cIP = responseLine.Substring(72, 20).Trim().Split(':')[0];
|
||||
if (cIP.Split(' ').Count() > 1)
|
||||
cIP = cIP.Split(' ')[1];
|
||||
Player P = new Player(cName, npID, cID, cIP) { Ping = Ping };
|
||||
StatusPlayers.Add(P);
|
||||
}
|
||||
}
|
||||
|
||||
return StatusPlayers;
|
||||
}
|
||||
|
||||
static string[] SendQuery(QueryType Type, Server QueryServer, string Parameters = "")
|
||||
{
|
||||
var ServerOOBConnection = new UdpClient();
|
||||
@ -113,7 +85,7 @@ namespace SharedLibrary.Network
|
||||
}
|
||||
}
|
||||
|
||||
public static async Task<_DVAR<T>> GetDvarAsync<T>(this Server server, string dvarName)
|
||||
public static async Task<DVAR<T>> GetDvarAsync<T>(this Server server, string dvarName)
|
||||
{
|
||||
string[] LineSplit = await Task.FromResult(SendQuery(QueryType.DVAR, server, dvarName));
|
||||
|
||||
@ -137,7 +109,7 @@ namespace SharedLibrary.Network
|
||||
string DvarCurrentValue = Regex.Replace(ValueSplit[2], @"\^[0-9]", "");
|
||||
string DvarDefaultValue = Regex.Replace(ValueSplit[4], @"\^[0-9]", "");
|
||||
|
||||
return new _DVAR<T>(DvarName) { Value = (T)Convert.ChangeType(DvarCurrentValue, typeof(T)) };
|
||||
return new DVAR<T>(DvarName) { Value = (T)Convert.ChangeType(DvarCurrentValue, typeof(T)) };
|
||||
}
|
||||
|
||||
public static async Task SetDvarAsync(this Server server, string dvarName, object dvarValue)
|
||||
@ -145,15 +117,15 @@ namespace SharedLibrary.Network
|
||||
await Task.FromResult(SendQuery(QueryType.DVAR, server, $"{dvarName} {dvarValue}"));
|
||||
}
|
||||
|
||||
public static async Task ExecuteCommandAsync(this Server server, string commandName)
|
||||
public static async Task<string[]> ExecuteCommandAsync(this Server server, string commandName)
|
||||
{
|
||||
await Task.FromResult(SendQuery(QueryType.COMMAND, server, commandName));
|
||||
return await Task.FromResult(SendQuery(QueryType.COMMAND, server, commandName).Skip(1).ToArray());
|
||||
}
|
||||
|
||||
public static async Task<List<Player>> GetStatusAsync(this Server server)
|
||||
{
|
||||
string[] response = await Task.FromResult(SendQuery(QueryType.DVAR, server, "status"));
|
||||
return PlayersFromStatus(response);
|
||||
return Utilities.PlayersFromStatus(response);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,7 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace SharedLibrary
|
||||
{
|
||||
|
@ -150,25 +150,16 @@ namespace SharedLibrary
|
||||
/// <param name="L">Game log line containing event</param>
|
||||
/// <param name="cIDPos">Position in the line where the cliet ID is written</param>
|
||||
/// <returns>Matching player if found</returns>
|
||||
abstract public Player clientFromEventLine(String[] L, int cIDPos);
|
||||
abstract public Player ParseClientFromString(String[] L, int cIDPos);
|
||||
|
||||
/// <summary>
|
||||
/// Get a player by name
|
||||
/// </summary>
|
||||
/// <param name="pName">Player name to search for</param>
|
||||
/// <returns>Matching player if found</returns>
|
||||
public Player clientFromName(String pName)
|
||||
public Player GetClientByName(String pName)
|
||||
{
|
||||
lock (Players)
|
||||
{
|
||||
foreach (var P in Players)
|
||||
{
|
||||
if (P != null && P.Name.ToLower().Contains(pName.ToLower()))
|
||||
return P;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
return Players.FirstOrDefault(p => p.Name.ToLower() == pName.ToLower());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -176,7 +167,7 @@ namespace SharedLibrary
|
||||
/// </summary>
|
||||
/// <param name="C">Player to check if banned</param>
|
||||
/// <returns>Matching ban if found</returns>
|
||||
abstract public Penalty isBanned(Player C);
|
||||
abstract public Penalty IsBanned(Player C);
|
||||
|
||||
/// <summary>
|
||||
/// Process requested command correlating to an event
|
||||
@ -210,7 +201,6 @@ namespace SharedLibrary
|
||||
/// </summary>
|
||||
/// <returns>True on sucess</returns>
|
||||
abstract public bool Reload();
|
||||
abstract public bool _Reload();
|
||||
|
||||
/// <summary>
|
||||
/// Send a message to all players
|
||||
|
@ -46,6 +46,34 @@ namespace SharedLibrary
|
||||
return newStr;
|
||||
}
|
||||
|
||||
public static List<Player> PlayersFromStatus(String[] Status)
|
||||
{
|
||||
List<Player> StatusPlayers = new List<Player>();
|
||||
|
||||
foreach (String S in Status)
|
||||
{
|
||||
String responseLine = S.Trim();
|
||||
|
||||
if (Regex.Matches(responseLine, @"\d+$", RegexOptions.IgnoreCase).Count > 0 && responseLine.Length > 72) // its a client line!
|
||||
{
|
||||
String[] playerInfo = responseLine.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
int cID = -1;
|
||||
int Ping = -1;
|
||||
Int32.TryParse(playerInfo[2], out Ping);
|
||||
String cName = Utilities.StripColors(responseLine.Substring(46, 18)).Trim();
|
||||
String npID = responseLine.Substring(29, 17).Trim(); // DONT TOUCH PLZ
|
||||
int.TryParse(playerInfo[0], out cID);
|
||||
String cIP = responseLine.Substring(72, 20).Trim().Split(':')[0];
|
||||
if (cIP.Split(' ').Count() > 1)
|
||||
cIP = cIP.Split(' ')[1];
|
||||
Player P = new Player(cName, npID, cID, cIP) { Ping = Ping };
|
||||
StatusPlayers.Add(P);
|
||||
}
|
||||
}
|
||||
|
||||
return StatusPlayers;
|
||||
}
|
||||
|
||||
public static Player.Permission matchPermission(String str)
|
||||
{
|
||||
String lookingFor = str.ToLower();
|
||||
|
Reference in New Issue
Block a user