[CoEmu PlayerCap]

08/19/2009 20:41 1supertao#1
How can I make this work for CoEmu? I want to have a Player Capacity....

Code:
if (World.AllChars.Count > 0)
                {
                  foreach (DictionaryEntry DE in World.AllChars)
                    {
                        Character Char = (Character)DE.Value;
                        Char.MyClient.Drop();
                        return;
                    }
}
08/19/2009 20:56 samehvan#2
Code:
if (Nano.ClientPool.Count>0)
08/19/2009 21:00 1supertao#3
Where do i put
if (Nano.ClientPool.Count>0)
08/19/2009 21:02 _Emme_#4
I just don't see why people won't cap the pool itself, like:

Quote:
public static Dictionary<int, ClientSocket> ClientPool = new Dictionary<int, ClientSocket>(100); // 100 being the limit

case 1052:
Quote:
try
{
Monitor.Enter(Nano.ClientPool);
Nano.ClientPool.Add(CSocket.Client.ID, CSocket);
//}
}
catch(Exception e)
{
CSocket.Disconnect();
Console.WriteLine(e.ToString());
}

Just added 3 letters and one line, voila.
08/19/2009 21:31 tanelipe#5
Actually emme... that is incorrect. Look at the following example, it will work just fine.
PHP Code:
Dictionary<uintuintUintPool = new Dictionary<uintuint>(10);
for (
uint i 01000i++)
{
      
UintPool.Add(i10);

The integer parameter passed to constructor is just the initial size, it will allocate more space in the array it uses.


PHP Code:
const int PLAYER_LIMIT 200;
if(
Nano.ClientPool.Count PLAYER_LIMIT) {
    
CSocket.Disconnect();

That code would be more correct. Ofcourse it won't work if you just copy paste it so figure out it yourself. ( I don't have CoEmu V2 on my computer, can't help more. )
08/19/2009 21:35 1supertao#6
still not understanding any of this
08/19/2009 23:38 _tao4229_#7
Quote:
Originally Posted by 1supertao View Post
still not understanding any of this
Then you should probably learn to code before asking for help you won't understand?
08/20/2009 00:02 1supertao#8
ya thats true... but ya... i got it...
08/20/2009 03:36 felipeboladao#9
then make a better type of Packet WrongPass ..
To tell the This Server Full '

Sorry for my Englesh'
08/20/2009 03:46 CptSky#10
Quote:
Originally Posted by felipeboladao View Post
then make a better type of Packet WrongPass ..
To tell the This Server Full '

Sorry for my Englesh'
Just send a message's packet on the channel 2101 and drop the connection...
LOTF Exemple:
Code:
SendPacket(General.MyPackets.SendMsg(MessageId, "SYSTEM", MyChar.Name, "Le serveur est complet!", 2101));
ListenSock.WinSock.Close();
ListenSock = null;