Thread: My TRUE way of logging out nulls

Page 1 of 2 12 LastLast
Results 1 to 10 of 15
  1. #1 My TRUE way of logging out nulls 
    Registered Member Dart Zamaki's Avatar
    Join Date
    Oct 2008
    Posts
    78
    Thanks given
    0
    Thanks received
    0
    Rep Power
    42
    First and for most, I am sorry everyone for my last tutorial. I really
    messed up and thought I was right. I feel really bad for saying what I did to everyone
    and if I said anything that hurt anyone here, I am deeply sorry to the bottom of my heart.
    And there was no reason of my actions. (Well I had a bad day yesterday... but lets keep it at that.) Anywho, here's the tutorial.


    Yes, this is in my main server, so I know its the currently right code.
    No, don't flame me saying it dosen't work. If it dosen't work, there are more nicer ways of saying it. (And I wont say anything in a mad way then.)
    If it helps, please comment. I don't get many comments, unless there bad ones. (its been happening alot here....)




    Part 1: playerhandler.java

    1. Open up that file. (playerhandler.java if you didn't notice the name of part 1)

    2. Find...

    Code:
        public void destruct() {
            for (int i = 0; i < maxPlayers; i++) {
                if (players[i] == null) {
                    continue;
                }
                players[i].destruct();
                players[i] = null;
            }
        }
    and change it into

    Code:
        public static void destruct() {
            for (int i = 0; i < maxPlayers; i++) {
                if (players[i] == null) {
                    continue;
                }
                players[i].destruct();
                players[i] = null;
            }
        }
    Where going to change the void into a static void so it can be easierly called by other files.

    3. Save & close file.

    ================================================== ===============
    Part 2: client.java

    1. Add this method to your client.java
    Code:
    public void close_connection()
    {
    	returnCode = 2;
    	disconnected = true;
    	server.playerHandler.destruct();
    	destruct();
            //mySock.close(); //Remove the comment if you want to add this. If it shows any errors, just comment it again.
    	System.out.println("--------Account connection closed--------------");
    }
    ================================================== ===============
    Part 3: testing it
    in client.java...

    1. Find...
    Code:
    if (playerName == null || playerName.length() == 0) {
    2. If it has anything inside it like a "disconnected = true" in it, and replace it all with this.
    (it should look something like this)

    Code:
    if (playerName == null || playerName.length() == 0) 
    {
    close_connection();
    return;
    }

    ================================================== ===============

    Other testing:
    Just add this to codes that you use for "blocking syi accounts" or something.
    This will work MUCH more effective. Instead of adding a disconnected = true code.
    Like if you don't want spammers to log in, this method will help fully into it.
    It gives the returncode on 2, then disconnects by the playerhandler and then the client then
    it will inform you that the account is being blocked out.



    I really hope this helps, and please let me know if it helps you.
    Reply With Quote  
     

  2. #2  
    Registered Member
    minutes's Avatar
    Join Date
    Apr 2008
    Posts
    1,926
    Thanks given
    2
    Thanks received
    19
    Rep Power
    465
    ohh firstly i was look .... this is leached, then i find out that another how stop nulls , then i saw you posted it to so nice work
    [Only registered and activated users can see links. ]
    click banner to join gtracer!
    Reply With Quote  
     

  3. #3  
    Registered Member

    Join Date
    Jun 2007
    Age
    26
    Posts
    3,007
    Thanks given
    52
    Thanks received
    98
    Rep Power
    3208
    Your still trying to destruct all connected clients...
    Reply With Quote  
     

  4. #4  
    Registered Member
    Lil Str Kid's Avatar
    Join Date
    Jul 2007
    Age
    28
    Posts
    1,302
    Thanks given
    169
    Thanks received
    71
    Rep Power
    260
    This exact same thing the destruct method should not be used...

    I told you already the destruct method is only for shutting down!

    Sorry but your an idiot first thing is why try getting them to logout when you can easy stop them from even connecting.

    Again look at this code 100x better took me 3 seconds and will work so much more better then yours:

    public void antiNull() {
    if(playerName == null || playerName.length() == 0 || inStream.readUnsignedByte() != 14) {
    mySock.close();
    }
    and add antiNull(); in your init method.


    Reply With Quote  
     

  5. #5  
    Registered Member Dart Zamaki's Avatar
    Join Date
    Oct 2008
    Posts
    78
    Thanks given
    0
    Thanks received
    0
    Rep Power
    42
    Now I know I'm not the king of java, but I KNOW this works.

    Code:
        public static void destruct() {
            for (int i = 0; i < maxPlayers; i++) {
                if (players[i] == null) {
                    continue;
                }
                players[i].destruct();
                players[i] = null;
            }
        }
    Now NORMALLY it searches until it looks for what it needs. Now, I made it where it FINDS
    only one player to do that on. Because of the "if" in it, ONLY destructing the account of the NULL.

    See where it says "if PLAYER[I] == NULL" at? That's where its saying continue.
    If I'm correct it will kick the nulls. Which I have been because I pulled this right out of my
    server.

    but, I will not inorge this, prove to me then it dosen't work.

    ps: inStream.readUnsignedByte() != 14 in my server logs you out. Yes, I've tried this part
    im showing here (not all servers have that part) and when I added it, it logged me out on
    pretty much all my accounts. (not at once) but like each account.
    Reply With Quote  
     

  6. #6  
    Community Veteran

    Cascade's Avatar
    Join Date
    Oct 2006
    Posts
    1,023
    Thanks given
    12
    Thanks received
    27
    Rep Power
    912
    Quote Originally Posted by Dart Zamaki View Post
    Now I know I'm not the king of java, but I KNOW this works.

    Code:
        public static void destruct() {
            for (int i = 0; i < maxPlayers; i++) {
                if (players[i] == null) {
                    continue;
                }
                players[i].destruct();
                players[i] = null;
            }
        }
    Now NORMALLY it searches until it looks for what it needs. Now, I made it where it FINDS
    only one player to do that on. Because of the "if" in it, ONLY destructing the account of the NULL.

    See where it says "if PLAYER[I] == NULL" at? That's where its saying continue.
    If I'm correct it will kick the nulls. Which I have been because I pulled this right out of my
    server.

    but, I will not inorge this, prove to me then it dosen't work.

    ps: inStream.readUnsignedByte() != 14 in my server logs you out. Yes, I've tried this part
    im showing here (not all servers have that part) and when I added it, it logged me out on
    pretty much all my accounts. (not at once) but like each account.
    Correct me if I am wrong a null is a null, the socket is already closed(90% of time), also you are doing "players[i] = null", this has the same effect as a null because the player has no value so you're just doing the same thing.
    Reply With Quote  
     

  7. #7  
    Registered Member
    CTucker's Avatar
    Join Date
    Oct 2008
    Posts
    2,422
    Thanks given
    263
    Thanks received
    281
    Rep Power
    343
    delete this tut it sucks... lol jk thanks i would use it but already have one
    Reply With Quote  
     

  8. #8  
    Registered Member Dart Zamaki's Avatar
    Join Date
    Oct 2008
    Posts
    78
    Thanks given
    0
    Thanks received
    0
    Rep Power
    42
    dds3030....... Ohhh! you where just kidding? ok thx ^_^

    Cascade: Yes, but this will work WITH the normal client close at the same moment of closing
    the client. Because a null IS a null, may not have a value, BUT it exists somehow someway.
    Normally I would disagree with what I just said, but I experiment a lot, and found this is
    the solution to my research.
    Reply With Quote  
     

  9. #9  
    Respected Member

    Join Date
    Jan 2009
    Posts
    5,682
    Thanks given
    1,093
    Thanks received
    3,494
    Discord
    View profile
    Rep Power
    5000
    Quote Originally Posted by Lil Str Kid View Post
    This exact same thing the destruct method should not be used...

    I told you already the destruct method is only for shutting down!

    Sorry but your an idiot first thing is why try getting them to logout when you can easy stop them from even connecting.

    Again look at this code 100x better took me 3 seconds and will work so much more better then yours:



    and add antiNull(); in your init method.
    It would be better to use this kind of method stopping the connection in the firstplace, or even better adding something like this where it accepts the connection and adds a thread, so it does not run any more code then the server actually needs too which infact reducing run time of the server.
    Reply With Quote  
     

  10. #10  
    Registered Member Dart Zamaki's Avatar
    Join Date
    Oct 2008
    Posts
    78
    Thanks given
    0
    Thanks received
    0
    Rep Power
    42
    Actually my method way dose the same effect. But I think I may add that as well to make
    the method a little more powerful. (since everyone keeps saying that)
    Reply With Quote  
     

Page 1 of 2 12 LastLast

Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •