1
0
mirror of https://github.com/RaidMax/IW4M-Admin.git synced 2025-06-10 15:20:48 -05:00

VERSION 1.4

CHANGELOG:
-works: with COD, WaW, MW3, BO1 (preliminary without extensive testing)
-fixed the issue with webfront chat history
-fixed console issue of spamming 'polling rate decreased' when server goes offline
-'unknown' admin in webfront defaults to 'IW4MAdmin'
This commit is contained in:
RaidMax
2017-08-08 21:44:52 -05:00
parent e7df314435
commit 5e9b11ed64
10 changed files with 175 additions and 131 deletions

View File

@ -23,8 +23,8 @@ namespace SharedLibrary.Network
static string[] SendQuery(QueryType Type, Server QueryServer, string Parameters = "")
{
var ServerOOBConnection = new UdpClient();
ServerOOBConnection.Client.SendTimeout = 1000;
ServerOOBConnection.Client.ReceiveTimeout = 1000;
ServerOOBConnection.Client.SendTimeout = 3000;
ServerOOBConnection.Client.ReceiveTimeout = 3000;
var Endpoint = new IPEndPoint(IPAddress.Parse(QueryServer.GetIP()), QueryServer.GetPort());
string QueryString = String.Empty;
@ -63,18 +63,25 @@ namespace SharedLibrary.Network
if (QueryResponseString.ToString().Contains("Invalid password"))
throw new Exceptions.NetworkException("RCON password is invalid");
if (QueryResponseString.ToString().Contains("rcon_password"))
throw new Exceptions.NetworkException("RCON password has not been set");
int num = int.Parse("0a", System.Globalization.NumberStyles.AllowHexSpecifier);
string[] SplitResponse = QueryResponseString.ToString().Split(new char[] { (char)num }, StringSplitOptions.RemoveEmptyEntries);
return SplitResponse;
}
catch (Exceptions.NetworkException e)
{
throw e;
}
catch (Exception)
{
attempts++;
if (attempts > 5)
{
var e = new Exceptions.NetworkException("Cannot communicate with server");
var e = new Exceptions.NetworkException("Could not communicate with the server (ensure the configuration is correct)");
e.Data["server_address"] = ServerOOBConnection.Client.RemoteEndPoint.ToString();
ServerOOBConnection.Close();
throw e;

View File

@ -14,6 +14,16 @@ namespace SharedLibrary
[Guid("61d3829e-fcbe-44d3-bb7c-51db8c2d7ac5")]
public abstract class Server
{
public enum Game
{
UKN,
IW3,
IW4,
IW5,
T4,
T5,
}
public Server(Interfaces.IManager mgr, ServerConfiguration config)
{
Password = config.Password;
@ -146,9 +156,10 @@ namespace SharedLibrary
public async Task Broadcast(String Message)
{
#if DEBUG
return;
//return;
#endif
await this.ExecuteCommandAsync($"sayraw {Message}");
string sayCommand = (GameName == Game.IW4) ? "sayraw" : "say";
await this.ExecuteCommandAsync($"{sayCommand} {Message}");
}
/// <summary>
@ -159,11 +170,13 @@ namespace SharedLibrary
public async Task Tell(String Message, Player Target)
{
#if DEBUG
if (!Target.lastEvent.Remote)
return;
//if (!Target.lastEvent.Remote)
// return;
#endif
string tellCommand = (GameName == Game.IW4) ? "tellraw" : "tell";
if (Target.ClientID > -1 && Message.Length > 0 && Target.Level != Player.Permission.Console && !Target.lastEvent.Remote)
await this.ExecuteCommandAsync($"tellraw {Target.ClientID} {Message}^7");
await this.ExecuteCommandAsync($"{tellCommand} {Target.ClientID} {Message}^7");
if (Target.Level == Player.Permission.Console)
{
@ -346,6 +359,7 @@ namespace SharedLibrary
public List<Report> Reports { get; set; }
public List<Chat> ChatHistory { get; protected set; }
public Queue<Helpers.PlayerHistory> PlayerHistory { get; private set; }
public Game GameName { get; protected set; }
// Info
public string Hostname { get; protected set; }

View File

@ -4,6 +4,7 @@ using System.Text;
using System.Text.RegularExpressions;
using System.Linq;
using System.Collections.Generic;
using static SharedLibrary.Server;
namespace SharedLibrary
{
@ -246,5 +247,21 @@ namespace SharedLibrary
else
return "a very long time";
}
public static Game GetGame(string gameName)
{
if (gameName.Contains("IW4"))
return Game.IW4;
if (gameName.Contains("CoD4"))
return Game.IW3;
if (gameName.Contains("WaW"))
return Game.T4;
if (gameName.Contains("COD_T5_S"))
return Game.T5;
if (gameName.Contains("IW5"))
return Game.IW5;
return Game.UKN;
}
}
}