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
![]()
|
|
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...
and change it intoCode:public 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.Code:public static void destruct() { for (int i = 0; i < maxPlayers; i++) { if (players[i] == null) { continue; } players[i].destruct(); players[i] = null; } }
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...
2. If it has anything inside it like a "disconnected = true" in it, and replace it all with this.Code:if (playerName == null || playerName.length() == 0) {
(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.

Your still trying to destruct all connected clients...

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.public void antiNull() {
if(playerName == null || playerName.length() == 0 || inStream.readUnsignedByte() != 14) {
mySock.close();
}
Now I know I'm not the king of java, but I KNOW this works.
Now NORMALLY it searches until it looks for what it needs. Now, I made it where it FINDSCode:public static void destruct() { for (int i = 0; i < maxPlayers; i++) { if (players[i] == null) { continue; } players[i].destruct(); players[i] = null; } }
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.
delete this tut it sucks... lol jk thanks i would use it but already have one![]()
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.
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.
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)
| « Fix 2 dupes for dodian (uber) | Perfect Uptime(real) for emulous » |
| Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |