I need a plugin that tells if the server is online. write 1 in a .txt when activated write 0 in the same .txt when disabling Can anyone do this for me?
Well it can't write 0 if the plugin isn't enabled! (the server is off). You can achieve this through a variety of methods. What are you trying to achieve?
online/offline stats on my webpage. It can be achieved by writing 0 when typing /stop. I just cant figure out how to make them plugins. its driving me insane x]
Try the HUGE Plugin Tutorial at http://wiki.bukkit.org/HUGE_Plugin_Tutorial. It was very helpful for me. As for detecting server shutdown, you can write the 0 in the onDisable handler of the plugin, or even add a VM shutdown handler. I'm going to try and make the plugin right now. Here you go! The plugin writes to a file called isserveron.txt in the folder where the server is located. It writes a 1 when it is enabled, and a 0 when it is disabled. Edit: I think Elusive92's version is better because it can also track if the server gets killed.
I modified a personal version of this to suit your requirements. The file is called server_status.txt and is even updated when the process is killed. edit: @zhuowei whoops, you beat me to it! @Astusvis You cannot ping ports. You could try to establish a connection to the IP/port using a terminal client or something like that, but that would require more work than this. Besides that, the server could still refuse connections, which would result in false negatives. @Astusvis They might have implemented the basic protocol to connect to those servers using a simple socket. Doing so would require quite some time. It is way easier to use a simple plugin like this. And it is VERY simple. I coded and tested my version in about 10 minutes.