Thread: Crasher Checker + Auto Restart

Page 1 of 2 12 LastLast
Results 1 to 10 of 20
  1. #1 Crasher Checker + Auto Restart 
    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
    Purpose: Give an idea of how to create an auto resarter on crash.

    Difficulty: 5/10 depending on your knowledge.

    Description: Well im not going to help you and spoon feed you, just going to give you brief exlaination can't believe people can't figure little stuff out and for god sake don't bother posting errors because methods are completely wrong except some xD

    First you would need to declare the variables:

    Code:
    public boolean serverDownAttempt = false;
    public boolean createNewConnection = false;
    public int serverChecker = 6000; //After how long to check.
    You need to make an if statment so when its time to check it creates a new connection.

    Code:
    if(serverChecker == 0) {
    createNewConnection = true;
    }
    Also you want timer to go down.

    Code:
    if(serverChecker > 0) {
    serverChecker -= 1;
    }
    Then you need the actual statment to go through the whole process of server being down.

    Code:
    if(createNewConnection && logIn) { //Creates connection and logs in
    playerHandler.kickNewConnection; //Kicks the connection 
    serverChecker = 6000; // Resets timer back to normal state.
    } else {
    if(createNewConnection && !logIn) { //If it trys logging in and fails attempts again.
    serverDownAttempt = true;
    serverChecker = 1000; // Notice timer set quicker.
    }
    Code:
    if(serverDownAttempt && (serverChecker == 0)) {
    if(createNewConnection && !logIn) {
    appendToRestart(); //Restart the server method 
    }
    }
    These methods would be declared:

    Code:
    public void appendToRestart() { // Restart method
    closeListener(); //Shutsdown the server
    runserver(); //Runs the server again
    }
    Code:
    public void closeListener() {
    try {
    server.shutdownClientHandler = true;
    if (server.clientListener != null) {
    server.clientListener.close();
    }
    server.clientListener = null;
    } catch (java.lang.Exception __ex) {
     __ex.printStackTrace();
    }
    }
    And last but all the run server method.

    Code:
    public void runserver() {
    try {
    String File = "runserver.bat"; // these 2 lines would be edited.
    String Dir = "./" + File; // Directory
    
    Runtime.getRuntime().exec(Dir);
    } catch (IOException ioe) {
    ioe.printStackTrace();
    } 
    }
    Can't figure out where some stuff goes? Then click the spoiler for help.

    Spoiler for Hint:
    Well as you would need it to check after time and make it loop you'd need to put it in process but i wouldn't recomend this i recomend learning how to use Grahams event manager and using that instead.


    Note: All the methods and stuff are all within the server already so i dont see why someone couldn't do this and i took all this out my head so there was no use of convections what so ever so don't bother posting on it.

    Hopefully you now have some understanding if there's something you can't understand please post it surely me or another member will answer your question/problem with an answer.


    Reply With Quote  
     

  2. #2  
    Registered Member
    ViperSniper's Avatar
    Join Date
    Apr 2007
    Age
    27
    Posts
    2,417
    Thanks given
    367
    Thanks received
    82
    Rep Power
    976
    Eww at using a process timer, use System timer.
    nextCheck = 10000;
    lastCheck = System.currentTimeMillis();

    Good job though.
    :indeed:
    Reply With Quote  
     

  3. #3  
    Banned

    Join Date
    May 2008
    Posts
    2,327
    Thanks given
    55
    Thanks received
    67
    Rep Power
    0
    is there a way to check if the drops are off?

    like, on my server... sometimes the drops stop working... or the shops run low on stuff, any way to detect any of those?

    or maybe sometimes people can't get on, any1 no wat causes these problems?
    Reply With Quote  
     

  4. #4  
    Community Veteran

    George's Avatar
    Join Date
    Mar 2009
    Posts
    7,059
    Thanks given
    2,100
    Thanks received
    2,939
    Rep Power
    5000
    good job at this


    Reply With Quote  
     

  5. #5  
    Registered Member
    Coder Alex's Avatar
    Join Date
    Apr 2009
    Age
    27
    Posts
    1,755
    Thanks given
    86
    Thanks received
    83
    Rep Power
    231
    Why use process timer?
    This will cause more lagg
    But , gj on it.
    My english skills back in the days.
    Quote Originally Posted by Coder Alex
    Well, if it's gooded decent, it's good.
    Reply With Quote  
     

  6. #6  
    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
    Omfg why in the hell do you guys post before reading it all i said.

    Well as you would need it to check after time and make it loop you'd need to put it in process but i wouldn't recomend this i recomend learning how to use Grahams event manager and using that instead.
    Next time please read the whole thread.


    Reply With Quote  
     

  7. #7  
    Registered Member

    Join Date
    May 2008
    Age
    26
    Posts
    188
    Thanks given
    4
    Thanks received
    1
    Rep Power
    79
    im gonna use thanks very much
    [Only registered and activated users can see links. ]
    Reply With Quote  
     

  8. #8  
    Registered Member
    MerzA's Avatar
    Join Date
    Jul 2008
    Age
    27
    Posts
    592
    Thanks given
    36
    Thanks received
    28
    Rep Power
    95
    very nicely done

    I became very proud of myself when i put it all into my server and it worked :]
    Reply With Quote  
     

  9. #9  




    Scu11's Avatar
    Join Date
    Aug 2007
    Age
    27
    Posts
    16,200
    Thanks given
    7,190
    Thanks received
    12,174
    Discord
    View profile
    Rep Power
    5000
    Best way: Create an independent program to send a connection every 60 secs, with a username you decide, then as soon as the connection gets accepted, make it print or return a code, then remove it from the game. Then make it so if the program does not get a connection within 10 secs, start the run.bat or whatever again.

    [Only registered and activated users can see links. ]



    Reply With Quote  
     

  10. #10  
    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
    Scu11 Rofl you just copied that idea for Martin lmao we have that in Shard what you just said and he even released nice


    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
  •