[RELEASE] PlayerCap[LOTF]

07/22/2009 16:45 Pete1990#1
Well this code is to add a player cap if ur source isnt stable or so on but eh its ok

Search for
HTML Code:
        public void GamePacketHandler(object Sender, HybridSocket Socket)
Under
HTML Code:
{
            try
            {
Add this

HTML Code:
if (World.AllChars.Count > 0)
                {
                    foreach (DictionaryEntry DE in World.AllChars)
                    {
                        Character Char = (Character)DE.Value;
                        Char.MyClient.Drop();
                        return;
                    }
                }
Change number 0 to anything u want no more then those players can connect it will just Dc them u can also send amessage to there client to say SERVER FULL. If You use this hit Thanks or If you like hit Thanks:)
07/22/2009 16:55 WTFoRK#2
Quote:
Originally Posted by Pete1990 View Post
Well this code is to add a player cap if ur source isnt stable or so on but eh its ok

Search for
HTML Code:
        public void GamePacketHandler(object Sender, HybridSocket Socket)
Under
HTML Code:
{
            try
            {
Add this

HTML Code:
if (World.AllChars.Count > 0)
                {
                    foreach (DictionaryEntry DE in World.AllChars)
                    {
                        Character Char = (Character)DE.Value;
                        Char.MyClient.Drop();
                        return;
                    }
                }
Change number 0 to anything u want no more then those players can connect it will just Dc them u can also send amessage to there client to say SERVER FULL. If You use this hit Thanks or If you like hit Thanks:)
ROFL, LMFAO HAHAHA LAUGHEDF MY ASS OFF
Seriously why doing that if you can do that
GameServer.MaxThreads = AMOUNT;
...? Seriously think and search before making something
07/22/2009 16:57 alexbigfoot#3
[QUOTE=Pete1990;2612312]
Code:
if (World.AllChars.Count > 0)
                {
                  [B]foreach (DictionaryEntry DE in World.AllChars)[/B]
                    {
                        Character Char = (Character)DE.Value;
                        Char.MyClient.Drop();
                        return;
                    }
}
Ok so, with that thing it will start checking all players in World.AllChars, you will DC the first one, and then use "return" to stop the foreach. Are you noob?
It just DCs the first player added in AllChars hastable and then stop. Insane.
07/22/2009 17:00 Pete1990#4
working fine for me? i tryed ti with people online to it dont dc the first person it dcs who ever is trying to connect after the amount u put
WTFoRK u think u can make somthing better go ahead i dont care
07/22/2009 17:13 ~Yuki~#5
This has been released be4 by adz06676 and its useless ....
07/22/2009 18:14 f0am#6
good release, also you could do it right when they loggin in , i have ip ban so it checks and if you have that you can place it right there and instead of all of that just make it say like

Code:
                            if (BannedIP.Contains(Ip) || World.AllChars.Count > 70)
                            {
                                Socket.Disconnect();
                            }
07/22/2009 18:20 WTFoRK#7
Its actually the worse code i've ever seen , no offence but cmon...
07/22/2009 18:25 Pete1990#8
So then do a better one? i havent ever seen u put anything on epvpers?
07/22/2009 19:26 AndreaCo#9
i can make a worse code right now!!

Code:
if (MyChar.CPs ==  1)
{
MyChar.Cps = 2;
}
i win ^^.. THANK ME IF U USE THIS CODE!!
07/22/2009 19:30 alexbigfoot#10
MyChar.Cps += MyChar.Cps == 1 ? 1 : 0;

My code beats yours lol
07/22/2009 19:32 AndreaCo#11
i r copy an paste u code and i get error.. pl0x help!!!
07/22/2009 19:35 Incariuz#12
@WTFoRK

He's attempting to provide something to the community, simple as that. Not everyone is a pro, but does that mean that they need to be bashed for trying? I think not, sometimes you have to fail a thousand times to finally accomplish your goals. So if you notice flaws in the coding, perhaps you can offer assistance to improve it, rather then acting like some 12 year old middle school brat who can't stand the fact that he's neglected by his parents, thus seeks out other methods of obtaining attention.

Nuff said, grow up, or get lost.
07/22/2009 19:37 AndreaCo#13
you deserve a thanks!!!!!!! so do u pete.. thank you for helping the community !!
07/22/2009 20:10 alexbigfoot#14
Quote:
Originally Posted by AndreaCo View Post
i r copy an paste u code and i get error.. pl0x help!!!
Ah sorry, lotf is so shitty, anyway fix:
MyChar.CPs += (uint)(MyChar.CPs == 1 ? 1 : 0);
07/22/2009 23:15 _Emme_#15
Quote:
if (World.AllChars.Count > 0) // Check if the amount of chars online are above '0'
{
foreach (DictionaryEntry DE in World.AllChars) // Go through all characters in game
{
Character Char = (Character)DE.Value; // Sets a Character class to the char(s) found
Char.MyClient.Drop(); // Disconnects them
return;
}
}
So, if it reaches the limit, all characters will be disconnected, or does Dictionary start with the latest item put into it? Im not sure.

Anyhow, there's many many many ways to do a player cap, but I don't see a reason really.

If I really really had to do one, I would just do:

Quote:
public static Hashtable AllChars = new Hashtable(PLAYER_CAP_HERE);

anyhow, stop flaming.