I need Banning System For 5165

10/02/2010 15:10 sohaib#1
hi, i have a conquer private server version 5165

i'm asking if there is a banning system( not botjail)

because i already have botjail

i want something who close the account or a command who cut the account file and put it in folder (banned) and another to unban

is it possible?

and i'm asking of ip ban is possible to make it in 5165?


thx
10/02/2010 15:15 khaled2010s`#2
talk to me in me email
[Only registered and activated users can see links. Click Here To Register...]
10/02/2010 15:43 _Vodka#3
search for my old account .Summer.

DL the source CoSX wich I released on it.

Take the ban system from it.

Gameworker.cs and Database.cs contains it.
10/02/2010 16:52 sohaib#4
okay , i added the required scripts in Database.cs and the script who shows yu have been banned the gameworker.cs , but icouldn't understand the command in chat.cs

Quote:
public static void BANPLAYER(string Name, string by)
{
if (!File.Exists(@"C:\CoSX\Database\Bans\" + Name + ".ban"))
{
FileStream FS = new FileStream(@"C:\CoSX\Database\Bans\" + Name + ".ban", FileMode.CreateNew);
BinaryWriter BW = new BinaryWriter(FS);
BW.Write(Name);
BW.Write(by);
BW.Write("-BanTime: " + DateTime.Now);
BW.Close();
FS.Close();
}
and i got another problem too, i can't download the database so i just created a text file called banname.txt

i tryied to write the username in the banname.txt but it didn't banned,

please explain me how to use the command the if i did every thing right
10/02/2010 17:15 _Vodka#5
Open Gameworker.cs and find:
Code:
                                GC.MessageID = (uint)Rnd.Next(50000);
                                GC.Soc = StO.Sock;
Under it put:
Code:
                                if (GC.AuthInfo.LogonType == 3)
                                {
                                    GC.AddSend(Packets.SystemMessage(GC.MessageID, "You have been banned!"));
                                }
Open database.cs and put:
Code:
        public static bool CheckBan(string Name)
        {
            if (File.Exists(@"C:\OldCODB\banname.txt"))
            {
                string[] Lines = File.ReadAllLines(@"C:\OldCODB\banname.txt");
                foreach (string line in Lines)
                {
                    if (line.Contains(Name))
                        return true;
                }
            }
            return false;
        }
        public static void AddBan(string Name)
        {
            if (!File.Exists(@"C:\OldCODB\banname.txt"))
            {
                File.AppendAllText(@"C:\OldCODB\banname.txt", Name + "\r\n");
            }
            else
            {
                if (!CheckBan(Name))
                {
                    File.AppendAllText(@"C:\OldCODB\banname.txt", Name + "\r\n");
                }
            }
        }
Now find:
Code:
public static Main.AuthWorker.AuthInfo Authenticate(string User, string Password)
replace it with:
Code:
public static Main.AuthWorker.AuthInfo Authenticate(string User, string Password)
        {
            Main.AuthWorker.AuthInfo Info = new NewestCOServer.Main.AuthWorker.AuthInfo();
            Info.Account = User;

            try
            {
                while (File.Exists(@"C:\OldCODB\Users\" + User + ".usr"))
                {
                    FileStream FS = new FileStream(@"C:\OldCODB\Users\" + User + ".usr", FileMode.Open);
                    BinaryReader BR = new BinaryReader(FS);
                    string RealPassword = Main.PassCrypto.EncryptPassword(Encoding.ASCII.GetString(BR.ReadBytes(BR.ReadByte())));
                    string[] FileCaseSensitive = Directory.GetFiles(@"C:\OldCODB\Users\",User + ".usr");
                    string RealAccount = Path.GetFileNameWithoutExtension(FileCaseSensitive[0]);
                    if (RealPassword == Password && RealAccount == User)
                    {
                        Info.Status = Encoding.ASCII.GetString(BR.ReadBytes(BR.ReadByte()));

                        Info.Character = "";
                        if (BR.BaseStream.Position != BR.BaseStream.Length)
                        {
                            byte len = BR.ReadByte();
                            Info.Character = Encoding.ASCII.GetString(BR.ReadBytes(len));
                        }

                        if (Info.Character == "")
                            Info.LogonType = 2;
                        else
                            Info.LogonType = 1;
                        if (CheckBan(RealAccount))
                            Info.LogonType = 3;
                    }
                    else
                        Info.LogonType = 255;
                    BR.Close();
                    FS.Close();

                    return Info;
                }
                Info.LogonType = 255;
            }
            catch (Exception Exc) { Console.WriteLine(Exc); }
            return Info;
        }
Now in chat.cs put this command:
Code:
                        #region ban
                        if (Cmd[0] == "/ban")
                        {
                            foreach (Character C in World.H_Chars.Values)
                            {
                                if (Cmd[1] == C.Name)
                                {
                                        BANPLAYER(C.Name, GC.MyChar.Name);
                                        C.MyClient.Soc.Disconnect(false);
                                        Database.AddBan(C.MyClient.AuthInfo.Account);
                                        C.MyClient.Disconnect();
                                        Game.World.SendMsgToAll(GC.MyChar.Name, C.Name + " have been banned by " + GC.MyChar.Name + "! (An abuse file have been created to check if he abused)", 2011, 0);//Fixed
                                }
                            }
                        }
                        #endregion
Now put in chat.cs put:
Code:
        public static void BANPLAYER(string Name, string by)
        {
            if (!File.Exists(@"C:\OldCODB\Bans\" + Name + ".txt"))
            {
                FileStream FS = new FileStream(@"C:\OldCODB\Bans\" + Name + ".txt", FileMode.CreateNew);
                StreamWriter SW = new StreamWriter(FS);
                SW.WriteLine(Name);
                SW.WriteLine(by);
                SW.WriteLine("BanTime: " + DateTime.Now);
                SW.Close();
                FS.Close();
            }
        }
Now make a folder in OldCODB called Bans.
Then it contains who got banned and who banned them.
Then make a textfile called banname.txt in OldCODB.
Thats where all bans are.
To unban, just remove the name from banname.txt.

Goodluck
10/02/2010 17:24 Arcо#6
Wow, yours has a whole bunch of unneeded stuff.
@OP
My advice is use Spare2's ban system. Its very simple and efficient.
10/02/2010 17:28 _Vodka#7
Quote:
Originally Posted by Аrco View Post
Wow, yours has a whole bunch of unneeded stuff.
@OP
My advice is use Spare2's ban system. Its very simple and efficient.
it is that, just some extra stuff. (I think)
such as the banfolder thing to see who bans who.

just took it from an old source.
10/02/2010 17:34 Arcо#8
Quote:
Originally Posted by _Vodka View Post
it is that, just some extra stuff. (I think)
such as the banfolder thing to see who bans who.

just took it from an old source.
This one is much simpler and more efficient.

@OP [Only registered and activated users can see links. Click Here To Register...]
10/02/2010 17:39 _Vodka#9
Quote:
Originally Posted by Аrco View Post
This one is much simpler and more efficient.

@OP [Only registered and activated users can see links. Click Here To Register...]
is exactly same.
I just putted the whobanned/when in.
10/03/2010 00:42 peterpiper99#10
Wow, I went by Spares guide, but I can't find:

if (Game.World.H_Chars.Contains(GC.MyChar.EntityID))

Anywhere.
10/03/2010 01:38 Arcо#11
Probably with Game in the reference.