Register for your free account! | Forgot your password?

You last visited: Today at 20:39

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[Release]Another report system

Discussion on [Release]Another report system within the CO2 PServer Guides & Releases forum part of the CO2 Private Server category.

Reply
 
Old   #1
 
xScott's Avatar
 
elite*gold: 0
Join Date: Nov 2009
Posts: 322
Received Thanks: 63
[Release]Another report system

I did this for educational purposes and thought i'd release it.
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);

        }


    }
}
Then all you need to do is code the command, this is how i did it.
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
Im going to eventually alter this so it checks the player being reported against accounts in the database, and wont write to the file unless the character exists.

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;
        }
I used templates from how the portals were loaded etc, gonna play around with it abit more so i know abit more about using MySQL.

Your also onn need to add the following namespace to the class.
Code:
using MySqlHandler;
Your also gonna have to define AccountExists; i did it at the top
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";
Heres an example how how i added it to the Chat.cs:
xScott is offline  
Thanks
6 Users
Old 05/27/2010, 04:19   #2
 
hunterman01's Avatar
 
elite*gold: 20
Join Date: Dec 2006
Posts: 945
Received Thanks: 175
Glad your starting to get better scott
hunterman01 is offline  
Thanks
1 User
Old 05/27/2010, 05:16   #3
 
Arcо's Avatar
 
elite*gold: 0
Join Date: Oct 2009
Posts: 8,765
Received Thanks: 5,291
Very impressed.
Glad to see you advancing in C# scott!
Arcо is offline  
Thanks
2 Users
Old 05/27/2010, 13:34   #4
 
QuickCo's Avatar
 
elite*gold: 0
Join Date: Jan 2010
Posts: 139
Received Thanks: 45
great I like that release good luck
QuickCo is offline  
Thanks
2 Users
Old 05/27/2010, 17:14   #5
 
scottdavey's Avatar
 
elite*gold: 0
Join Date: Dec 2006
Posts: 684
Received Thanks: 238
Good work
scottdavey is offline  
Thanks
1 User
Old 05/27/2010, 17:33   #6
 
elite*gold: 0
Join Date: Sep 2008
Posts: 1,683
Received Thanks: 505
Scott, when you asked me what you were doing wrong, and told me what you were working on, I was impressed, when you solved the problem, without any of my help, I was impressed, but now that I see the actual thing, I'm even more impressed.
You are doing fantastic Scott, keep up.
Basser is offline  
Thanks
2 Users
Old 05/27/2010, 17:37   #7
 
QuickCo's Avatar
 
elite*gold: 0
Join Date: Jan 2010
Posts: 139
Received Thanks: 45
nice to see members as saying that about other people
QuickCo is offline  
Old 05/27/2010, 17:38   #8
 
xScott's Avatar
 
elite*gold: 0
Join Date: Nov 2009
Posts: 322
Received Thanks: 63
Thanks (: working on the mql thing now ;o
xScott is offline  
Old 05/27/2010, 18:27   #9
 
xScott's Avatar
 
elite*gold: 0
Join Date: Nov 2009
Posts: 322
Received Thanks: 63
/updated, now has method to check database character exists :P
xScott is offline  
Old 05/30/2010, 00:13   #10
 
_Emme_'s Avatar
 
elite*gold: 1142
Join Date: Aug 2006
Posts: 2,464
Received Thanks: 1,161
For the reports, use Assert.IsEqual after you get one of the properties, continue if nothing of the old report was found on the new one, else continue on using the IsEqual<Type> method.

Although, this only works in some Visual Studio that supports UnitTesting,

Goodluck.
_Emme_ is offline  
Thanks
1 User
Reply


Similar Threads Similar Threads
[RELEASE]Report player
05/27/2010 - CO2 PServer Guides & Releases - 19 Replies
Hello Elitepvpers, this is how you could make a report a player system for the 5165source. First open Chat.cs and put this command for players: if (Cmd == "/report") { if (Cmd.Length == 3) { REPORTPLAYER(Cmd, Cmd); GC.LocalMessage(2000, "You have reported: " + Cmd + " For: " + Cmd); }
[Release]e*PvP Report-Helper
01/08/2010 - Main - 18 Replies
German - Aktuelle Version: V0.1 Ich hab hier mal ein kleines Programm geschrieben welches das reporten auf e*PvP vereinfachen soll, im Großen und Ganzen bekommt man durch ein paar Klicks nen vorgefertigten Text den man dann posten kann (bzw als Report abschickt) Der Hintergrund dazu ist das jeder sieht das reportet wurde und die Mods keine doppelten Reports bekommen, der User gleich sieht was er falsch gemacht hat und man ihn auf die Regeln verweist. Damit ihr euch auch was drunter...



All times are GMT +2. The time now is 20:39.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.