Can someone help me make it so that only a certain # of people can join my server? Is there a way to make it work for LOTF?
if (World.AllChars.Count == 70)
{
Console.WriteLine("Server is now full last space = " + MyChar.Name);
World.SendMsgToAll(MyChar.Name + " Got the last space The Server is now full", "SYSTEM", 2011);
}
if (World.AllChars.Count >= 71)
{
SendPacket(General.MyPackets.SendMsg(MessageId, "SYSTEM", MyChar.Name, "The server is full please try later", 2000));
Console.WriteLine(MyChar.Name + " Attempted to login server full");
MyChar.MyClient.Drop();
}
public void AuthPacketHandler(object Sender, HybridSocket Socket)
{
try
{
Socket Sock = Socket.WinSock;
IPEndPoint IPE = (IPEndPoint)Sock.RemoteEndPoint;
string Ip = Convert.ToString(IPE.Address);
int Port = IPE.Port;
byte[] Data = Socket.Packet;
AuthBinder AB = (AuthBinder)AuthServerClients[Ip + ":" + Port];
Client TheClient = AB.Client;
if (Data.Length == 52)
TheClient.Crypto.Decrypt(ref Data);
if (Data[0] == 0x34 && Data[1] == 0x00 && Data[2] == 0x1b && Data[3] == 0x04)
{
try
{
int read = 0x04;
string ThisAcc = "";
string ThisPass = "";
while (read < 0x14 && Data[read] != 0x00)
{
ThisAcc += Convert.ToChar(Data[read]);
read += 1;
}
[COLOR="Red"]if (World.AllChars.Count <= 130)[/COLOR]
read = 0x14;
while (read < 36 && Data[read] != 0)
{
ThisPass += (Convert.ToString(Data[read], 16)).PadLeft(2, '0');
read += 1;
}
byte Auth = DataBase.Authenticate(ThisAcc, ThisPass);
if (Auth != 0)
{
General.WriteLine("Account: " + ThisAcc + " IP: " + Ip);
AB.Auth = Auth;
AB.Acc = ThisAcc;
AB.Client.Account = ThisAcc;
ulong TheKeys = (uint)(Rand.Next(0x98968) << 32);
TheKeys = TheKeys << 32;
TheKeys = (uint)(TheKeys | (uint)Rand.Next(10000000));
KeyClients.Add(TheKeys, AB);
byte[] Key1 = new byte[4];
byte[] Key2 = new byte[4];
Key1[0] = (byte)((ulong)(TheKeys & 0xff00000000000000L) >> 56);
Key1[1] = (byte)((TheKeys & 0xff000000000000) >> 48);
Key1[2] = (byte)((TheKeys & 0xff0000000000) >> 40);
Key1[3] = (byte)((TheKeys & 0xff00000000) >> 32);
Key2[0] = (byte)((TheKeys & 0xff000000) >> 24);
Key2[1] = (byte)((TheKeys & 0xff0000) >> 16);
Key2[2] = (byte)((TheKeys & 0xff00) >> 8);
Key2[3] = (byte)(TheKeys & 0xff);
try
{
byte[] Pack = MyPackets.AuthResponse(ServerIP, Key1, Key2);
TheClient.Crypto.Encrypt(ref Pack);
Sock.Send(Pack);
byte[] Pack1 = MyPackets.AuthResponse(ServerIP2, Key1, Key2);
TheClient.Crypto.Encrypt(ref Pack);
Sock.Send(Pack);
}
catch { }
Socket.Disconnect();
AuthServerClients.Remove(Ip + ":" + Port);
}
else
{
TheClient.SendPacket(General.MyPackets.SendMsg(TheClient.MessageId, "SYSTEM", "ALLUSERS", "Wrong username or password! Try Again!", 2101));
Socket.Disconnect();
AuthServerClients.Remove(Ip + ":" + Port);
}
}
catch (Exception Exc) { WriteLine(Convert.ToString(Exc)); }
}
}
catch (Exception Exc) { WriteLine(Exc.ToString()); }
}
i bet mine is less space lolQuote:
My Code To Max Players On ..
Code:public void AuthPacketHandler(object Sender, HybridSocket Socket) { try { Socket Sock = Socket.WinSock; IPEndPoint IPE = (IPEndPoint)Sock.RemoteEndPoint; string Ip = Convert.ToString(IPE.Address); int Port = IPE.Port; byte[] Data = Socket.Packet; AuthBinder AB = (AuthBinder)AuthServerClients[Ip + ":" + Port]; Client TheClient = AB.Client; if (Data.Length == 52) TheClient.Crypto.Decrypt(ref Data); if (Data[0] == 0x34 && Data[1] == 0x00 && Data[2] == 0x1b && Data[3] == 0x04) { try { int read = 0x04; string ThisAcc = ""; string ThisPass = ""; while (read < 0x14 && Data[read] != 0x00) { ThisAcc += Convert.ToChar(Data[read]); read += 1; } [COLOR="Red"]if (World.AllChars.Count <= 130)[/COLOR] read = 0x14; while (read < 36 && Data[read] != 0) { ThisPass += (Convert.ToString(Data[read], 16)).PadLeft(2, '0'); read += 1; } byte Auth = DataBase.Authenticate(ThisAcc, ThisPass); if (Auth != 0) { General.WriteLine("Account: " + ThisAcc + " IP: " + Ip); AB.Auth = Auth; AB.Acc = ThisAcc; AB.Client.Account = ThisAcc; ulong TheKeys = (uint)(Rand.Next(0x98968) << 32); TheKeys = TheKeys << 32; TheKeys = (uint)(TheKeys | (uint)Rand.Next(10000000)); KeyClients.Add(TheKeys, AB); byte[] Key1 = new byte[4]; byte[] Key2 = new byte[4]; Key1[0] = (byte)((ulong)(TheKeys & 0xff00000000000000L) >> 56); Key1[1] = (byte)((TheKeys & 0xff000000000000) >> 48); Key1[2] = (byte)((TheKeys & 0xff0000000000) >> 40); Key1[3] = (byte)((TheKeys & 0xff00000000) >> 32); Key2[0] = (byte)((TheKeys & 0xff000000) >> 24); Key2[1] = (byte)((TheKeys & 0xff0000) >> 16); Key2[2] = (byte)((TheKeys & 0xff00) >> 8); Key2[3] = (byte)(TheKeys & 0xff); try { byte[] Pack = MyPackets.AuthResponse(ServerIP, Key1, Key2); TheClient.Crypto.Encrypt(ref Pack); Sock.Send(Pack); byte[] Pack1 = MyPackets.AuthResponse(ServerIP2, Key1, Key2); TheClient.Crypto.Encrypt(ref Pack); Sock.Send(Pack); } catch { } Socket.Disconnect(); AuthServerClients.Remove(Ip + ":" + Port); } else { TheClient.SendPacket(General.MyPackets.SendMsg(TheClient.MessageId, "SYSTEM", "ALLUSERS", "Wrong username or password! Try Again!", 2101)); Socket.Disconnect(); AuthServerClients.Remove(Ip + ":" + Port); } } catch (Exception Exc) { WriteLine(Convert.ToString(Exc)); } } } catch (Exception Exc) { WriteLine(Exc.ToString()); } }
Quote:
I did post this in another thread, but just as turk55 got from KinshiCO source, lol. Copy+Paste ftw huh?
It's a chat type, but you can only send it before the client sets location(before the client loads the map and crap).Quote:
How to send a Error message? Like when the server is offline, You get a message that the server is undegoing a Servermaintenance or something,