I've been thinking of making a ban command for my 5165 server but I don't know where I should put the code (not the command but the actual function code). So if anyone knows, step up blez.
Try making a definition in character.cs and then adding it to the save/load/create char sequences.Quote:
I've been thinking of making a ban command for my 5165 server but I don't know where I should put the code (not the command but the actual function code). So if anyone knows, step up blez.
public byte Ban = 0;
if (Cmd[0] == "/ban")
{
Game.Character C = Game.World.CharacterFromName(Cmd[1]);
if (C != null)
C.Ban += 1;
}
Or, to be more efficient, only add the "Ban=" (or whatever) string in the Character file once you use "/ban <name>". And then let the Auth thread check if the character is banned when it is checking acc/pass. More efficient than the auth okaying acc and then game loads all the stats and then finally reads that and then has to end the client's connection. X.xQuote:
Try making a definition in character.cs and then adding it to the save/load/create char sequences.
Then make a command somewhat like this:Code:public byte Ban = 0;
Then go to the load char sequence and under C.Loaded = true;Code:if (Cmd[0] == "/ban") { Game.Character C = Game.World.CharacterFromName(Cmd[1]); if (C != null) C.Ban += 1; }
put something like if (C.Ban >0) C.Disconnect;
get it?
Gotta point :/Quote:
Or, to be more efficient, only add the "Ban=" (or whatever) string in the Character file once you use "/ban <name>". And then let the Auth thread check if the character is banned when it is checking acc/pass. More efficient than the auth okaying acc and then game loads all the stats and then finally reads that and then ends the client connection. X.x
if (Info.LogonType != 255)
{
byte[] IV = new byte[8];
for (int i = 0; i < 8; i++)
IV[i] = (byte)Rnd.Next(255);
KeyedClients.Add(BitConverter.ToUInt64(IV, 0), Info);
AC.Send(Packets.SendAuthentication(GameIP, IV));
//AC.Disconnect();
}
else
{
AC.Send(Packets.WrongAuth());
//AC.Disconnect();
}
if (Info.LogonType != 255)
{
if (Info.LogonType == 3)//Banned
{
AC.Send(Packets.BannedAuth());//Example!
AC.Disconnect();
}
byte[] IV = new byte[8];
for (int i = 0; i < 8; i++)
IV[i] = (byte)Rnd.Next(255);
KeyedClients.Add(BitConverter.ToUInt64(IV, 0), Info);
AC.Send(Packets.SendAuthentication(GameIP, IV));
//AC.Disconnect();
}
else
{
AC.Send(Packets.WrongAuth());
//AC.Disconnect();
}
AuthInfo Info = Database.Authenticate(Account, Password);
public static bool CheckBan(string Name)
{
if (File.Exists(@"C:\OldCODB\banname.txt"))
{
TextReader tr = new StreamReader(@"C:\OldCODB\banname.txt");//You can change to where ever your OldCODB is
string name;
while ((name = tr.ReadLine()) != null)
{
if (name == Name)
{
return true;
}
}
tr.Close();
}
return false;
}
public static void AddBan(string Name)
{
if (!CheckBan(Name))
{
TextWriter tw = new StreamWriter(@"C:\OldCODB\banname.txt");//You can change to where ever your OldCODB is
tw.WriteLine(Name);
tw.Close();
}
}
GC.Soc = StO.Sock;
if (GC.AuthInfo.LogonType == 3)
{
GC.AddSend(Packets.SystemMessage(GC.MessageID, "You are banned!"));
}
public bool Ghost = false;
public string AccountName;
if (Game.World.H_Chars.Contains(GC.MyChar.EntityID))
GC.MyChar.AccountName = Acc;
Info.LogonType = 1;
if (CheckBan(RealAccount))
Info.LogonType = 3;
if (Cmd[0] == "/ban")
{
Game.Character C = Game.World.CharacterFromName(Cmd[1]);
if (C != null)
Database.AddBan(C.AccountName);
C.MyClient.Disconnect();
}