It works uses ini's, When a player is reported for a certain reason, it +1's to total number of reports
Atm it still can be spammed, by making new reasons up, mispelling the name/reason etc. you'll see what i mean alter; im gonna change it soon.
Ok heres the class:
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
namespace WorldServer
{
public class ReportPlayer
{
private static int NumberOfReports;
private static bool BeenReported;
private string FILEPATH = @"[[B][COLOR="Red"]THE DIRECTORY YOU WANT TO SAVE THE INI IN[/COLOR][/B]].";
[DllImport("kernel32")]
private static extern long WritePrivateProfileString(string section, string key, string val, string filepath);
[DllImport("kernel32")]
private static extern int GetPrivateProfileString(string section, string key, string def,
StringBuilder retVal, int size, string filePath);
/// <summary>
/// Checks if the player has been reported once before.
/// If so the Section will need to be removed so the NumberOfReports will append
/// a new Value for the same key.
/// </summary>
public bool CheckPlayerReported(string Name, string Reason)
{
string temps;
StringBuilder temp = new StringBuilder(255);
int i = GetPrivateProfileString(Name, Reason, "", temp, 255, FILEPATH );
temps = System.Convert.ToString(temp);
if (temps == "")
NumberOfReports = 0;
else
NumberOfReports = int.Parse(temps);
if (NumberOfReports == 0)
BeenReported = false;
else
BeenReported = true;
return BeenReported;
}
/// <summary>
/// Gets number the number of times player has been reported so
/// the total will be NumberOfReports +1
/// </summary>
public int GetNumberReported(string Name, string Reason)
{
string temps;
StringBuilder temp = new StringBuilder(255);
int i = GetPrivateProfileString(Name, Reason, "", temp, 255, FILEPATH);
temps = System.Convert.ToString(temp);
NumberOfReports = int.Parse(temps);
return NumberOfReports;
}
/// <summary>
/// Write the account to the .ini file.
/// </summary>
public void WriteAccount(string Name, string Reason, int ReportsNumber)
{
WritePrivateProfileString(Name, Reason, Convert.ToString(ReportsNumber) , FILEPATH);
}
}
}
Note: this is in Elite-CoEmu & is VERY EASY to convert.
Code:
#region report
case "report":
{
ReportPlayer R = new ReportPlayer();
if (R.CheckPlayerReported(Command[1], Command[2]) == true)
{
int TotalReports = R.GetNumberReported(Command[1], Command[2]);
TotalReports += 1;
R.WriteAccount(Command[1], Command[2], TotalReports);
}
else
{
R.WriteAccount(Command[1], Command[2], 1);
}
break;
}
#endregion
i also need to add some sort of timer to stop mass reports.
#EDIT
Added the checking of the database, heres the method:
Code:
public bool CheckDatabase(string CharacterName)
{
MySqlCommand cmd = new MySqlCommand(MySqlCommandType.SELECT);
cmd.Select("characters").Where("Name", CharacterName);
MySqlReader r = new MySqlReader(cmd);
if (r.Read())
{
if (r.ReadString("Name") == CharacterName)
{ AccountExists = true; }
}
return AccountExists;
}
Your also onn need to add the following namespace to the class.
Code:
using MySqlHandler;
where i defined FilePath & NumberOfReports, IE:
Code:
private static int NumberOfReports;
private static bool BeenReported;
[B][COLOR="Red"] private static bool AccountExists = false;[/COLOR][/B]
private string FILEPATH = @"C:\Users\ADVENT\Documents\REPORT.ini";






