Thread: Shutdown server with a command!! (NOOB FRIENDLY!!)

Page 1 of 2 12 LastLast
Results 1 to 10 of 18
  1. #1 Shutdown server with a command!! (NOOB FRIENDLY!!) 
    andrew121
    Guest
    Ok well the server i was admin on was attacked by a hacker some time today, and what i did was download a cheat client and crash the server so nothing would happen. Since i wasn't hosting i couldn't kill the server. Well many things got messed up but we recovered. After that i decided to make a Shutdown command for one or all admins. Just in case a hacker comes in and messes up all an admin has to do is type :hutdown and everyone gets disconnected and the server will not let anybody in. I even made a handler for this.

    Description: Shutdown server with a command.

    Difficulty: 1/10

    Assumed Knowledge: Barely any java experience

    Tested Server: Don't know base because it isn't mine but it should work in all.

    Files/Classes Modified: Client.java

    Procedure
    Step 1: Ok well first open up Client.java and search for

    Code:
    if (command.startsWith("pickup")
    (you should have this) If not the look for any command.

    You should have something like this (can be a little different.)

    Code:
    if (command.startsWith("pickup") && (playerRights > 1)) {
    			String[] args = command.split(" ");
    			if (args.length == 3) {
    				int newItemID = Integer.parseInt(args[1]);
    				int newItemAmount = Integer.parseInt(args[2]);
    				if ((newItemID <= 20000) && (newItemID >= 0)) {
    					addItem(newItemID, newItemAmount);
    				} else {
    					sendMessage("No such item.");
    				}
    			} else {
    				sendMessage("usage Use as ::pickup 800 100");
    			}
    }


    Right Before the command put this in.

    Code:
    if (command.equalsIgnoreCase("shutdown") && (playerName.equalsIgnoreCase("YOURNAME"))) {
    			ShutdownHandler.shutdown = true;
    			PlayerHandler.kickAllPlayers = true;
    		}
    What that does is first use the shutdown boolean in the handler and then kick all players out. (this one is if you only want 1 admin to have power in doing this.


    If you want any admin just put this

    Code:
    if (command.equalsIgnoreCase("shutdown") && (playerRights > 1)) {
    			ShutdownHandler.shutdown = true;
    			PlayerHandler.kickAllPlayers = true;
    		}
    Same thing as the top but lets any admin do this.



    Step 2: While still in client.java, look for this

    Code:
    if (PlayerHandler.updateRunning) {
    This might not be in your server and if it isn't please post i will help you.

    Right after the last bracket of this code copy this.
    Code:
    if (ShutdownHandler.shutdown) {
    				returnCode = 40;
    				disconnected = true;
    				savefile = false;
    				println_debug(playerName + " refused - SHUTDOWN !");
    				return;
    			}
    The returnCode = 40 is set for my client where i wrote The server has been SHUTDOWN by andrew.
    disconnected = true is pretty much doesnt let you in.
    savefile = false means that the character files will not be saved.
    println_debug(playerName + " refused - SHUTDOWN !"); this will show the playername trying to get in and that stuff in the black server screen.

    Now you are done with Client.java.


    Step 3: Make a new txt file and rename it to ShutdownHandler.java (make the S and the H capital)

    Put this inside it.

    Code:
    import java.util.Calendar;
    import java.util.GregorianCalendar;
    
    
    public class ShutdownHandler { //By Andrew
    
    
    
    //More can be added im just too lazy :P
    	public static boolean shutdown;	
    		public void process() {
    		
    			
    			
    			if (shutdown) {
    				
    				server.ShutDown = true;
    			}
    
    
    }
    }
    All this handler does is name a variable and use a ShutDown boolean in server.java


    And that is it! Please post feedback as it is my first Server Tutorial!!
    (I DID NOT LEECH THIS AND IF YOU THINK I DID THEN SHOW ME PROOF)
    I was flamed in MoparScape because i am an idiot and still think moparscape is smart. BUT MOPARSCAPE IS FULL OF NOOBS even some of the mods are retards.

    Credits: Me- Andrew121
     

  2. #2  
    Mr.Smooth
    Guest
    this is in every server source from the first one until the last if you cant post anything better just dont post!
     

  3. #3  
    Mr.Smooth
    Guest
    Quote Originally Posted by 5blacksmith5 View Post
    Does this really shut it down or something else?
    1st Read the rplys on a thread so you dont have to make usseles replys like this.

    read the code...all it does is close connections so yes it closes down the server for example if u dont have a proper autosaver that saves every milisecond then you can use this command (THAT IS ALREADY IN YOUR SOURCE) by closing down the conenctions and making everybodys moreinfo save.
     

  4. #4  
    andrew121
    Guest
    Quote Originally Posted by 5blacksmith5 View Post
    Does this really shut it down or something else?
    Yes it does. ive tried it.

    Quote Originally Posted by Mr.Smooth View Post
    1st Read the rplys on a thread so you dont have to make usseles replys like this.

    read the code...all it does is close connections so yes it closes down the server for example if u dont have a proper autosaver that saves every milisecond then you can use this command (THAT IS ALREADY IN YOUR SOURCE) by closing down the conenctions and making everybodys moreinfo save.
    if you read the first paragraph you would know what this i used for
    Last edited by andrew121; 04-03-2008 at 05:48 AM. Reason: Double posting is not allowed!
     

  5. #5  
    Mr.Smooth
    Guest
    aah yes andrew im sorry i now notice that its not in the sources these days it use to be in cheezscape and whitescape but p16 based source dont have these commands
     

  6. #6  
    andrew121
    Guest
    This is new i made this handler myself. i just added the kickall so no one stays in.

    change the println_debug with

    Code:
    misc.println
     

  7. #7  
    Registered Member Poptart's Avatar
    Join Date
    Dec 2007
    Posts
    333
    Thanks given
    0
    Thanks received
    0
    Rep Power
    26
    andrew121, Do you know what a 'noob' is?!

    Do you andrew121?!
    DO YOU?!

    No you don't andrew121.

    A 'noob' is a stupid, annoying person thats cheats or exploits glitches.

    Get it straight. You're an idiot for saying 'noob friendly' why would we want cheaters or stupid annoying people doing this? You made it special for them?

    Thats really great andrew121.

    You truly are, a noob.
     

  8. #8  
    De-Repped
    ~Jake's Avatar
    Join Date
    Oct 2006
    Posts
    637
    Thanks given
    38
    Thanks received
    1
    Rep Power
    690
    I've seen this many times before, but I guess it doesn't hurt to post
     

  9. #9  
    andrew121
    Guest
    Quote Originally Posted by Poptart View Post
    andrew121, Do you know what a 'noob' is?!

    Do you andrew121?!
    DO YOU?!

    No you don't andrew121.

    A 'noob' is a stupid, annoying person thats cheats or exploits glitches.

    Get it straight. You're an idiot for saying 'noob friendly' why would we want cheaters or stupid annoying people doing this? You made it special for them?

    Thats really great andrew121.

    You truly are, a noob.
    WTF? you are really messed up.
     

  10. #10  
    Optimist

    Vice's Avatar
    Join Date
    Nov 2007
    Age
    28
    Posts
    3,263
    Thanks given
    3
    Thanks received
    59
    Rep Power
    2536
    dodgy font but other than that its alright
    Jack
    Scotland
    Undergraduate - BSc Computing Science
     

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
  •