-rcon tweaks
-so much stuff cant remember
This commit is contained in:
parent
dad8fedc78
commit
ed4883d675
143
Admin/Command.cs
143
Admin/Command.cs
@ -203,7 +203,7 @@ namespace IW4MAdmin
|
|||||||
|
|
||||||
public override void Execute(Event E)
|
public override void Execute(Event E)
|
||||||
{
|
{
|
||||||
String You = String.Format("You are {0} at client spot {1} with xuid {2} and ID {5}. You have connected {3} times and are currently ranked {4}", E.Origin.getName(), E.Origin.getClientNum(), E.Origin.getID(), E.Origin.getConnections(), E.Origin.getLevel(), E.Origin.getDBID());
|
String You = String.Format("{0} [^3{1}^7] {{2}} {{3}} [{4}^7] IP: {5}", E.Origin.getName(), E.Origin.getClientNum(), E.Origin.getID(), Utilities.levelToColor(E.Origin.getLevel()), E.Origin.getDBID(), E.Origin.getIP());
|
||||||
E.Origin.Tell(You);
|
E.Origin.Tell(You);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -412,32 +412,51 @@ namespace IW4MAdmin
|
|||||||
public override void Execute(Event E)
|
public override void Execute(Event E)
|
||||||
{
|
{
|
||||||
var db_players = E.Owner.clientDB.findPlayers(E.Data.Trim());
|
var db_players = E.Owner.clientDB.findPlayers(E.Data.Trim());
|
||||||
|
|
||||||
if (db_players == null)
|
if (db_players == null)
|
||||||
{
|
{
|
||||||
E.Origin.Tell("No players found");
|
E.Origin.Tell("No players found");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
foreach (Player P in db_players)
|
foreach (Player P in db_players)
|
||||||
{
|
{
|
||||||
String mesg;
|
String mesg;
|
||||||
var db_aliases = E.Owner.aliasDB.getPlayer(P.getDBID());
|
P.Alias = E.Owner.aliasDB.getPlayer(P.getDBID());
|
||||||
|
|
||||||
if (P.getLevel() == Player.Permission.Banned)
|
if (P.getLevel() == Player.Permission.Banned)
|
||||||
mesg = String.Format("[^3{0}^7] [^3@{1}^7] - {2} [{3}^7] - {4}", P.getName(), P.getDBID(), P.getID(), Utilities.levelToColor(P.getLevel()), P.getLastO());
|
mesg = String.Format("[^3{0}^7] [^3@{1}^7] - {2} [{3}^7] - {4}", P.getName(), P.getDBID(), P.getID(), Utilities.levelToColor(P.getLevel()), P.getLastO());
|
||||||
else
|
else
|
||||||
mesg = String.Format("[^3{0}^7] [^3@{1}^7] - {2} [{3}^7]", P.getName(), P.getDBID(), P.getID(), Utilities.levelToColor(P.getLevel()));
|
mesg = String.Format("[^3{0}^7] [^3@{1}^7] - {2} [{3}^7]", P.getName(), P.getDBID(), P.getID(), Utilities.levelToColor(P.getLevel()));
|
||||||
E.Origin.Tell(mesg);
|
|
||||||
if (db_aliases != null)
|
|
||||||
{
|
|
||||||
mesg = "Aliases: ";
|
|
||||||
foreach (String S in db_aliases.getNames())
|
|
||||||
mesg += S + ',';
|
|
||||||
}
|
|
||||||
|
|
||||||
E.Origin.Tell(mesg);
|
E.Origin.Tell(mesg);
|
||||||
|
|
||||||
|
if (P.Alias == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (P.Alias.getNames() != null)
|
||||||
|
{
|
||||||
|
mesg = "Aliases: ";
|
||||||
|
foreach (String S in P.Alias.getNames())
|
||||||
|
{
|
||||||
|
if (S != String.Empty)
|
||||||
|
mesg += S + " | ";
|
||||||
|
}
|
||||||
|
E.Origin.Tell(mesg);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (P.Alias.getIPS() != null)
|
||||||
|
{
|
||||||
|
mesg = "IPs: ";
|
||||||
|
foreach (String IP in P.Alias.getIPS())
|
||||||
|
{
|
||||||
|
if (IP.Split('.').Length > 3 && IP != String.Empty)
|
||||||
|
mesg += IP + " | ";
|
||||||
|
}
|
||||||
|
|
||||||
|
E.Origin.Tell(mesg);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -515,7 +534,6 @@ namespace IW4MAdmin
|
|||||||
{
|
{
|
||||||
if (P != null)
|
if (P != null)
|
||||||
E.Origin.Tell(String.Format("^3{0}^7 - ^5{1} ^7KDR | ^5{2} ^7SKILL", P.getName(), P.stats.KDR, P.stats.Skill));
|
E.Origin.Tell(String.Format("^3{0}^7 - ^5{1} ^7KDR | ^5{2} ^7SKILL", P.getName(), P.stats.KDR, P.stats.Skill));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -536,5 +554,106 @@ namespace IW4MAdmin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class Balance : Command
|
||||||
|
{
|
||||||
|
public Balance(String N, String D, String U, Player.Permission P, int args, bool nT) : base(N, D, U, P, args, nT) { }
|
||||||
|
|
||||||
|
public override void Execute(Event E)
|
||||||
|
{
|
||||||
|
E.Owner.RCON.addRCON(String.Format("admin_lastevent {0};{1}", "balance", E.Origin.getID())); //Let gsc do the magic
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class GoTo : Command
|
||||||
|
{
|
||||||
|
public GoTo(String N, String D, String U, Player.Permission P, int args, bool nT) : base(N, D, U, P, args, nT) { }
|
||||||
|
|
||||||
|
public override void Execute(Event E)
|
||||||
|
{
|
||||||
|
E.Owner.RCON.addRCON(String.Format("admin_lastevent {0};{1};{2};{3}", "goto", E.Origin.getID(), E.Target.getName(), E.Data)); //Let gsc do the magic
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Flag : Command
|
||||||
|
{
|
||||||
|
public Flag(String N, String D, String U, Player.Permission P, int args, bool nT) : base(N, D, U, P, args, nT) { }
|
||||||
|
|
||||||
|
public override void Execute(Event E)
|
||||||
|
{
|
||||||
|
if (E.Target.getLevel() >= E.Origin.getLevel())
|
||||||
|
{
|
||||||
|
E.Origin.Tell("You cannot flag " + E.Target.getName());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (E.Target.getLevel() == Player.Permission.Flagged)
|
||||||
|
{
|
||||||
|
E.Target.setLevel(Player.Permission.User);
|
||||||
|
E.Origin.Tell("You have ^5unflagged ^7" + E.Target.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
E.Target.setLevel(Player.Permission.Flagged);
|
||||||
|
E.Origin.Tell("You have ^5flagged ^7" + E.Target.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
E.Owner.clientDB.updatePlayer(E.Target);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _Report : Command
|
||||||
|
{
|
||||||
|
public _Report(String N, String D, String U, Player.Permission P, int args, bool nT) : base(N, D, U, P, args, nT) { }
|
||||||
|
|
||||||
|
public override void Execute(Event E)
|
||||||
|
{
|
||||||
|
if (E.Target.getLevel() > E.Origin.getLevel())
|
||||||
|
{
|
||||||
|
E.Origin.Tell("You cannot report " + E.Target.getName());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
E.Data = Utilities.removeWords(E.Data, 1);
|
||||||
|
E.Owner.Reports.Add(new Report(E.Target, E.Origin, E.Data));
|
||||||
|
E.Origin.Tell("Successfully reported " + E.Target.getName());
|
||||||
|
|
||||||
|
E.Owner.ToAdmins(String.Format("^5{0}^7->^1{1}^7: {2}", E.Origin.getName(), E.Target.getName(), E.Data));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Reports : Command
|
||||||
|
{
|
||||||
|
public Reports(String N, String D, String U, Player.Permission P, int args, bool nT) : base(N, D, U, P, args, nT) { }
|
||||||
|
|
||||||
|
public override void Execute(Event E)
|
||||||
|
{
|
||||||
|
if (E.Owner.Reports.Count < 1)
|
||||||
|
{
|
||||||
|
E.Origin.Tell("No players reported yet.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int count = E.Owner.Reports.Count - 1;
|
||||||
|
for (int i = 0; i <= count; i++)
|
||||||
|
{
|
||||||
|
if (count > 8)
|
||||||
|
i = count - 8;
|
||||||
|
Report R = E.Owner.Reports[i];
|
||||||
|
E.Origin.Tell(String.Format("^5{0}^7->^1{1}^7: {2}", R.Origin.getName(), R.Target.getName(), R.Reason));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _Tell : Command
|
||||||
|
{
|
||||||
|
public _Tell(String N, String D, String U, Player.Permission P, int args, bool nT) : base(N, D, U, P, args, nT) { }
|
||||||
|
|
||||||
|
public override void Execute(Event E)
|
||||||
|
{
|
||||||
|
E.Data = Utilities.removeWords(E.Data, 1);
|
||||||
|
E.Owner.RCON.addRCON(String.Format("admin_lastevent tell;{0};{1};{2}", E.Origin.getID(), E.Target.getID(), E.Data));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -152,9 +152,9 @@ namespace IW4MAdmin
|
|||||||
DataRow ResponseRow = Result.Rows[0];
|
DataRow ResponseRow = Result.Rows[0];
|
||||||
|
|
||||||
|
|
||||||
if (ResponseRow["IP"].ToString().Length < 2)
|
// if (ResponseRow["IP"].ToString().Length < 2)
|
||||||
ResponseRow["IP"] = DateTime.Now.ToString(); // because aliases and backwards compatibility
|
// ResponseRow["IP"] = DateTime.Now.ToString(); // because aliases and backwards compatibility
|
||||||
|
|
||||||
return new Player(ResponseRow["Name"].ToString(), ResponseRow["npID"].ToString(), cNum, (Player.Permission)(ResponseRow["Level"]), Convert.ToInt32(ResponseRow["Number"]), ResponseRow["LastOffense"].ToString(), (int)ResponseRow["Connections"], ResponseRow["IP"].ToString());
|
return new Player(ResponseRow["Name"].ToString(), ResponseRow["npID"].ToString(), cNum, (Player.Permission)(ResponseRow["Level"]), Convert.ToInt32(ResponseRow["Number"]), ResponseRow["LastOffense"].ToString(), (int)ResponseRow["Connections"], ResponseRow["IP"].ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,8 +172,8 @@ namespace IW4MAdmin
|
|||||||
{
|
{
|
||||||
DataRow p = Result.Rows[0];
|
DataRow p = Result.Rows[0];
|
||||||
|
|
||||||
if (p["IP"].ToString().Length < 2)
|
// if (p["IP"].ToString().Length < 2)
|
||||||
p["IP"] = DateTime.Now.ToString(); // because aliases and backwards compatibility
|
// p["IP"] = DateTime.Now.ToString(); // because aliases and backwards compatibility
|
||||||
|
|
||||||
return new Player(p["Name"].ToString(), p["npID"].ToString(), -1, (Player.Permission)(p["Level"]), Convert.ToInt32(p["Number"]), p["LastOffense"].ToString(), Convert.ToInt32(p["Connections"]), p["IP"].ToString());
|
return new Player(p["Name"].ToString(), p["npID"].ToString(), -1, (Player.Permission)(p["Level"]), Convert.ToInt32(p["Number"]), p["LastOffense"].ToString(), Convert.ToInt32(p["Connections"]), p["IP"].ToString());
|
||||||
}
|
}
|
||||||
@ -231,8 +231,8 @@ namespace IW4MAdmin
|
|||||||
{
|
{
|
||||||
if (Row["TIME"].ToString().Length < 2) //compatibility with my old database
|
if (Row["TIME"].ToString().Length < 2) //compatibility with my old database
|
||||||
Row["TIME"] = DateTime.Now.ToString();
|
Row["TIME"] = DateTime.Now.ToString();
|
||||||
if (Row["IP"].ToString().Length < 2)
|
// if (Row["IP"].ToString().Length < 2)
|
||||||
Row["IP"] = DateTime.Now.ToString(); //because we don't have old ip's and don't want a messy alias
|
// Row["IP"] = DateTime.Now.ToString(); //because we don't have old ip's and don't want a messy alias
|
||||||
|
|
||||||
Bans.Add(new Ban(Row["Reason"].ToString(), Row["npID"].ToString(), Row["bannedByID"].ToString(), DateTime.Parse(Row["TIME"].ToString()), Row["IP"].ToString()));
|
Bans.Add(new Ban(Row["Reason"].ToString(), Row["npID"].ToString(), Row["bannedByID"].ToString(), DateTime.Parse(Row["TIME"].ToString()), Row["IP"].ToString()));
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
<CreateWebPageOnPublish>true</CreateWebPageOnPublish>
|
<CreateWebPageOnPublish>true</CreateWebPageOnPublish>
|
||||||
<WebPage>publish.htm</WebPage>
|
<WebPage>publish.htm</WebPage>
|
||||||
<ApplicationRevision>7</ApplicationRevision>
|
<ApplicationRevision>7</ApplicationRevision>
|
||||||
<ApplicationVersion>0.6.0.%2a</ApplicationVersion>
|
<ApplicationVersion>0.7.0.%2a</ApplicationVersion>
|
||||||
<UseApplicationTrust>false</UseApplicationTrust>
|
<UseApplicationTrust>false</UseApplicationTrust>
|
||||||
<PublishWizardCompleted>true</PublishWizardCompleted>
|
<PublishWizardCompleted>true</PublishWizardCompleted>
|
||||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||||
@ -106,6 +106,7 @@
|
|||||||
<DependentUpon>Settings.settings</DependentUpon>
|
<DependentUpon>Settings.settings</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="RCON.cs" />
|
<Compile Include="RCON.cs" />
|
||||||
|
<Compile Include="Report.cs" />
|
||||||
<Compile Include="Server.cs" />
|
<Compile Include="Server.cs" />
|
||||||
<Compile Include="TrueSkill.cs" />
|
<Compile Include="TrueSkill.cs" />
|
||||||
<Compile Include="Utilities.cs" />
|
<Compile Include="Utilities.cs" />
|
||||||
|
@ -14,16 +14,17 @@ namespace IW4MAdmin
|
|||||||
None,
|
None,
|
||||||
}
|
}
|
||||||
|
|
||||||
public Log(file logf, Level mode)
|
public Log(file logf, Level mode, int port)
|
||||||
{
|
{
|
||||||
logFile = logf;
|
logFile = logf;
|
||||||
logMode = mode;
|
logMode = mode;
|
||||||
|
Port = port;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void Write(String line, Level lv)
|
public void Write(String line, Level lv)
|
||||||
{
|
{
|
||||||
String Line = String.Format("{1} - [{0}]: {2}", lv, getTime(), line);
|
String Line = String.Format("{1} - [{0}]: {2}", Port, getTime(), line);
|
||||||
switch(logMode)
|
switch(logMode)
|
||||||
{
|
{
|
||||||
case Level.All:
|
case Level.All:
|
||||||
@ -50,5 +51,6 @@ namespace IW4MAdmin
|
|||||||
|
|
||||||
private file logFile;
|
private file logFile;
|
||||||
private Level logMode;
|
private Level logMode;
|
||||||
|
private int Port;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,10 +29,11 @@ namespace IW4MAdmin
|
|||||||
foreach (Server IW4M in checkConfig())
|
foreach (Server IW4M in checkConfig())
|
||||||
{
|
{
|
||||||
//Threading seems best here
|
//Threading seems best here
|
||||||
Thread monitorThread = new Thread(new ThreadStart(IW4M.Monitor));
|
Server SV = IW4M;
|
||||||
|
Thread monitorThread = new Thread(new ThreadStart(SV.Monitor));
|
||||||
monitorThread.Start();
|
monitorThread.Start();
|
||||||
Utilities.Wait(0.3);
|
Utilities.Wait(0.2); // give rcon a chance to respond
|
||||||
Console.WriteLine("Now monitoring " + IW4M.getName());
|
Console.WriteLine("Now monitoring " + SV.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
Utilities.Wait(5); //Give them time to read an error before exiting
|
Utilities.Wait(5); //Give them time to read an error before exiting
|
||||||
|
@ -72,12 +72,14 @@ namespace IW4MAdmin
|
|||||||
|
|
||||||
public void addName(String Name)
|
public void addName(String Name)
|
||||||
{
|
{
|
||||||
Names += Names + ';';
|
if (Name.Trim() != String.Empty && Name != null)
|
||||||
|
Names += ';' + Names;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addIP(String IP)
|
public void addIP(String IP)
|
||||||
{
|
{
|
||||||
IPS += IP + ';';
|
if (IP.Trim() != String.Empty && IP != null)
|
||||||
|
IPS += ';' + IP;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String Names;
|
private String Names;
|
||||||
@ -89,6 +91,7 @@ namespace IW4MAdmin
|
|||||||
{
|
{
|
||||||
public enum Permission
|
public enum Permission
|
||||||
{
|
{
|
||||||
|
Flagged = -2,
|
||||||
Banned = -1,
|
Banned = -1,
|
||||||
User = 0,
|
User = 0,
|
||||||
Moderator = 1,
|
Moderator = 1,
|
||||||
|
20
Admin/Report.cs
Normal file
20
Admin/Report.cs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace IW4MAdmin
|
||||||
|
{
|
||||||
|
class Report
|
||||||
|
{
|
||||||
|
public Report(Player T, Player O, String R)
|
||||||
|
{
|
||||||
|
Target = T;
|
||||||
|
Origin = O;
|
||||||
|
Reason = R;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Player Target { get; private set; }
|
||||||
|
public Player Origin { get; private set; }
|
||||||
|
public String Reason { get; private set; }
|
||||||
|
}
|
||||||
|
}
|
156
Admin/Server.cs
156
Admin/Server.cs
@ -22,9 +22,9 @@ namespace IW4MAdmin
|
|||||||
RCON = new RCON(this);
|
RCON = new RCON(this);
|
||||||
logFile = new file("admin_" + port + ".log", true);
|
logFile = new file("admin_" + port + ".log", true);
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
Log = new Log(logFile, Log.Level.Debug);
|
Log = new Log(logFile, Log.Level.Debug, port);
|
||||||
#else
|
#else
|
||||||
Log = new Log(logFile, Log.Level.Production);
|
Log = new Log(logFile, Log.Level.Production, port);
|
||||||
#endif
|
#endif
|
||||||
players = new List<Player>(new Player[18]);
|
players = new List<Player>(new Player[18]);
|
||||||
clientDB = new ClientsDB("clients.rm");
|
clientDB = new ClientsDB("clients.rm");
|
||||||
@ -35,6 +35,7 @@ namespace IW4MAdmin
|
|||||||
events = new Queue<Event>();
|
events = new Queue<Event>();
|
||||||
HB = new Heartbeat(this);
|
HB = new Heartbeat(this);
|
||||||
Macros = new Dictionary<String, Object>();
|
Macros = new Dictionary<String, Object>();
|
||||||
|
Reports = new List<Report>();
|
||||||
nextMessage = 0;
|
nextMessage = 0;
|
||||||
initCommands();
|
initCommands();
|
||||||
initMacros();
|
initMacros();
|
||||||
@ -112,13 +113,11 @@ namespace IW4MAdmin
|
|||||||
clientDB.addPlayer(P);
|
clientDB.addPlayer(P);
|
||||||
Player New = clientDB.getPlayer(P.getID(), P.getClientNum());
|
Player New = clientDB.getPlayer(P.getID(), P.getClientNum());
|
||||||
statDB.addPlayer(New);
|
statDB.addPlayer(New);
|
||||||
aliasDB.addPlayer(new Aliases(New.getDBID(), New.getName(), New.getIP()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//messy way to prevent loss of last event
|
//messy way to prevent loss of last event
|
||||||
Player NewPlayer = clientDB.getPlayer(P.getID(), P.getClientNum());
|
Player NewPlayer = clientDB.getPlayer(P.getID(), P.getClientNum());
|
||||||
NewPlayer.stats = statDB.getStats(NewPlayer.getDBID());
|
NewPlayer.stats = statDB.getStats(NewPlayer.getDBID());
|
||||||
NewPlayer.Alias = aliasDB.getPlayer(NewPlayer.getDBID());
|
|
||||||
|
|
||||||
if (NewPlayer.stats == null) //For safety
|
if (NewPlayer.stats == null) //For safety
|
||||||
{
|
{
|
||||||
@ -134,36 +133,40 @@ namespace IW4MAdmin
|
|||||||
if (players[NewPlayer.getClientNum()] == null)
|
if (players[NewPlayer.getClientNum()] == null)
|
||||||
{
|
{
|
||||||
bool updated = false;
|
bool updated = false;
|
||||||
while (!updated)
|
while (!updated) //Sometimes we get a issue when a player disconnects and it doesn't register
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
P.updateIP(IPS[P.getID()].Trim());
|
P.updateIP(IPS[P.getID()].Trim());
|
||||||
updated = true;
|
|
||||||
|
NewPlayer.updateIP(P.getIP());
|
||||||
Log.Write("Sucessfully updated " + NewPlayer.getName() + "'s IP to " + P.getIP(), Log.Level.Debug);
|
Log.Write("Sucessfully updated " + NewPlayer.getName() + "'s IP to " + P.getIP(), Log.Level.Debug);
|
||||||
|
updated = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
//Log.Write("Looks like the connecting player doesn't have an IP location assigned yet. Let's wait for next poll", Log.Level.Debug);
|
Log.Write("Waiting for " + P.getName() + "'s IP...", Log.Level.Debug);
|
||||||
Utilities.Wait(1);
|
Utilities.Wait(2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NewPlayer.Alias == null)
|
if (aliasDB.getPlayer(NewPlayer.getDBID()) == null)
|
||||||
{
|
aliasDB.addPlayer(new Aliases(NewPlayer.getDBID(), P.getName(), P.getIP()));
|
||||||
aliasDB.addPlayer(new Aliases(NewPlayer.getDBID(), NewPlayer.getName(), P.getIP()));
|
|
||||||
}
|
NewPlayer.Alias = aliasDB.getPlayer(NewPlayer.getDBID());
|
||||||
|
|
||||||
if (P.getName() != NewPlayer.getName())
|
if ((NewPlayer.Alias.getNames().Find(m => m.Equals(P.getName()))) == null || NewPlayer.getName() == null || NewPlayer.getName() == String.Empty)
|
||||||
{
|
{
|
||||||
|
Log.Write("Connecting player has new alias -- " + P.getName() + " previous was: " + NewPlayer.getName(), Log.Level.Debug);
|
||||||
NewPlayer.updateName(P.getName());
|
NewPlayer.updateName(P.getName());
|
||||||
NewPlayer.Alias.addName(P.getName());
|
NewPlayer.Alias.addName(P.getName());
|
||||||
aliasDB.updatePlayer(NewPlayer.Alias);
|
aliasDB.updatePlayer(NewPlayer.Alias);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (P.getIP() != NewPlayer.getIP())
|
if (NewPlayer.Alias.getIPS().Find(i => i.Equals(P.getIP())) == null || P.getIP() == null || P.getIP() == String.Empty)
|
||||||
{
|
{
|
||||||
|
Log.Write("Connecting player has new IP - " + P.getIP(), Log.Level.Debug);
|
||||||
NewPlayer.updateIP(P.getIP());
|
NewPlayer.updateIP(P.getIP());
|
||||||
NewPlayer.Alias.addIP(P.getIP());
|
NewPlayer.Alias.addIP(P.getIP());
|
||||||
aliasDB.updatePlayer(NewPlayer.Alias);
|
aliasDB.updatePlayer(NewPlayer.Alias);
|
||||||
@ -177,6 +180,7 @@ namespace IW4MAdmin
|
|||||||
{
|
{
|
||||||
Log.Write("Banned client " + P.getName() + " trying to connect...", Log.Level.Debug);
|
Log.Write("Banned client " + P.getName() + " trying to connect...", Log.Level.Debug);
|
||||||
string Reason = String.Empty;
|
string Reason = String.Empty;
|
||||||
|
|
||||||
if (B != null)
|
if (B != null)
|
||||||
Reason = B.getReason();
|
Reason = B.getReason();
|
||||||
else
|
else
|
||||||
@ -184,14 +188,23 @@ namespace IW4MAdmin
|
|||||||
|
|
||||||
String Message = "^1Player Kicked: ^7Previously Banned for ^5" + Reason;
|
String Message = "^1Player Kicked: ^7Previously Banned for ^5" + Reason;
|
||||||
NewPlayer.Kick(Message);
|
NewPlayer.Kick(Message);
|
||||||
|
|
||||||
|
if (players[P.getClientNum()] != null)
|
||||||
|
players[P.getClientNum()] = null;
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
players[NewPlayer.getClientNum()] = null;
|
players[NewPlayer.getClientNum()] = null;
|
||||||
players[NewPlayer.getClientNum()] = NewPlayer;
|
players[NewPlayer.getClientNum()] = NewPlayer;
|
||||||
|
#if DEBUG == FALSE
|
||||||
NewPlayer.Tell("Welcome ^5" + NewPlayer.getName() + " ^7this is your ^5" + Utilities.timesConnected(NewPlayer.getConnections()) + " ^7time connecting!");
|
NewPlayer.Tell("Welcome ^5" + NewPlayer.getName() + " ^7this is your ^5" + Utilities.timesConnected(NewPlayer.getConnections()) + " ^7time connecting!");
|
||||||
|
#endif
|
||||||
Log.Write("Client " + NewPlayer.getName() + " connecting...", Log.Level.Debug);
|
Log.Write("Client " + NewPlayer.getName() + " connecting...", Log.Level.Debug);
|
||||||
clientnum++;
|
clientnum++;
|
||||||
|
|
||||||
|
if (NewPlayer.getLevel() == Player.Permission.Flagged)
|
||||||
|
ToAdmins("^1NOTICE: ^7Flagged player ^5" + NewPlayer.getName() + "^7 has joined!");
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -324,14 +337,19 @@ namespace IW4MAdmin
|
|||||||
{
|
{
|
||||||
foreach (Ban B in Bans)
|
foreach (Ban B in Bans)
|
||||||
{
|
{
|
||||||
|
if (B.getID().Length < 5 || B.getIP().Length < 5)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (B.getID() == null || C.getID() == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
if (B.getID() == C.getID())
|
if (B.getID() == C.getID())
|
||||||
return B;
|
return B;
|
||||||
|
|
||||||
if (B.getIP() == null)
|
if (B.getIP() == null || C.getIP() == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (C.Alias.getIPS().Find(f => f.Contains(B.getIP())) != null)
|
if (C.Alias.getIPS().Find(f => f.Equals(B.getIP())) != null)
|
||||||
return B;
|
return B;
|
||||||
|
|
||||||
if (C.getIP() == B.getIP())
|
if (C.getIP() == B.getIP())
|
||||||
@ -364,9 +382,13 @@ namespace IW4MAdmin
|
|||||||
int cNum = -1;
|
int cNum = -1;
|
||||||
int.TryParse(Args[0], out cNum);
|
int.TryParse(Args[0], out cNum);
|
||||||
|
|
||||||
|
if (C.getName() == "stats" && Args.Length == 1)
|
||||||
|
E.Target = E.Origin;
|
||||||
|
|
||||||
if (Args[0] == String.Empty)
|
if (Args[0] == String.Empty)
|
||||||
return C;
|
return C;
|
||||||
|
|
||||||
|
|
||||||
if (Args[0][0] == '@') // user specifying target by database ID
|
if (Args[0][0] == '@') // user specifying target by database ID
|
||||||
{
|
{
|
||||||
int dbID = -1;
|
int dbID = -1;
|
||||||
@ -456,7 +478,7 @@ namespace IW4MAdmin
|
|||||||
Broadcast("IW4M Admin is now ^2ONLINE");
|
Broadcast("IW4M Admin is now ^2ONLINE");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
while (errors <=5)
|
while (isRunning)
|
||||||
{
|
{
|
||||||
#if DEBUG == false
|
#if DEBUG == false
|
||||||
try
|
try
|
||||||
@ -536,7 +558,6 @@ namespace IW4MAdmin
|
|||||||
catch (Exception E)
|
catch (Exception E)
|
||||||
{
|
{
|
||||||
Log.Write("Something unexpected occured. Hopefully we can ignore it - " + E.Message + " @" + Utilities.GetLineNumber(E), Log.Level.All);
|
Log.Write("Something unexpected occured. Hopefully we can ignore it - " + E.Message + " @" + Utilities.GetLineNumber(E), Log.Level.All);
|
||||||
errors++;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -559,27 +580,36 @@ namespace IW4MAdmin
|
|||||||
timesFailed++;
|
timesFailed++;
|
||||||
Log.Write("Server appears to be offline - " + timesFailed, Log.Level.Debug);
|
Log.Write("Server appears to be offline - " + timesFailed, Log.Level.Debug);
|
||||||
|
|
||||||
if (timesFailed > 4)
|
if (timesFailed >= 4)
|
||||||
{
|
{
|
||||||
Log.Write("Max offline attempts reached. Reinitializing RCON connection.", Log.Level.Debug);
|
Log.Write("Max offline attempts reached. Reinitializing RCON connection.", Log.Level.Debug);
|
||||||
RCON.Reset();
|
RCON.Reset();
|
||||||
timesFailed = 0;
|
timesFailed = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
Utilities.Wait(10); // cut the time in half to make sure it isn't changing a map
|
||||||
|
IPS = Utilities.IPFromStatus(RCON.addRCON("status"));
|
||||||
|
}
|
||||||
|
|
||||||
|
Log.Write("Server responded to status query!", Log.Level.Debug);
|
||||||
|
timesFailed = 0;
|
||||||
|
|
||||||
|
foreach(Player P in players) //Ensures uniformity between server and admin players
|
||||||
|
{
|
||||||
|
if (P == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
String IP = String.Empty;
|
||||||
|
IPS.TryGetValue(P.getID(), out IP);
|
||||||
|
if (IP == String.Empty)
|
||||||
{
|
{
|
||||||
Log.Write("Server responded to status query!", Log.Level.All);
|
Log.Write("Invalid player detected, quit event must have been skipped!", Log.Level.All);
|
||||||
timesFailed = 0;
|
removePlayer(P.getClientNum());
|
||||||
}
|
}
|
||||||
|
|
||||||
Thread.Sleep(FLOOD_TIMEOUT);
|
|
||||||
|
|
||||||
IPS = Utilities.IPFromStatus(RCON.addRCON("status"));
|
|
||||||
Utilities.Wait(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lastPoll = DateTime.Now;
|
lastPoll = DateTime.Now;
|
||||||
Utilities.Wait(20);
|
Utilities.Wait(20); // don't want to overload the server
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -808,19 +838,30 @@ namespace IW4MAdmin
|
|||||||
}
|
}
|
||||||
|
|
||||||
Log.Write(E.Origin.getName() + " killed " + E.Target.getName() + " with a " + E.Data, Log.Level.Debug);
|
Log.Write(E.Origin.getName() + " killed " + E.Target.getName() + " with a " + E.Data, Log.Level.Debug);
|
||||||
E.Origin.stats.Kills++;
|
|
||||||
E.Origin.stats.updateKDR();
|
|
||||||
|
|
||||||
E.Origin.stats.lastMew = TrueSkill.calculateWinnerMu(E.Origin.stats, E.Target.stats);
|
if (E.Origin != E.Target)
|
||||||
|
{
|
||||||
|
E.Origin.stats.Kills++;
|
||||||
|
E.Origin.stats.updateKDR();
|
||||||
|
|
||||||
E.Origin.stats.lastSigma = TrueSkill.calculateWinnerSigma(E.Origin.stats, E.Target.stats);
|
E.Origin.stats.lastMew = TrueSkill.calculateWinnerMu(E.Origin.stats, E.Target.stats);
|
||||||
E.Origin.stats.updateSkill();
|
E.Origin.stats.lastSigma = TrueSkill.calculateWinnerSigma(E.Origin.stats, E.Target.stats);
|
||||||
|
E.Origin.stats.updateSkill();
|
||||||
|
|
||||||
E.Target.stats.Deaths++;
|
E.Target.stats.Deaths++;
|
||||||
E.Target.stats.updateKDR();
|
E.Target.stats.updateKDR();
|
||||||
|
|
||||||
E.Target.stats.lastMew = TrueSkill.calculateLoserMu(E.Target.stats, E.Origin.stats);
|
E.Target.stats.lastMew = TrueSkill.calculateLoserMu(E.Target.stats, E.Origin.stats);
|
||||||
E.Target.stats.lastSigma = TrueSkill.calculateLoserSigma(E.Target.stats, E.Origin.stats);
|
E.Target.stats.lastSigma = TrueSkill.calculateLoserSigma(E.Target.stats, E.Origin.stats);
|
||||||
|
|
||||||
|
totalKills++;
|
||||||
|
}
|
||||||
|
|
||||||
|
else //Suicide
|
||||||
|
{
|
||||||
|
E.Origin.stats.Deaths++;
|
||||||
|
E.Origin.stats.updateKDR();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (E.Type == Event.GType.Say)
|
if (E.Type == Event.GType.Say)
|
||||||
@ -955,7 +996,7 @@ namespace IW4MAdmin
|
|||||||
{
|
{
|
||||||
if (B.getID() == Target.getID())
|
if (B.getID() == Target.getID())
|
||||||
{
|
{
|
||||||
clientDB.removeBan(GUID);
|
clientDB.removeBan(Target.getID());
|
||||||
Bans.Remove(B);
|
Bans.Remove(B);
|
||||||
Player P = clientDB.getPlayer(Target.getID(), 0);
|
Player P = clientDB.getPlayer(Target.getID(), 0);
|
||||||
P.setLevel(Player.Permission.User);
|
P.setLevel(Player.Permission.User);
|
||||||
@ -1000,6 +1041,22 @@ namespace IW4MAdmin
|
|||||||
return Utilities.removeNastyChars(Quote);
|
return Utilities.removeNastyChars(Quote);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ToAdmins(String message)
|
||||||
|
{
|
||||||
|
List<Player> admins = players;
|
||||||
|
foreach (Player P in admins)
|
||||||
|
{
|
||||||
|
if (P == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (P.getLevel() > Player.Permission.User)
|
||||||
|
{
|
||||||
|
RCON.addRCON("admin_lastevent alert;" + P.getID() + ";0;mp_killstreak_nuclearstrike");
|
||||||
|
P.Tell(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//END
|
//END
|
||||||
|
|
||||||
//THIS IS BAD BECAUSE WE DON"T WANT EVERYONE TO HAVE ACCESS :/
|
//THIS IS BAD BECAUSE WE DON"T WANT EVERYONE TO HAVE ACCESS :/
|
||||||
@ -1013,6 +1070,8 @@ namespace IW4MAdmin
|
|||||||
Macros = new Dictionary<String, Object>();
|
Macros = new Dictionary<String, Object>();
|
||||||
Macros.Add("WISDOM", Wisdom());
|
Macros.Add("WISDOM", Wisdom());
|
||||||
Macros.Add("TOTALPLAYERS", clientDB.totalPlayers());
|
Macros.Add("TOTALPLAYERS", clientDB.totalPlayers());
|
||||||
|
Macros.Add("TOTALKILLS", totalKills);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initMaps()
|
private void initMaps()
|
||||||
@ -1121,12 +1180,12 @@ namespace IW4MAdmin
|
|||||||
commands.Add(new _Stats("stats", "view your stats or another player's. syntax: !stats", "xlrstats", Player.Permission.User, 0, true));
|
commands.Add(new _Stats("stats", "view your stats or another player's. syntax: !stats", "xlrstats", Player.Permission.User, 0, true));
|
||||||
commands.Add(new TopStats("topstats", "view the top 4 players on this server. syntax: !topstats", "xlrtopstats", Player.Permission.User, 0, false));
|
commands.Add(new TopStats("topstats", "view the top 4 players on this server. syntax: !topstats", "xlrtopstats", Player.Permission.User, 0, false));
|
||||||
commands.Add(new Reload("reload", "reload configurations. syntax: !reload", "reload", Player.Permission.Owner, 0, false));
|
commands.Add(new Reload("reload", "reload configurations. syntax: !reload", "reload", Player.Permission.Owner, 0, false));
|
||||||
/*
|
commands.Add(new Balance("balance", "balance teams. syntax !balance", "bal", Player.Permission.Moderator, 0, false));
|
||||||
commands.Add(new commands { command = "stats", desc = "view your server stats.", requiredPer = 0 });
|
commands.Add(new GoTo("goto", "teleport to selected player. syntax !goto", "go", Player.Permission.SeniorAdmin, 1, true));
|
||||||
commands.Add(new commands { command = "speed", desc = "change player speed. syntax: !speed <number>", requiredPer = 3 });
|
commands.Add(new Flag("flag", "flag a suspicious player and announce to admins on join . syntax !flag <player>:", "flag", Player.Permission.Moderator, 1, true));
|
||||||
commands.Add(new commands { command = "gravity", desc = "change game gravity. syntax: !gravity <number>", requiredPer = 3 });
|
commands.Add(new _Report("report", "report a player for suspicious behaivor. syntax !report <player> <reason>", "rep", Player.Permission.User, 2, true));
|
||||||
|
commands.Add(new Reports("reports", "get most recent reports. syntax !reports", "reports", Player.Permission.Moderator, 0, false));
|
||||||
commands.Add(new commands { command = "version", desc = "view current app version.", requiredPer = 0 });*/
|
commands.Add(new _Tell("tell", "send onscreen message to player. synrax !tell <player> <message>", "t", Player.Permission.Moderator, 2, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
//Objects
|
//Objects
|
||||||
@ -1143,6 +1202,8 @@ namespace IW4MAdmin
|
|||||||
public Heartbeat HB;
|
public Heartbeat HB;
|
||||||
public String Website;
|
public String Website;
|
||||||
public String Gametype;
|
public String Gametype;
|
||||||
|
public int totalKills = 0;
|
||||||
|
public List<Report> Reports;
|
||||||
|
|
||||||
//Info
|
//Info
|
||||||
private String IP;
|
private String IP;
|
||||||
@ -1157,7 +1218,6 @@ namespace IW4MAdmin
|
|||||||
private int messageTime;
|
private int messageTime;
|
||||||
private TimeSpan lastMessage;
|
private TimeSpan lastMessage;
|
||||||
private int nextMessage;
|
private int nextMessage;
|
||||||
private int errors = 0;
|
|
||||||
private String IW_Ver;
|
private String IW_Ver;
|
||||||
private int maxClients;
|
private int maxClients;
|
||||||
private Dictionary<String, Object> Macros;
|
private Dictionary<String, Object> Macros;
|
||||||
|
@ -57,7 +57,10 @@ namespace IW4MAdmin
|
|||||||
|
|
||||||
public static String removeNastyChars(String str)
|
public static String removeNastyChars(String str)
|
||||||
{
|
{
|
||||||
return str.Replace("`", "").Replace("\\", "").Replace("\"", "").Replace("^", "").Replace(""", "''").Replace("&", "&").Replace("\"", "''");
|
if (str != null)
|
||||||
|
return str.Replace("`", "").Replace("\\", "").Replace("\"", "").Replace("^", "").Replace(""", "''").Replace("&", "&").Replace("\"", "''");
|
||||||
|
else
|
||||||
|
return String.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int GetLineNumber(Exception ex)
|
public static int GetLineNumber(Exception ex)
|
||||||
@ -86,6 +89,8 @@ namespace IW4MAdmin
|
|||||||
{
|
{
|
||||||
case Player.Permission.Banned:
|
case Player.Permission.Banned:
|
||||||
return "^1" + Player.Permission.Banned;
|
return "^1" + Player.Permission.Banned;
|
||||||
|
case Player.Permission.Flagged:
|
||||||
|
return "^0" + Player.Permission.Flagged;
|
||||||
case Player.Permission.Owner:
|
case Player.Permission.Owner:
|
||||||
return "^5" + Player.Permission.Owner;
|
return "^5" + Player.Permission.Owner;
|
||||||
case Player.Permission.User:
|
case Player.Permission.User:
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
VERSION: 0.6
|
VERSION: 0.7
|
||||||
CHANGELOG:
|
CHANGELOG:
|
||||||
-stability fixes
|
-rcon tweaks
|
||||||
-welcome has post-fixed connection indicator
|
-so much stuff cant remember
|
||||||
|
Loading…
x
Reference in New Issue
Block a user