Players Online Via Website (No MYSQL)
Since keep selling this stuff, figured I would release my old server's one from months ago.
http://img221.imageshack.us/img221/2...yersonline.png
First:
Go into your Server class and under:
Code:
public class Server {
add
Code:
public static boolean forceWebUpdate = false;
public static Thread WebCommThread = new Thread (
new Runnable(){
long lastUpdate = 0;
@Override
public void run(){
while(true){
try{
if(System.currentTimeMillis() - lastUpdate > 1000 * 60 * 5 || Server.forceWebUpdate){
lastUpdate = System.currentTimeMillis();
new URL("http://website.com/vps/reset.php?pass=jilixpie").openStream().close();
for(Player p1: PlayerHandler.players){
if(p1 != null){
Client p = (Client)p1;
if(!p.properLogout)
new URL("http://website.com/vps/add.php?pass=jilixpie&u=" + p.playerName.replaceAll(" ","%20")).openStream().close();
}
}
if(Server.forceWebUpdate)
Server.forceWebUpdate = false;
System.gc();
}
}catch(Exception e){}
}
}
}
);
then under main add:
Code:
WebCommThread.start();
Then make sure to import:
Second:
In your Client class somewhere under logout add:
Code:
Server.forceWebUpdate = true;
then declare this somewhere:
Code:
public boolean runOnce = true;
then under process add:
Code:
if(runOnce){
Server.forceWebUpdate = true;
runOnce = false;
}
Third:
Download these files and add them to your webhost:
Players Online Files
You have to call it somehow to count players, like this:
Code:
<?php
$fileName = FOLDNAME/players.txt";
$countOnline = count(file($fileName));
echo "$countOnline players online.";
?>
Credits:
Matt123337
Me