diff --git a/Admin/IW4M ADMIN.csproj b/Admin/IW4M ADMIN.csproj
index d5c080270..635d8c628 100644
--- a/Admin/IW4M ADMIN.csproj
+++ b/Admin/IW4M ADMIN.csproj
@@ -143,7 +143,9 @@
PreserveNewest
-
+
+ PreserveNewest
+
Always
diff --git a/Admin/Plugins.cs b/Admin/Plugins.cs
index 3aaa07679..550ddfad8 100644
--- a/Admin/Plugins.cs
+++ b/Admin/Plugins.cs
@@ -9,6 +9,7 @@ namespace IW4MAdmin
public class PluginImporter
{
public static List potentialPlugins = new List();
+ public static List potentialNotifies = new List();
public static bool Load()
{
@@ -46,15 +47,24 @@ namespace IW4MAdmin
Type[] types = Plugin.GetTypes();
foreach(Type assemblyType in types)
{
- if(assemblyType.IsClass && assemblyType.BaseType.Name == "Command")
+ if(assemblyType.IsClass && assemblyType.BaseType.Name == "EventNotify")
+ {
+ Object notifyObject = Activator.CreateInstance(assemblyType);
+ EventNotify newNotify = (EventNotify)notifyObject;
+ potentialNotifies.Add(newNotify);
+ Program.getManager().mainLog.Write("Loaded event plugin \"" + assemblyType.Name + "\"", Log.Level.All);
+ }
+
+ else if (assemblyType.IsClass && assemblyType.BaseType.Name == "Command")
{
Object commandObject = Activator.CreateInstance(assemblyType);
Command newCommand = (Command)commandObject;
potentialPlugins.Add(newCommand);
Program.getManager().mainLog.Write("Loaded command plugin \"" + newCommand.Name + "\"", Log.Level.All);
- }
+ }
+
else
- Program.getManager().mainLog.Write("Ignoring invalid command plugin \"" + assemblyType.Name + "\"", Log.Level.All);
+ Program.getManager().mainLog.Write("Ignoring invalid plugin \"" + assemblyType.Name + "\"", Log.Level.All);
}
}
}
diff --git a/Admin/Server.cs b/Admin/Server.cs
index 9720b181e..8128dafa3 100644
--- a/Admin/Server.cs
+++ b/Admin/Server.cs
@@ -15,13 +15,9 @@ namespace IW4MAdmin
public IW4MServer(string address, int port, string password, int H, int PID) : base(address, port, password, H, PID)
{
playerHistory = new Queue();
- commandQueue = new Queue();
+ commandQueue = new Queue();
}
- public override void initAbstractObj()
- {
- throw new NotImplementedException();
- }
override public void getAliases(List returnPlayers, Player Origin)
{
if (Origin == null)
@@ -126,6 +122,8 @@ namespace IW4MAdmin
aliasDB.updatePlayer(NewPlayer.Alias);
clientDB.updatePlayer(NewPlayer);
+ events.Enqueue(new Event(Event.GType.Connect, "", NewPlayer, null, this));
+
if (NewPlayer.Level == Player.Permission.Banned) // their guid is already banned so no need to check aliases
{
@@ -240,6 +238,7 @@ namespace IW4MAdmin
statDB.updatePlayer(Leaving);
Log.Write("Client at " + cNum + " disconnecting...", Log.Level.Debug);
+ events.Enqueue(new Event(Event.GType.Disconnect, "", Leaving, null, this));
lock (players)
{
players[cNum] = null;
@@ -410,10 +409,16 @@ namespace IW4MAdmin
while(isRunning)
{
if (events.Count > 0)
- processEvent(events.Dequeue());
+ {
+ Event curEvent = events.Peek();
+ processEvent(curEvent);
+ foreach (EventNotify E in PluginImporter.potentialNotifies)
+ E.onEvent(curEvent);
+ events.Dequeue();
+ }
if (commandQueue.Count > 0)
lastCommandPointer = Utilities.executeCommand(PID, commandQueue.Dequeue(), lastCommandPointer);
- Thread.Sleep(350);
+ Thread.Sleep(300);
}
}
@@ -556,7 +561,7 @@ namespace IW4MAdmin
}
oldLines = lines;
l_size = logFile.getSize();
- Thread.Sleep(350);
+ Thread.Sleep(300);
}
#if DEBUG == false
catch (Exception E)
@@ -701,6 +706,7 @@ namespace IW4MAdmin
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));
}
else // suicide/falling
diff --git a/Admin/lib/SharedLibary.dll b/Admin/lib/SharedLibary.dll
index cd6e22b45..cab58081a 100644
Binary files a/Admin/lib/SharedLibary.dll and b/Admin/lib/SharedLibary.dll differ
diff --git a/Admin/plugins/SamplePlugin.dll b/Admin/plugins/SamplePlugin.dll
index d991740bd..923af901b 100644
Binary files a/Admin/plugins/SamplePlugin.dll and b/Admin/plugins/SamplePlugin.dll differ
diff --git a/IW4M Admin.sln b/IW4M Admin.sln
index f2ba95549..214a3f6e7 100644
--- a/IW4M Admin.sln
+++ b/IW4M Admin.sln
@@ -5,6 +5,7 @@ VisualStudioVersion = 12.0.30723.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IW4M ADMIN", "Admin\IW4M ADMIN.csproj", "{DD5DCDA2-51DB-4B1A-922F-5705546E6115}"
ProjectSection(ProjectDependencies) = postProject
+ {4785AB75-66F3-4391-985D-63A5A049A0FA} = {4785AB75-66F3-4391-985D-63A5A049A0FA}
{D51EECEB-438A-47DA-870F-7D7B41BC24D6} = {D51EECEB-438A-47DA-870F-7D7B41BC24D6}
EndProjectSection
EndProject
diff --git a/SamplePlugin/Main.cs b/SamplePlugin/Main.cs
index eee0938d5..ecb30cdfd 100644
--- a/SamplePlugin/Main.cs
+++ b/SamplePlugin/Main.cs
@@ -38,6 +38,17 @@ namespace SamplePlugin
}
}
+ public class SampleEvent : EventNotify
+ {
+ public override void onEvent(Event E)
+ {
+ E.Owner.Broadcast("An event occured of type: ^1" + E.Type);
+
+ if (E.Data != null)
+ E.Origin.Tell(E.Data);
+ }
+ }
+
public class InvalidCommandExample
{
private void doNotDoThis() { }
diff --git a/SamplePlugin/SamplePlugin.csproj b/SamplePlugin/SamplePlugin.csproj
index b7644e6c3..af79b039c 100644
--- a/SamplePlugin/SamplePlugin.csproj
+++ b/SamplePlugin/SamplePlugin.csproj
@@ -46,6 +46,9 @@
+
+ copy /Y "$(TargetDir)$(TargetName).dll" "$(SolutionDir)Admin\plugins\$(TargetName).dll"
+