added pm command

fixed connections not incrementing
fixed formatting of ban response
added ability of multiple instances running
This commit is contained in:
RaidMax 2015-03-09 15:11:09 -05:00
parent 828afc563a
commit 2486bc9993
10 changed files with 88 additions and 34 deletions

View File

@ -1,6 +1,6 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<configuration> <configuration>
<startup> <startup>
<supportedRuntime version="v2.0.50727"/>
<supportedRuntime version="v2.0.50727"/></startup> </startup>
</configuration> </configuration>

View File

@ -171,7 +171,7 @@ namespace IW4MAdmin
if (E.Origin.getLevel() > E.Target.getLevel()) if (E.Origin.getLevel() > E.Target.getLevel())
{ {
E.Target.Ban(Message, E.Origin); E.Target.Ban(Message, E.Origin);
E.Origin.Tell("Successfully banned ^5" + E.Target.getName() + " (^7" + E.Target.getID()); E.Origin.Tell(String.Format("Sucessfully banned ^5{0} ^7({1})", E.Target.getName(), E.Target.getID()));
} }
else else
E.Origin.Tell("You cannot ban " + E.Target.getName()); E.Origin.Tell("You cannot ban " + E.Target.getName());
@ -431,4 +431,15 @@ namespace IW4MAdmin
} }
} }
class PrivateMessage : Command
{
public PrivateMessage(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.Target.Tell("^1" + E.Origin.getName() + " ^3[PM]^7 - " + E.Data);
E.Origin.Tell("Sucessfully sent message");
}
}
} }

View File

@ -17,14 +17,22 @@ namespace IW4MAdmin
public String Read() public String Read()
{ {
WebResponse Resp = ConnectionHandle.GetResponse(); try
StreamReader data_in = new StreamReader(Resp.GetResponseStream()); {
String result = data_in.ReadToEnd(); WebResponse Resp = ConnectionHandle.GetResponse();
StreamReader data_in = new StreamReader(Resp.GetResponseStream());
String result = data_in.ReadToEnd();
data_in.Close(); data_in.Close();
Resp.Close(); Resp.Close();
return result; return result;
}
catch (System.Net.WebException E)
{
return null;
}
} }
private String Location; private String Location;

View File

@ -37,7 +37,7 @@ namespace IW4MAdmin
if (Result != null && Result.Rows.Count > 0) if (Result != null && Result.Rows.Count > 0)
{ {
DataRow ResponseRow = Result.Rows[0]; DataRow ResponseRow = Result.Rows[0];
return new Player(ResponseRow["Name"].ToString(), ResponseRow["npID"].ToString(), cNum, (Player.Permission)(ResponseRow["Level"]), Convert.ToInt32(ResponseRow["Number"]), ResponseRow["LastOffense"].ToString(), ((int)ResponseRow["Connections"] + 1)); return new Player(ResponseRow["Name"].ToString(), ResponseRow["npID"].ToString(), cNum, (Player.Permission)(ResponseRow["Level"]), Convert.ToInt32(ResponseRow["Number"]), ResponseRow["LastOffense"].ToString(), (int)ResponseRow["Connections"]);
} }
else else

View File

@ -13,7 +13,7 @@
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<TargetFrameworkProfile /> <TargetFrameworkProfile />
<IsWebBootstrapper>true</IsWebBootstrapper> <IsWebBootstrapper>true</IsWebBootstrapper>
<PublishUrl>ftp://raidmax.org/IW4M/Admin/</PublishUrl> <PublishUrl>ftp://raidmax.org/</PublishUrl>
<Install>true</Install> <Install>true</Install>
<InstallFrom>Web</InstallFrom> <InstallFrom>Web</InstallFrom>
<UpdateEnabled>true</UpdateEnabled> <UpdateEnabled>true</UpdateEnabled>
@ -22,14 +22,14 @@
<UpdateIntervalUnits>Days</UpdateIntervalUnits> <UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically> <UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired> <UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions> <MapFileExtensions>false</MapFileExtensions>
<InstallUrl>http://raidmax.org/IW4M/Admin/</InstallUrl> <InstallUrl>http://raidmax.org/IW4M/Admin/</InstallUrl>
<ProductName>IW4M Administration</ProductName> <ProductName>IW4M Administration</ProductName>
<PublisherName>RaidMax LLC</PublisherName> <PublisherName>RaidMax LLC</PublisherName>
<CreateWebPageOnPublish>true</CreateWebPageOnPublish> <CreateWebPageOnPublish>true</CreateWebPageOnPublish>
<WebPage>publish.htm</WebPage> <WebPage>publish.htm</WebPage>
<ApplicationRevision>3</ApplicationRevision> <ApplicationRevision>4</ApplicationRevision>
<ApplicationVersion>0.1.0.%2a</ApplicationVersion> <ApplicationVersion>0.2.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust> <UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted> <PublishWizardCompleted>true</PublishWizardCompleted>
<BootstrapperEnabled>true</BootstrapperEnabled> <BootstrapperEnabled>true</BootstrapperEnabled>
@ -109,11 +109,20 @@
<Compile Include="Utilities.cs" /> <Compile Include="Utilities.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Content Include="version.txt" />
<None Include="App.config" /> <None Include="App.config" />
<None Include="config\maps.cfg" /> <Content Include="config\maps.cfg">
<None Include="config\messages.cfg" /> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<None Include="config\rules.cfg" /> </Content>
<None Include="config\servers.cfg" /> <Content Include="config\messages.cfg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="config\rules.cfg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="config\servers.cfg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<None Include="IW4M ADMIN_TemporaryKey.pfx" /> <None Include="IW4M ADMIN_TemporaryKey.pfx" />
<None Include="Properties\app.manifest" /> <None Include="Properties\app.manifest" />
<None Include="Properties\Settings.settings"> <None Include="Properties\Settings.settings">

View File

@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
using System.Threading;
namespace IW4MAdmin namespace IW4MAdmin
{ {
@ -9,20 +10,26 @@ namespace IW4MAdmin
static String IP; static String IP;
static int Port; static int Port;
static String RCON; static String RCON;
static double Version = 0.2;
static void Main(string[] args) static void Main(string[] args)
{ {
Console.WriteLine("====================================================="); Console.WriteLine("=====================================================");
Console.WriteLine(" IW4M ADMIN v"); Console.WriteLine(" IW4M ADMIN");
Console.WriteLine(" by RaidMax "); Console.WriteLine(" by RaidMax ");
String latestVer = checkUpdate();
if (latestVer != null)
Console.WriteLine(" Version " + Version + " (latest " + latestVer + ")");
else
Console.WriteLine(" Version " + Version + " (unable to retrieve latest)");
Console.WriteLine("====================================================="); Console.WriteLine("=====================================================");
file Config = new file("config\\servers.cfg"); file Config = new file("config\\servers.cfg");
String[] SV_CONF = Config.getParameters(3); String[] SV_CONF = Config.readAll();
double Version = 0.1;
if (SV_CONF == null || SV_CONF.Length != 3) if (SV_CONF == null || SV_CONF.Length < 1)
{ {
setupConfig(); setupConfig();
SV_CONF = new file("config\\servers.cfg").getParameters(3); SV_CONF = new file("config\\servers.cfg").getParameters(3);
@ -31,11 +38,23 @@ namespace IW4MAdmin
if (Config.getSize() > 0 && SV_CONF != null) if (Config.getSize() > 0 && SV_CONF != null)
{ {
Console.WriteLine("Starting admin on port " + SV_CONF[1]); foreach (String S in SV_CONF)
{
if (S.Length < 1)
continue;
Server IW4M; String[] sv = S.Split(':');
IW4M = new Server(SV_CONF[0], Convert.ToInt32(SV_CONF[1]), SV_CONF[2]);
IW4M.Monitor(); Console.WriteLine("Starting admin on port " + sv[1]);
Server IW4M;
IW4M = new Server(sv[0], Convert.ToInt32(sv[1]), sv[2]);
//Threading seems best here
Thread monitorThread = new Thread(new ThreadStart(IW4M.Monitor));
monitorThread.Start();
}
} }
else else
{ {
@ -58,5 +77,11 @@ namespace IW4MAdmin
Config.Write(IP + ":" + Port + ":" + RCON); Config.Write(IP + ":" + Port + ":" + RCON);
Console.WriteLine("Great! Let's go ahead and start 'er up."); Console.WriteLine("Great! Let's go ahead and start 'er up.");
} }
static String checkUpdate()
{
Connection Ver = new Connection("http://raidmax.org/IW4M/Admin/version.txt");
return Ver.Read();
}
} }
} }

View File

@ -36,7 +36,7 @@ namespace IW4MAdmin
Level = l; Level = l;
dbID = cind; dbID = cind;
LastOffense = lo; LastOffense = lo;
Connections = con; Connections = con + 1;
Warnings = 0; Warnings = 0;
} }

View File

@ -33,5 +33,5 @@ using System.Resources;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.1.*")] [assembly: AssemblyVersion("0.1.*")]
[assembly: NeutralResourcesLanguageAttribute("en")] [assembly: NeutralResourcesLanguageAttribute("en")]

View File

@ -22,7 +22,7 @@ namespace IW4MAdmin
logFile = new file("admin_" + port + ".log", true); logFile = new file("admin_" + port + ".log", true);
Log = new Log(logFile, Log.Level.Production); Log = new Log(logFile, Log.Level.Production);
players = new List<Player>(new Player[18]); players = new List<Player>(new Player[18]);
DB = new Database(port + ".dll"); DB = new Database("clients.dll");
Bans = DB.getBans(); Bans = DB.getBans();
owner = DB.getOwner(); owner = DB.getOwner();
maps = new List<Map>(); maps = new List<Map>();
@ -113,7 +113,7 @@ namespace IW4MAdmin
} }
catch (Exception E) catch (Exception E)
{ {
Log.Write("Unable to add player - " + E.Message, Log.Level.Debug); Log.Write("Unable to add player " + P.getName() + " - " + E.Message, Log.Level.Debug);
return false; return false;
} }
} }
@ -254,9 +254,9 @@ namespace IW4MAdmin
{ {
if (!intializeBasics()) if (!intializeBasics())
{ {
Log.Write("Shutting due to uncorrectable errors (check log)" + logPath, Log.Level.Production); Log.Write("Stopping " + Port + " due to uncorrectable errors (check log)" + logPath, Log.Level.Production);
Utilities.Wait(10); Utilities.Wait(10);
Environment.Exit(-1); return;
} }
//Handles new rcon requests in a fashionable manner //Handles new rcon requests in a fashionable manner
@ -717,7 +717,7 @@ namespace IW4MAdmin
commands.Add(new MapCMD("map", "change to specified map. syntax: !map", "m", Player.Permission.Administrator, 1, false)); commands.Add(new MapCMD("map", "change to specified map. syntax: !map", "m", Player.Permission.Administrator, 1, false));
commands.Add(new Find("find", "find player in database. syntax: !find <player>", "f", Player.Permission.Administrator, 1, false)); commands.Add(new Find("find", "find player in database. syntax: !find <player>", "f", Player.Permission.Administrator, 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 commands { command = "stats", desc = "view your server stats.", requiredPer = 0 }); commands.Add(new commands { command = "stats", desc = "view your server stats.", requiredPer = 0 });
commands.Add(new commands { command = "speed", desc = "change player speed. syntax: !speed <number>", requiredPer = 3 }); commands.Add(new commands { command = "speed", desc = "change player speed. syntax: !speed <number>", requiredPer = 3 });

1
Admin/version.txt Normal file
View File

@ -0,0 +1 @@
0.2