[RELEASE]PlayerLimit

07/10/2010 06:52 Fish*#1
(For tanels source)

This is just a simple release for playerlimit.
can be done in many way, but this one is good.
if u are about to ask why i dont use world.h_chars.count,
then is because is not working. it will simply make server full when is online players are not eve 1% close to it XD
Im not going to release more anyway.
here is some of my trash.

anyways here it is.
in program.cs put:
Code:
public static int OnlinePlayers = 0;
Now find in program.cs:
Code:
Database.LoadLottoItems();
under it put:
Code:
OnlinePlayers = 0;
Now open GameWorker.cs and search for:
Code:
                        if (PacketID == 1052)
                        {
                            try
                            {
                                ulong CryptoKey = BitConverter.ToUInt64(Data, 4);

                                AuthWorker.AuthInfo Info = (AuthWorker.AuthInfo)AuthWorker.KeyedClients[CryptoKey];
                                GC.AuthInfo = Info;
                                GC.MessageID = (uint)Rnd.Next(50000);
                                GC.Soc = StO.Sock;
right under this put:
Code:
                                if (Program.OnlinePlayers >= 100)//Change to the limit u want
                                {
                                    GC.AddSend(Packets.SystemMessage(GC.MessageID, "Server is Full! Online Players: " + Program.OnlinePlayers + "/100."));
                                }
Now in Teleport.cs put this under the loginmessage:
Code:
Program.OnlinePlayers += 1;
Now find (in GameClient.cs)
Code:
        public void LogOff(bool Remove)
        {
            try
            {
under that put:
Code:
Program.OnlinePlayers -= 1;
This should work ;)
Any problems let me know :)

if im right the OnlinePlayers thing will always stay alittle above then World.H_Chars.Count.
07/10/2010 17:04 KraHen#2
Ain`t there a container or something for the gameclients? Why not check those?
07/10/2010 22:29 Fish*#3
just released it, cuz was some trash i run about in a folder lol :D
07/10/2010 22:48 MonstersAbroad#4
Yeah its like
Code:
foreach(client.client Clients in Kernel.gamepool.count)
{
if Client > PlayerLimit
{
whatever
}
}
else
OK
}
Too simple,

It's not that grillmad coudn't do it, It was that he never thought of it
07/10/2010 22:49 ~Master#5
Quote:
LOL, banned ftw.
I dont release more, but anything you need, whisper me and I will try my best
hmm
07/10/2010 22:51 KraHen#6
Quote:
Originally Posted by MonstersAbroad View Post
Yeah its like
Code:
foreach(client.client Clients in Kernel.gamepool.count)
{
if Client > PlayerLimit
{
whatever
}
}
else
OK
}
Too simple,

It's not that grillmad coudn't do it, It was that he never thought of it
Why not just have a counter variable in the server socket code, and check it whenever someone tries to connect...
07/10/2010 22:57 MonstersAbroad#7
Like you said, Why not
07/11/2010 01:03 Fish*#8
Quote:
Originally Posted by ~Master View Post
hmm
if u read i said this is last.
cuz i just saw some trash at my pc and thought i would smack it up here :pimp:
07/11/2010 01:05 Korvacs#9
What happens if the client crashes? It wont be an eligant logoff so i cant imagine this is going to work correctly in that case, so eventually people wont be able to login because the server will think its full.
07/11/2010 13:30 Fish*#10
yee korvacs xD
I tested it and always count like 2-3backwards then the real count.
and then it starts go negative XD