more plugin tweaks, added console interface!
This commit is contained in:
parent
7ca0b654ac
commit
d42a329097
@ -107,7 +107,6 @@
|
|||||||
<Compile Include="Command.cs" />
|
<Compile Include="Command.cs" />
|
||||||
<Compile Include="Connection.cs" />
|
<Compile Include="Connection.cs" />
|
||||||
<Compile Include="Heartbeat.cs" />
|
<Compile Include="Heartbeat.cs" />
|
||||||
<Compile Include="Helpers.cs" />
|
|
||||||
<Compile Include="Main.cs" />
|
<Compile Include="Main.cs" />
|
||||||
<Compile Include="Manager.cs" />
|
<Compile Include="Manager.cs" />
|
||||||
<Compile Include="Plugins.cs" />
|
<Compile Include="Plugins.cs" />
|
||||||
@ -141,7 +140,7 @@
|
|||||||
<Content Include="plugins\SamplePlugin.dll">
|
<Content Include="plugins\SamplePlugin.dll">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
<Content Include="plugins\Webfront Plugin.dll">
|
<Content Include="plugins\WebfrontPlugin.dll">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
<Content Include="version.txt">
|
<Content Include="version.txt">
|
||||||
@ -157,7 +156,7 @@
|
|||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
<Content Include="webfront\graph.html">
|
<Content Include="webfront\graph.html">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
<Content Include="webfront\header.html">
|
<Content Include="webfront\header.html">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
@ -44,6 +44,19 @@ namespace IW4MAdmin
|
|||||||
if (serverManager.getServers() != null)
|
if (serverManager.getServers() != null)
|
||||||
Program.getManager().mainLog.Write("IW4M Now Initialized!", Log.Level.Production);
|
Program.getManager().mainLog.Write("IW4M Now Initialized!", Log.Level.Production);
|
||||||
|
|
||||||
|
String userInput;
|
||||||
|
Server serverToExecuteOn = serverManager.getServers()[0];
|
||||||
|
Player Origin = new Player("IW4MAdmin Console", "", -1, Player.Permission.Console, -1, "", 0, "");
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
userInput = Console.ReadLine();
|
||||||
|
Event E = new Event(Event.GType.Say, userInput, Origin, null, serverToExecuteOn);
|
||||||
|
Origin.lastEvent = E;
|
||||||
|
serverToExecuteOn.processEvent(E);
|
||||||
|
Console.Write('>');
|
||||||
|
|
||||||
|
} while (userInput != null && serverManager.isRunning());
|
||||||
|
|
||||||
serverMGRThread.Join();
|
serverMGRThread.Join();
|
||||||
serverManager.mainLog.Write("Shutting down IW4MAdmin...", Log.Level.Debug);
|
serverManager.mainLog.Write("Shutting down IW4MAdmin...", Log.Level.Debug);
|
||||||
|
@ -60,16 +60,20 @@ namespace IW4MAdmin
|
|||||||
if (S == null)
|
if (S == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!isIW4MStillRunning(S.pID()))
|
if (!isIW4MStillRunning(S.pID()) || !S.isRunning)
|
||||||
{
|
{
|
||||||
Thread Defunct = ThreadList[S.pID()];
|
Thread Defunct = ThreadList[S.pID()];
|
||||||
|
|
||||||
|
if (!S.isRunning)
|
||||||
|
Utilities.shutdownInterface(S.pID());
|
||||||
|
|
||||||
S.isRunning = false;
|
S.isRunning = false;
|
||||||
if (Defunct != null)
|
if (Defunct != null)
|
||||||
{
|
{
|
||||||
Defunct.Join();
|
Defunct.Join();
|
||||||
ThreadList[S.pID()] = null;
|
ThreadList[S.pID()] = null;
|
||||||
}
|
}
|
||||||
mainLog.Write("Server with PID #" + S.pID() + " no longer appears to be running.", Log.Level.Debug);
|
mainLog.Write("Server with PID #" + S.pID() + " can no longer be monitored.", Log.Level.Debug);
|
||||||
activePIDs.Remove(S.pID());
|
activePIDs.Remove(S.pID());
|
||||||
defunctServers.Add(S);
|
defunctServers.Add(S);
|
||||||
}
|
}
|
||||||
@ -98,6 +102,11 @@ namespace IW4MAdmin
|
|||||||
ThreadList[T.Key].Join();
|
ThreadList[T.Key].Join();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool isRunning()
|
||||||
|
{
|
||||||
|
return activePIDs.Count != 0;
|
||||||
|
}
|
||||||
|
|
||||||
public List<Server> getServers()
|
public List<Server> getServers()
|
||||||
{
|
{
|
||||||
return Servers;
|
return Servers;
|
||||||
|
@ -40,6 +40,7 @@ namespace IW4MAdmin
|
|||||||
assemblies.Add(assembly);
|
assemblies.Add(assembly);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int totalLoaded = 0;
|
||||||
foreach (Assembly Plugin in assemblies)
|
foreach (Assembly Plugin in assemblies)
|
||||||
{
|
{
|
||||||
if (Plugin != null)
|
if (Plugin != null)
|
||||||
@ -47,13 +48,14 @@ namespace IW4MAdmin
|
|||||||
Type[] types = Plugin.GetTypes();
|
Type[] types = Plugin.GetTypes();
|
||||||
foreach(Type assemblyType in types)
|
foreach(Type assemblyType in types)
|
||||||
{
|
{
|
||||||
if(assemblyType.IsClass && assemblyType.BaseType.Name == "Notify")
|
if(assemblyType.IsClass && assemblyType.BaseType.Name == "Plugin")
|
||||||
{
|
{
|
||||||
Object notifyObject = Activator.CreateInstance(assemblyType);
|
Object notifyObject = Activator.CreateInstance(assemblyType);
|
||||||
Plugin newNotify = (Plugin)notifyObject;
|
Plugin newNotify = (Plugin)notifyObject;
|
||||||
potentialNotifies.Add(newNotify);
|
potentialNotifies.Add(newNotify);
|
||||||
newNotify.onLoad();
|
newNotify.onLoad();
|
||||||
Program.getManager().mainLog.Write("Loaded event plugin \"" + assemblyType.Name + "\"", Log.Level.All);
|
Program.getManager().mainLog.Write("Loaded plugin \"" + newNotify.Name + "\"" + " [" + newNotify.Version + "]", Log.Level.Debug);
|
||||||
|
totalLoaded++;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (assemblyType.IsClass && assemblyType.BaseType.Name == "Command")
|
else if (assemblyType.IsClass && assemblyType.BaseType.Name == "Command")
|
||||||
@ -61,14 +63,14 @@ namespace IW4MAdmin
|
|||||||
Object commandObject = Activator.CreateInstance(assemblyType);
|
Object commandObject = Activator.CreateInstance(assemblyType);
|
||||||
Command newCommand = (Command)commandObject;
|
Command newCommand = (Command)commandObject;
|
||||||
potentialCommands.Add(newCommand);
|
potentialCommands.Add(newCommand);
|
||||||
Program.getManager().mainLog.Write("Loaded command plugin \"" + newCommand.Name + "\"", Log.Level.All);
|
Program.getManager().mainLog.Write("Registered command \"" + newCommand.Name + "\"", Log.Level.Debug);
|
||||||
|
totalLoaded++;
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
|
||||||
Program.getManager().mainLog.Write("Ignoring invalid plugin \"" + assemblyType.Name + "\"", Log.Level.All);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Program.getManager().mainLog.Write("Loaded " + totalLoaded + " plugins.", Log.Level.Production);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
136
Admin/Server.cs
136
Admin/Server.cs
@ -14,7 +14,6 @@ namespace IW4MAdmin
|
|||||||
{
|
{
|
||||||
public IW4MServer(string address, int port, string password, int H, int PID) : base(address, port, password, H, PID)
|
public IW4MServer(string address, int port, string password, int H, int PID) : base(address, port, password, H, PID)
|
||||||
{
|
{
|
||||||
playerHistory = new Queue<pHistory>();
|
|
||||||
commandQueue = new Queue<string>();
|
commandQueue = new Queue<string>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -429,8 +428,22 @@ namespace IW4MAdmin
|
|||||||
{
|
{
|
||||||
Event curEvent = events.Peek();
|
Event curEvent = events.Peek();
|
||||||
processEvent(curEvent);
|
processEvent(curEvent);
|
||||||
foreach (Notify E in PluginImporter.potentialNotifies)
|
foreach (Plugin P in PluginImporter.potentialNotifies)
|
||||||
E.onEvent(curEvent);
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
P.onEvent(curEvent);
|
||||||
|
}
|
||||||
|
|
||||||
|
catch (Exception Except)
|
||||||
|
{
|
||||||
|
Log.Write(String.Format("The plugin \"{0}\" (v{1}) generated an error. ( see log )", P.Name, P.Version), Log.Level.Production);
|
||||||
|
Log.Write(String.Format("Error Message: {0}", Except.Message), Log.Level.Debug);
|
||||||
|
Log.Write(String.Format("Error Trace: {0}", Except.StackTrace), Log.Level.Debug);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
events.Dequeue();
|
events.Dequeue();
|
||||||
}
|
}
|
||||||
if (commandQueue.Count > 0)
|
if (commandQueue.Count > 0)
|
||||||
@ -465,6 +478,7 @@ namespace IW4MAdmin
|
|||||||
|
|
||||||
#if DEBUG == false
|
#if DEBUG == false
|
||||||
Broadcast("IW4M Admin is now ^2ONLINE");
|
Broadcast("IW4M Admin is now ^2ONLINE");
|
||||||
|
int numExceptions = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
while (isRunning)
|
while (isRunning)
|
||||||
@ -480,7 +494,7 @@ namespace IW4MAdmin
|
|||||||
{
|
{
|
||||||
while (playerHistory.Count > 144 ) // 12 times a minute for 12 hours
|
while (playerHistory.Count > 144 ) // 12 times a minute for 12 hours
|
||||||
playerHistory.Dequeue();
|
playerHistory.Dequeue();
|
||||||
playerHistory.Enqueue(new pHistory(lastCount, clientnum));
|
playerHistory.Enqueue(new PlayerHistory(lastCount, clientnum));
|
||||||
playerCountStart = DateTime.Now;
|
playerCountStart = DateTime.Now;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -493,21 +507,9 @@ namespace IW4MAdmin
|
|||||||
else
|
else
|
||||||
nextMessage++;
|
nextMessage++;
|
||||||
start = DateTime.Now;
|
start = DateTime.Now;
|
||||||
//if (timesFailed <= 3)
|
|
||||||
// HB.Send();
|
|
||||||
|
|
||||||
String checkVer = new Connection("http://raidmax.org/IW4M/Admin/version.php").Read();
|
|
||||||
double checkVerNum;
|
|
||||||
double.TryParse(checkVer, out checkVerNum);
|
|
||||||
if (checkVerNum != Program.Version && checkVerNum != 0 && !checkedForOutdate)
|
|
||||||
{
|
|
||||||
messages.Add("^5IW4M Admin ^7is outdated. Please ^5update ^7to version " + checkVerNum);
|
|
||||||
checkedForOutdate = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
if ((DateTime.Now - lastPoll).Milliseconds > 300)
|
||||||
|
|
||||||
if ((DateTime.Now - lastPoll).Milliseconds > 750)
|
|
||||||
{
|
{
|
||||||
int numberRead = 0;
|
int numberRead = 0;
|
||||||
int activeClients = 0;
|
int activeClients = 0;
|
||||||
@ -583,8 +585,18 @@ namespace IW4MAdmin
|
|||||||
#if DEBUG == false
|
#if DEBUG == false
|
||||||
catch (Exception E)
|
catch (Exception E)
|
||||||
{
|
{
|
||||||
Log.Write("Something unexpected occured. Hopefully we can ignore it :)", Log.Level.All);
|
numExceptions++;
|
||||||
|
Log.Write("Unexpected error on \"" + hostname + "\"", Log.Level.Debug);
|
||||||
|
Log.Write("Error Message: " + E.Message, Log.Level.Debug);
|
||||||
|
Log.Write("Error Trace: " + E.StackTrace, Log.Level.Debug);
|
||||||
|
if (numExceptions < 30)
|
||||||
continue;
|
continue;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Log.Write("Maximum number of unhandled exceptions reached for \"" + hostname + "\"", Log.Level.Production);
|
||||||
|
events.Enqueue(new Event(Event.GType.Stop, "Monitoring stopping because of max exceptions reached", null, null, this));
|
||||||
|
isRunning = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -655,9 +667,10 @@ namespace IW4MAdmin
|
|||||||
Bans = clientDB.getBans();
|
Bans = clientDB.getBans();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
catch (Exception E)
|
catch (Exception E)
|
||||||
{
|
{
|
||||||
Log.Write("Error during initialization - " + E.Message +"--" + E.StackTrace, Log.Level.All);
|
Log.Write("Error during initialization - " + E.Message + "--" + E.StackTrace, Log.Level.All);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -696,18 +709,6 @@ namespace IW4MAdmin
|
|||||||
|
|
||||||
if (E.Origin != E.Target)
|
if (E.Origin != E.Target)
|
||||||
{
|
{
|
||||||
/*E.Origin.stats.Kills += 1;
|
|
||||||
E.Origin.stats.updateKDR();
|
|
||||||
|
|
||||||
E.Target.stats.Deaths += 1;
|
|
||||||
E.Target.stats.updateKDR();
|
|
||||||
|
|
||||||
//Skills.updateNewSkill(E.Origin, E.Target);
|
|
||||||
statDB.updatePlayer(E.Origin);
|
|
||||||
statDB.updatePlayer(E.Target);
|
|
||||||
|
|
||||||
totalKills++;*/
|
|
||||||
Log.Write(E.Origin.Name + " killed " + E.Target.Name + " with a " + E.Data, Log.Level.Debug);
|
|
||||||
events.Enqueue(new Event(Event.GType.Death, E.Data, E.Target, null, this));
|
events.Enqueue(new Event(Event.GType.Death, E.Data, E.Target, null, this));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -720,7 +721,6 @@ namespace IW4MAdmin
|
|||||||
|
|
||||||
if (E.Type == Event.GType.Say)
|
if (E.Type == Event.GType.Say)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (E.Data.Length < 2) // ITS A LIE!
|
if (E.Data.Length < 2) // ITS A LIE!
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -738,19 +738,8 @@ namespace IW4MAdmin
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (E.Data.Substring(0, 1) != "!") // Not a command so who gives an F?
|
if (E.Data.Substring(0, 1) == "!" || E.Origin.Level == Player.Permission.Console)
|
||||||
{
|
{
|
||||||
E.Data = SharedLibrary.Utilities.stripColors(SharedLibrary.Utilities.cleanChars(E.Data));
|
|
||||||
if (E.Data.Length > 50)
|
|
||||||
E.Data = E.Data.Substring(0, 50) + "...";
|
|
||||||
while (chatHistory.Count > Math.Ceiling((double)clientnum/2))
|
|
||||||
chatHistory.RemoveAt(0);
|
|
||||||
|
|
||||||
chatHistory.Add(new Chat(E.Origin, E.Data, DateTime.Now));
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
Command C = E.isValidCMD(commands);
|
Command C = E.isValidCMD(commands);
|
||||||
|
|
||||||
if (C != null)
|
if (C != null)
|
||||||
@ -763,7 +752,19 @@ namespace IW4MAdmin
|
|||||||
Log.Write("Requested event requiring target does not have a target!", Log.Level.Debug);
|
Log.Write("Requested event requiring target does not have a target!", Log.Level.Debug);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
C.Execute(E);
|
C.Execute(E);
|
||||||
|
}
|
||||||
|
|
||||||
|
catch (Exception Except)
|
||||||
|
{
|
||||||
|
Log.Write(String.Format("A command request \"{0}\" generated an error.", C.Name, Log.Level.Debug));
|
||||||
|
Log.Write(String.Format("Error Message: {0}", Except.Message), Log.Level.Debug);
|
||||||
|
Log.Write(String.Format("Error Trace: {0}", Except.StackTrace), Log.Level.Debug);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -776,6 +777,20 @@ namespace IW4MAdmin
|
|||||||
|
|
||||||
else
|
else
|
||||||
E.Origin.Tell("You entered an invalid command!");
|
E.Origin.Tell("You entered an invalid command!");
|
||||||
|
}
|
||||||
|
|
||||||
|
else // Not a command so who gives an F?
|
||||||
|
{
|
||||||
|
E.Data = SharedLibrary.Utilities.stripColors(SharedLibrary.Utilities.cleanChars(E.Data));
|
||||||
|
if (E.Data.Length > 50)
|
||||||
|
E.Data = E.Data.Substring(0, 50) + "...";
|
||||||
|
while (chatHistory.Count > Math.Ceiling((double)clientnum / 2))
|
||||||
|
chatHistory.RemoveAt(0);
|
||||||
|
|
||||||
|
chatHistory.Add(new Chat(E.Origin, E.Data, DateTime.Now));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -784,35 +799,13 @@ namespace IW4MAdmin
|
|||||||
{
|
{
|
||||||
Log.Write("New map loaded - " + clientnum + " active players", Log.Level.Debug);
|
Log.Write("New map loaded - " + clientnum + " active players", Log.Level.Debug);
|
||||||
|
|
||||||
Dictionary<String, String> infoResponseDict = new Dictionary<String, String>();
|
String newMapName = getDvar("mapname").current;
|
||||||
String[] infoResponse = E.Data.Split('\\');
|
|
||||||
|
|
||||||
for (int i = 0; i < infoResponse.Length; i++)
|
|
||||||
{
|
|
||||||
if (i % 2 == 0 || infoResponse[i] == String.Empty)
|
|
||||||
continue;
|
|
||||||
infoResponseDict.Add(infoResponse[i], infoResponse[i + 1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
String newMapName = null;
|
|
||||||
infoResponseDict.TryGetValue("mapname", out newMapName);
|
|
||||||
|
|
||||||
if (newMapName != null)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Map newMap = maps.Find(m => m.Name.Equals(newMapName));
|
Map newMap = maps.Find(m => m.Name.Equals(newMapName));
|
||||||
|
|
||||||
|
if (newMap != null)
|
||||||
mapname = newMap.Alias;
|
mapname = newMap.Alias;
|
||||||
}
|
|
||||||
|
|
||||||
catch (Exception)
|
|
||||||
{
|
|
||||||
Log.Write(mapname + " doesn't appear to be in the maps.cfg", Log.Level.Debug);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
else
|
else
|
||||||
Log.Write("Could not get new mapname from InitGame line!", Log.Level.Debug);
|
mapname = newMapName;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -941,8 +934,6 @@ namespace IW4MAdmin
|
|||||||
commands.Add(new Find("find", "find player in database. syntax: !find <player>", "f", Player.Permission.SeniorAdmin, 1, false));
|
commands.Add(new Find("find", "find player in database. syntax: !find <player>", "f", Player.Permission.SeniorAdmin, 1, false));
|
||||||
commands.Add(new Rules("rules", "list server rules. syntax: !rules", "r", Player.Permission.User, 0, false));
|
commands.Add(new Rules("rules", "list server rules. syntax: !rules", "r", Player.Permission.User, 0, false));
|
||||||
commands.Add(new PrivateMessage("privatemessage", "send message to other player. syntax: !pm <player> <message>", "pm", Player.Permission.User, 2, true));
|
commands.Add(new PrivateMessage("privatemessage", "send message to other player. syntax: !pm <player> <message>", "pm", Player.Permission.User, 2, 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 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 Balance("balance", "balance teams. syntax !balance", "bal", Player.Permission.Moderator, 0, false));
|
||||||
commands.Add(new GoTo("goto", "teleport to selected player. syntax !goto", "go", Player.Permission.SeniorAdmin, 1, true));
|
commands.Add(new GoTo("goto", "teleport to selected player. syntax !goto", "go", Player.Permission.SeniorAdmin, 1, true));
|
||||||
@ -962,7 +953,6 @@ namespace IW4MAdmin
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Objects
|
//Objects
|
||||||
public Queue<pHistory> playerHistory;
|
|
||||||
private Queue<String> commandQueue;
|
private Queue<String> commandQueue;
|
||||||
|
|
||||||
//Info
|
//Info
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Admin/plugins/WebfrontPlugin.dll
Normal file
BIN
Admin/plugins/WebfrontPlugin.dll
Normal file
Binary file not shown.
@ -55,3 +55,4 @@ function drawChart() {
|
|||||||
chart.draw(data, options);
|
chart.draw(data, options);
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
{{GRAPH}}
|
||||||
|
@ -414,8 +414,10 @@
|
|||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
function searchPlayerName() {
|
function searchPlayerName() {
|
||||||
var nameValue = document.getElementById("search_playerName").value;
|
var nameValue = document.getElementById("search_playerName").value;
|
||||||
if (nameValue.length > 0)
|
if (nameValue.length > 3)
|
||||||
window.location.href = ("/player?query=" + encodeURIComponent(nameValue));
|
window.location.href = ("/player?query=" + encodeURIComponent(nameValue));
|
||||||
|
else
|
||||||
|
alert("Please enter at least 4 characters of the name");
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<div id="player_search">
|
<div id="player_search">
|
||||||
|
Binary file not shown.
Binary file not shown.
@ -77,7 +77,7 @@ namespace SamplePlugin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Stats : Notify
|
public class Stats : Plugin
|
||||||
{
|
{
|
||||||
public static StatsDB playerStats { get; private set; }
|
public static StatsDB playerStats { get; private set; }
|
||||||
|
|
||||||
@ -108,6 +108,7 @@ namespace SamplePlugin
|
|||||||
|
|
||||||
victimStats.Deaths++;
|
victimStats.Deaths++;
|
||||||
victimStats.KDR = victimStats.Kills / victimStats.Deaths;
|
victimStats.KDR = victimStats.Kills / victimStats.Deaths;
|
||||||
|
|
||||||
playerStats.updateStats(Victim, victimStats);
|
playerStats.updateStats(Victim, victimStats);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -116,6 +117,16 @@ namespace SamplePlugin
|
|||||||
{
|
{
|
||||||
playerStats = new StatsDB("stats.rm");
|
playerStats = new StatsDB("stats.rm");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override string Name
|
||||||
|
{
|
||||||
|
get { return "Basic Stats"; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public override float Version
|
||||||
|
{
|
||||||
|
get { return 0.1f; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class StatsDB : Database
|
public class StatsDB : Database
|
||||||
|
@ -57,8 +57,6 @@ namespace SharedLibrary
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Command isValidCMD(List<Command> list)
|
public Command isValidCMD(List<Command> list)
|
||||||
{
|
|
||||||
if (this.Data.Substring(0, 1) == "!")
|
|
||||||
{
|
{
|
||||||
string[] cmd = this.Data.Substring(1, this.Data.Length - 1).Split(' ');
|
string[] cmd = this.Data.Substring(1, this.Data.Length - 1).Split(' ');
|
||||||
|
|
||||||
@ -71,10 +69,6 @@ namespace SharedLibrary
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Event requestEvent(String[] line, Server SV)
|
public static Event requestEvent(String[] line, Server SV)
|
||||||
{
|
{
|
||||||
#if DEBUG == false
|
#if DEBUG == false
|
||||||
|
@ -3,11 +3,11 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace IW4MAdmin
|
namespace SharedLibrary
|
||||||
{
|
{
|
||||||
class pHistory
|
public class PlayerHistory
|
||||||
{
|
{
|
||||||
public pHistory(DateTime w, int cNum)
|
public PlayerHistory(DateTime w, int cNum)
|
||||||
{
|
{
|
||||||
When = w;
|
When = w;
|
||||||
Players = cNum;
|
Players = cNum;
|
@ -31,6 +31,7 @@ namespace SharedLibrary
|
|||||||
SeniorAdmin = 4,
|
SeniorAdmin = 4,
|
||||||
Owner = 5,
|
Owner = 5,
|
||||||
Creator = 6,
|
Creator = 6,
|
||||||
|
Console = 7,
|
||||||
}
|
}
|
||||||
|
|
||||||
public Player(string n, string id, int num, int l)
|
public Player(string n, string id, int num, int l)
|
||||||
|
@ -8,10 +8,10 @@ namespace SharedLibrary
|
|||||||
public abstract class Plugin
|
public abstract class Plugin
|
||||||
{
|
{
|
||||||
public abstract void onLoad();
|
public abstract void onLoad();
|
||||||
}
|
|
||||||
|
|
||||||
public abstract class Notify : Plugin
|
|
||||||
{
|
|
||||||
public abstract void onEvent(Event E);
|
public abstract void onEvent(Event E);
|
||||||
|
|
||||||
|
//for logging purposes
|
||||||
|
public abstract string Name { get; }
|
||||||
|
public abstract float Version { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,7 @@ namespace SharedLibrary
|
|||||||
Macros = new Dictionary<String, Object>();
|
Macros = new Dictionary<String, Object>();
|
||||||
Reports = new List<Report>();
|
Reports = new List<Report>();
|
||||||
statusPlayers = new Dictionary<string, Player>();
|
statusPlayers = new Dictionary<string, Player>();
|
||||||
|
playerHistory = new Queue<PlayerHistory>();
|
||||||
chatHistory = new List<Chat>();
|
chatHistory = new List<Chat>();
|
||||||
lastWebChat = DateTime.Now;
|
lastWebChat = DateTime.Now;
|
||||||
nextMessage = 0;
|
nextMessage = 0;
|
||||||
@ -240,6 +241,13 @@ namespace SharedLibrary
|
|||||||
{
|
{
|
||||||
if (Target.clientID > -1)
|
if (Target.clientID > -1)
|
||||||
executeCommand("tellraw " + Target.clientID + " " + Message + "^7");
|
executeCommand("tellraw " + Target.clientID + " " + Message + "^7");
|
||||||
|
|
||||||
|
if (Target.Level == Player.Permission.Console)
|
||||||
|
{
|
||||||
|
Console.ForegroundColor = ConsoleColor.Cyan;
|
||||||
|
Console.WriteLine(Utilities.stripColors(Message));
|
||||||
|
Console.ForegroundColor = ConsoleColor.Gray;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -474,6 +482,7 @@ namespace SharedLibrary
|
|||||||
public int totalKills = 0;
|
public int totalKills = 0;
|
||||||
public List<Report> Reports;
|
public List<Report> Reports;
|
||||||
public List<Chat> chatHistory;
|
public List<Chat> chatHistory;
|
||||||
|
public Queue<PlayerHistory> playerHistory { get; private set; }
|
||||||
|
|
||||||
//Info
|
//Info
|
||||||
protected String IP;
|
protected String IP;
|
||||||
|
@ -55,6 +55,7 @@
|
|||||||
<Compile Include="Dvar.cs" />
|
<Compile Include="Dvar.cs" />
|
||||||
<Compile Include="Log.cs" />
|
<Compile Include="Log.cs" />
|
||||||
<Compile Include="Map.cs" />
|
<Compile Include="Map.cs" />
|
||||||
|
<Compile Include="Miscellaneous.cs" />
|
||||||
<Compile Include="Player.cs" />
|
<Compile Include="Player.cs" />
|
||||||
<Compile Include="Plugin.cs" />
|
<Compile Include="Plugin.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
@ -171,7 +171,15 @@ namespace SharedLibrary
|
|||||||
{
|
{
|
||||||
String Match = M.Value;
|
String Match = M.Value;
|
||||||
String Identifier = M.Value.Substring(2, M.Length - 4);
|
String Identifier = M.Value.Substring(2, M.Length - 4);
|
||||||
String Replacement = Dict[Identifier].ToString();
|
Object foundVal;
|
||||||
|
Dict.TryGetValue(Identifier, out foundVal);
|
||||||
|
String Replacement;
|
||||||
|
|
||||||
|
if (foundVal != null)
|
||||||
|
Replacement = foundVal.ToString();
|
||||||
|
else
|
||||||
|
Replacement = "";
|
||||||
|
|
||||||
str = str.Replace(Match, Replacement);
|
str = str.Replace(Match, Replacement);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -367,6 +367,25 @@ namespace Webfront_Plugin
|
|||||||
return Input.Replace(Macro, buffer.ToString());
|
return Input.Replace(Macro, buffer.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Looking == "GRAPH")
|
||||||
|
{
|
||||||
|
StringBuilder buffer = new StringBuilder();
|
||||||
|
buffer.Append("<script type='text/javascript' src='//www.google.com/jsapi'></script><div id='chart_div'></div>");
|
||||||
|
buffer.Append("<script> var players = [");
|
||||||
|
int count = 1;
|
||||||
|
List<PlayerHistory> run = Servers[0].playerHistory.ToList();
|
||||||
|
foreach (PlayerHistory i in run) //need to reverse for proper timeline
|
||||||
|
{
|
||||||
|
buffer.AppendFormat("[new Date({0}, {1}, {2}, {3}, {4}), {5}]", i.When.Year, i.When.Month - 1, i.When.Day, i.When.Hour, i.When.Minute, i.Players);
|
||||||
|
if (count < run.Count)
|
||||||
|
buffer.Append(",\n");
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
buffer.Append("];\n");
|
||||||
|
buffer.Append("</script>");
|
||||||
|
return Input.Replace(Macro, buffer.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
if (Looking == "TITLE")
|
if (Looking == "TITLE")
|
||||||
return Input.Replace(Macro, "IW4MAdmin by RaidMax");
|
return Input.Replace(Macro, "IW4MAdmin by RaidMax");
|
||||||
|
|
||||||
@ -399,7 +418,7 @@ namespace Webfront_Plugin
|
|||||||
break;
|
break;
|
||||||
case "graph":
|
case "graph":
|
||||||
requestedPage = new graph();
|
requestedPage = new graph();
|
||||||
break;
|
return processTemplate(requestedPage.Load(), request.QueryString);
|
||||||
case "stats":
|
case "stats":
|
||||||
requestedPage = new stats();
|
requestedPage = new stats();
|
||||||
break;
|
break;
|
||||||
|
@ -4,7 +4,7 @@ using System.Threading;
|
|||||||
|
|
||||||
namespace Webfront_Plugin
|
namespace Webfront_Plugin
|
||||||
{
|
{
|
||||||
public class Webfront : Notify
|
public class Webfront : Plugin
|
||||||
{
|
{
|
||||||
private static Manager webManager;
|
private static Manager webManager;
|
||||||
|
|
||||||
@ -33,5 +33,15 @@ namespace Webfront_Plugin
|
|||||||
|
|
||||||
webManagerThread.Start();
|
webManagerThread.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override String Name
|
||||||
|
{
|
||||||
|
get { return "Webfront"; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public override float Version
|
||||||
|
{
|
||||||
|
get { return 0.1f; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<PostBuildEvent>copy /Y "$(TargetDir)$(TargetName).dll" "$(SolutionDir)Admin\plugins\$(TargetName).dll"</PostBuildEvent>
|
<PostBuildEvent>copy /Y "$(TargetDir)$(TargetName).dll" "$(SolutionDir)Admin\plugins\WebfrontPlugin.dll"</PostBuildEvent>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
Other similar extension points exist, see Microsoft.Common.targets.
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user