Ok so this is a messy release that I'm sure no one will use but I figured I'd throw it out there for people who want it.
What it is is a command to report a player and it will store who used the command, who was reported and the reason in a handy little database for gm's to use later.
Personally I plan to use it (or a cleaned up version) to allow moderators to report problems or hackers for when a gm is not online. It's not perfect as it is but it works.
Note: this version is CoEmu but really... it's not hard at all to convert.
Handlers>Chat.cs
PHP Code:
case "report":
{
if (CSocket.Client.isPM || CSocket.Client.isGM || CSocket.Client.isHH)
{
try
{
Monitor.Enter(Nano.ClientPool);
foreach (KeyValuePair<int, ClientSocket> Player in Nano.ClientPool)
{
if (Player.Value.Client.Name.ToLower() == Command[1].ToLower())
{
if (Player.Value.Client.isPM || Player.Value.Client.isPM)
CSocket.Send(ConquerPacket.Chat(0, "SYSTEM", CSocket.Client.Name, "GM and PM chars cannot be reported", Struct.ChatType.Top));
else
{
Result = Command1.Remove(0, Command[0].Length);
Result = Result.Remove(0, (Command[1].Length + 1));
Database.Database.ReportPlayer(CSocket, Player.Value, Result);
ConquerPacket.ToServer(ConquerPacket.Chat(0, "SYSTEM", "ALLUSERS", Player.Value.Client.Name + " has been reported by " + CSocket.Client.Name, Struct.ChatType.Center), 0);
/
}
break;
}
}
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
finally
{
Monitor.Exit(Nano.ClientPool);
}
}
break;
}
Notice you will have some undefined strings. Go up to the top of the file and see string[] Command = Message.Substring(1).Split(' ');
Place these two under that
string Command1 = Message.Substring(1);
string Result = "";
That's just what I used for clearing out the initial part of the msg so that you could write more than 1 word reasons for reporting a player. Simple but somewhat messy fix.
Now Database>Database.cs
PHP Code:
public static void ReportPlayer(ClientSocket CSocket, ClientSocket RSocket, string Report1)
{
lock (DatabaseConnection.NewConnection())
{
MySqlCommand Cmd = new MySqlCommand("insert into `Report`(`WhoReport`, `WhoReported`, `Report`) values ('" + CSocket.Client.Name + "', '" + RSocket.Client.Name + "', '" + Report1 + "')", DatabaseConnection.NewConnection());
Cmd.ExecuteNonQuery();
}
}
And for the database itself. Open up navicat and create a new database.
Mine is called "Report" with the following fields
ReportUID, int, 11, 0 notnull, key, auto incrimented
WhoReport, varchar, 20, 0, notnull
WhoReported, varchar, 20, 0, notnull
Report, varchar, 200, 0, notnull
That should be all you need, you will wanna add a bool under Characters.cs for "isHH", that's the new moderator position I am adding for players with improved server rights (such as reporting, don't want noobs spamming up the log)
You can also use this type of a thing to log server events such as errors for later reference.... but that's a different thing and I'm super tired so yah.
Enjoy,
Pro4never