Players online protocol has been added to TopList! This means every server can now show how much people are currently online on the details page. It is really easy to implent! Takes only about few lines of code.
Originally Posted by
Vastastico
Hyperion simple modification of 1 file.
Code:
case OPCODE_PLAYERCOUNT:
session.write(new PacketBuilder().putShort(World.getWorld().getPlayers().size()).toPacket());
return true;
beneath:
Code:
case OPCODE_UPDATE:
session.setAttribute("state", STATE_UPDATE);
session.write(new PacketBuilder().put(INITIAL_RESPONSE).toPacket());
return true;
add:
Code:
public static final int OPCODE_PLAYERCOUNT = 20;
beneath:
Code:
public static final int OPCODE_UPDATE = 15;
Adding it to WL is also very easy. More detailed TUT coming soon!
PI: Java - Rune-Server Official Pastebin
As you can see this feature is trusting the count server sends to it. Altough there may be some people who will increase this value, thatswhy faking the value will get your server disabled on the list for a week and account banned for a week too! There will be a report button soon and moderators who deal with them!
Edit: I will release the PHP script soon, so you can display how many people are online in your signature or on site!
Edit:
Code:
<?php $fs = @fsockopen("localhost", 50000, $errno, $errstr, 2);
if($fs)
{
stream_set_timeout($fs, 2);
write_byte($fs, 20);
$players = read_short($fs);
@fclose($fs);
echo "Server is online, players: ".$players;
}
else
echo "Server is offline.";
function write_byte($fs, $b)
{
@fwrite($fs, chr($b));
}
function read_byte($fs)
{
return ord(@fread($fs, 1));
}
function read_ubyte($fs)
{
return read_byte($fs) & 0xff;
}
function read_short($fs)
{
return (read_ubyte($fs) << 8) + read_ubyte($fs);
}
?>