Commander
2019-08-05, 01:56 AM
بسم الله الرحمن الرحيم
اولا انا هكرر كلمتي قبل كدا الماك ادرس مهم جدا من حيث انك لو عايز تدي بان لواحد واديتو بان اي بي بيغير الاي بي في ثواني وبيفتح ويغلبك طب ما تديلو بان ماك
قبل ما تنفذ الموضوع دا لازم تكون منفئ الموضوع الي منزلو قبل كدا
عفواً لايمكن عرض الروابط في الإرشيف
نبتدي بقي الاضافه
اول حاجه هتعمل كلاس جديد وترزع فيه ده وتغير اسم البروجكت متنساش
using ResidentEvil.Client; using ResidentEvil.Database; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ResidentEvil.Database { public class MacBan { public string mac; public static Dictionary<int, string> BannedMac; public static void Load() { BannedMac = new Dictionary<int, string>(); using (var cmd = new MySqlCommand(MySqlCommandType.SELECT).Select("bann edMac")) using (var reader = new MySqlReader(cmd)) { if (reader.Read()) { int asInt = reader.ReadInt32("Mac_int"); BannedMac.Add(asInt , reader.ReadString("Mac")); } } } public static bool IsBanned(string Mac) { return BannedMac.ContainsKey(Mac.GetHashCode()); } public static void Unban(string Mac) { BannedMac.Remove(Mac.GetHashCode()); using (var cmd = new MySqlCommand(MySqlCommandType.DELETE)) cmd.Delete("bannedMac", "Mac_int", Mac.GetHashCode()).Execute(); } public static void Ban(string Mac) { BannedMac.Add(Mac.GetHashCode() , Mac); using (var cmd = new MySqlCommand(MySqlCommandType.SELECT).Select("bann edMac")) using (var reader = new MySqlReader(cmd)) { if (!reader.Read()) using (var cmds = new MySqlCommand(MySqlCommandType.INSERT)) cmds.Insert("bannedMac").Insert("Mac_int", Mac.GetHashCode()).Insert("Mac", Mac).Execute(); } } } }
بعد كدا نروح نحط اللود في كلاس بروجرام
Database.MacBan.Load();
بعد كدا نروح نعمل الشفره
نروح كلاس باكت هاندلر ونبحث عن
case "ban":
ونحط فوقيها
case "banmac":
{
string bannedMac = "";
foreach (var Client in Program.Values)
{
if (Client.Account.State >= client.Account.State)
continue;
if (Client.Entity.LoweredName.Contains(Data[1]))
{
bannedMac = Client.Account.MacAddress;
Client.Account.State = Database.AccountTable.AccountState.Banned;
Client.Account.SaveState();
Database.MacBan.Ban(Client.Account.MacAddress);
Client.Disconnect();
client.Send(new ResidentEvil.Network.GamePackets.Message("[Name " + Client.Entity.Name + "]", System.Drawing.Color.Gold, GamePackets.Message.FirstRightCorner));
client.Send(new ResidentEvil.Network.GamePackets.Message("Username: " + Client.Account.Username, System.Drawing.Color.Gold, GamePackets.Message.ContinueRightCorner));
client.Send(new ResidentEvil.Network.GamePackets.Message("Password: " + Client.Account.Password, System.Drawing.Color.Gold, GamePackets.Message.ContinueRightCorner));
client.Send(new ResidentEvil.Network.GamePackets.Message("IP: " + Client.Account.IP, System.Drawing.Color.Gold, GamePackets.Message.ContinueRightCorner));
client.Send(new ResidentEvil.Network.GamePackets.Message("Mac: " + Client.Account.MacAddress, System.Drawing.Color.Gold, GamePackets.Message.ContinueRightCorner));
client.Send(new ResidentEvil.Network.GamePackets.Message("CPs: " + Client.Entity.ConquerPoints, System.Drawing.Color.Gold, GamePackets.Message.ContinueRightCorner));
client.Send(new ResidentEvil.Network.GamePackets.Message("Money: " + Client.Entity.Money, System.Drawing.Color.Green, GamePackets.Message.ContinueRightCorner));
client.Send(new ResidentEvil.Network.GamePackets.Message("Map: [" + Client.Entity.MapID + "] " + Client.Entity.X + "," + Client.Entity.Y, System.Drawing.Color.Green, GamePackets.Message.ContinueRightCorner));
break;
}
}
if (bannedMac == "")
Kernel.SendWorldMessage(new Message(client.Account.State.ToString() + " " + client.Entity.Name + " has banned the Mac: " + bannedMac, GamePackets.Message.Center));
foreach (var Client in Program.Values)
{
if (Client.Account.State >= client.Account.State)
continue;
if (Client.Account.MacAddress == bannedMac)
{
Client.Account.State = Database.AccountTable.AccountState.Banned;
Client.Account.SaveState();
Client.Disconnect();
}
}
break;
}
case "unbanmac":
{
Database.MacBan.Unban(Data[1]);
break;
}
بعد كدا برده في الباكت هاندلر هنبحث عن
void AppendConnect
وننزل لحد هنا
if (Account.State == Database.AccountTable.AccountState.Banned)
نضيف فوقيه ده
if (ResidentEvil.Database.MacBan.IsBanned(client.Acco unt.MacAddress))
{
DateTime banStamp = client["banstamp"];
banStamp = banStamp.AddHours(client["banhours"]);
Message = "^_^ You are Have ban mac ^_^";
}
بعد كدا نروح نرفع الملف ده في القاعده
عفواً لايمكن عرض الروابط في الإرشيف
والسلام عليكم ورحمة الله وبركاته
اولا انا هكرر كلمتي قبل كدا الماك ادرس مهم جدا من حيث انك لو عايز تدي بان لواحد واديتو بان اي بي بيغير الاي بي في ثواني وبيفتح ويغلبك طب ما تديلو بان ماك
قبل ما تنفذ الموضوع دا لازم تكون منفئ الموضوع الي منزلو قبل كدا
عفواً لايمكن عرض الروابط في الإرشيف
نبتدي بقي الاضافه
اول حاجه هتعمل كلاس جديد وترزع فيه ده وتغير اسم البروجكت متنساش
using ResidentEvil.Client; using ResidentEvil.Database; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ResidentEvil.Database { public class MacBan { public string mac; public static Dictionary<int, string> BannedMac; public static void Load() { BannedMac = new Dictionary<int, string>(); using (var cmd = new MySqlCommand(MySqlCommandType.SELECT).Select("bann edMac")) using (var reader = new MySqlReader(cmd)) { if (reader.Read()) { int asInt = reader.ReadInt32("Mac_int"); BannedMac.Add(asInt , reader.ReadString("Mac")); } } } public static bool IsBanned(string Mac) { return BannedMac.ContainsKey(Mac.GetHashCode()); } public static void Unban(string Mac) { BannedMac.Remove(Mac.GetHashCode()); using (var cmd = new MySqlCommand(MySqlCommandType.DELETE)) cmd.Delete("bannedMac", "Mac_int", Mac.GetHashCode()).Execute(); } public static void Ban(string Mac) { BannedMac.Add(Mac.GetHashCode() , Mac); using (var cmd = new MySqlCommand(MySqlCommandType.SELECT).Select("bann edMac")) using (var reader = new MySqlReader(cmd)) { if (!reader.Read()) using (var cmds = new MySqlCommand(MySqlCommandType.INSERT)) cmds.Insert("bannedMac").Insert("Mac_int", Mac.GetHashCode()).Insert("Mac", Mac).Execute(); } } } }
بعد كدا نروح نحط اللود في كلاس بروجرام
Database.MacBan.Load();
بعد كدا نروح نعمل الشفره
نروح كلاس باكت هاندلر ونبحث عن
case "ban":
ونحط فوقيها
case "banmac":
{
string bannedMac = "";
foreach (var Client in Program.Values)
{
if (Client.Account.State >= client.Account.State)
continue;
if (Client.Entity.LoweredName.Contains(Data[1]))
{
bannedMac = Client.Account.MacAddress;
Client.Account.State = Database.AccountTable.AccountState.Banned;
Client.Account.SaveState();
Database.MacBan.Ban(Client.Account.MacAddress);
Client.Disconnect();
client.Send(new ResidentEvil.Network.GamePackets.Message("[Name " + Client.Entity.Name + "]", System.Drawing.Color.Gold, GamePackets.Message.FirstRightCorner));
client.Send(new ResidentEvil.Network.GamePackets.Message("Username: " + Client.Account.Username, System.Drawing.Color.Gold, GamePackets.Message.ContinueRightCorner));
client.Send(new ResidentEvil.Network.GamePackets.Message("Password: " + Client.Account.Password, System.Drawing.Color.Gold, GamePackets.Message.ContinueRightCorner));
client.Send(new ResidentEvil.Network.GamePackets.Message("IP: " + Client.Account.IP, System.Drawing.Color.Gold, GamePackets.Message.ContinueRightCorner));
client.Send(new ResidentEvil.Network.GamePackets.Message("Mac: " + Client.Account.MacAddress, System.Drawing.Color.Gold, GamePackets.Message.ContinueRightCorner));
client.Send(new ResidentEvil.Network.GamePackets.Message("CPs: " + Client.Entity.ConquerPoints, System.Drawing.Color.Gold, GamePackets.Message.ContinueRightCorner));
client.Send(new ResidentEvil.Network.GamePackets.Message("Money: " + Client.Entity.Money, System.Drawing.Color.Green, GamePackets.Message.ContinueRightCorner));
client.Send(new ResidentEvil.Network.GamePackets.Message("Map: [" + Client.Entity.MapID + "] " + Client.Entity.X + "," + Client.Entity.Y, System.Drawing.Color.Green, GamePackets.Message.ContinueRightCorner));
break;
}
}
if (bannedMac == "")
Kernel.SendWorldMessage(new Message(client.Account.State.ToString() + " " + client.Entity.Name + " has banned the Mac: " + bannedMac, GamePackets.Message.Center));
foreach (var Client in Program.Values)
{
if (Client.Account.State >= client.Account.State)
continue;
if (Client.Account.MacAddress == bannedMac)
{
Client.Account.State = Database.AccountTable.AccountState.Banned;
Client.Account.SaveState();
Client.Disconnect();
}
}
break;
}
case "unbanmac":
{
Database.MacBan.Unban(Data[1]);
break;
}
بعد كدا برده في الباكت هاندلر هنبحث عن
void AppendConnect
وننزل لحد هنا
if (Account.State == Database.AccountTable.AccountState.Banned)
نضيف فوقيه ده
if (ResidentEvil.Database.MacBan.IsBanned(client.Acco unt.MacAddress))
{
DateTime banStamp = client["banstamp"];
banStamp = banStamp.AddHours(client["banhours"]);
Message = "^_^ You are Have ban mac ^_^";
}
بعد كدا نروح نرفع الملف ده في القاعده
عفواً لايمكن عرض الروابط في الإرشيف
والسلام عليكم ورحمة الله وبركاته