PS status script

Overview

This page provides a little status informer for everyone who's interested. What it does is simply check if your character is online on Zeroping, and output an image representing this status.

This image can be embedded into the signature on the PlaneShift forums, for example.

How it works

The idea behind it is the same as in this script: It fetches the Zeroping server's status page and extracts the list of names of all online players. This list is then stored locally for ten minutes, in order not to mess with the server too much. I might reduce that interval to 2 minutes if someone gives me sensible reason to do so, but at the moment, I don't think a 10 minute interval is too long.

Usage

To show your character's status, just use the link of the following form:

http://psstatus.uglyhorst.de/<Character Name>.png

Of course, you will have to replace "<Character Name>" by your character's name (first name only), e.g.:

http://psstatus.uglyhorst.de/Masterfighter.png

The result of that would look something like this:

Alternatively, you can specify a comma seperated list of all your characters' names at once, for example:

http://psstatus.uglyhorst.de/Masterfighter,Orkkiller,SlaughterhouseDarling.png

In that case, the online statuses of all your characters will be checked at once, and the names will be enumerated in a comma seperated list where the names of online characters will be written in green, those of offline ones in red color, much like this:

Instead of showing all your characters individually, you can also make it only show a defined alias, for example, your forum name:

http://psstatus.uglyhorst.de/leetPLer:Masterfighter,Orkkiller,SlaughterhouseDarling.png

With this variant, you will be shown as online when at least one of your characters is online on Zeroping, and your characters' names will not be shown, in favor of the alias you specified. Our little example would look like this:

You can use anything as an alias except real character names. If your alias is the same as an existing character name, it will be ignored and your characters will be displayed individually instead. The alias must not include an ampersand (&) or question mark (?) character.

Note: the names used in these examples are deliberately chosen not to conflict with any real names on the server. You should probably not use those namen on Zeroping; legend has it that the gods there tend not to tolerate names like that.

Advanced Usage

If you find the regular online / offline message boring, you can create your own images to be shown in these cases. If you want the script to use your own images, procede like this:

This manual procedure may seem a little strange, but it ensures a great security of the system :P

For developers

You can get an alphabetically sorted list of currently online characters in one of three different formats to use it in your own scripts:

Serialized PHP array

This format is handy to use from PHP, though you might as well use JSON instead. It can't be used well from any other languages. You can get this from the following address:

http://psstatus.uglyhorst.de/chars_array.txt

Simple usage example (PHP):

<?php
    // Load the array of characters currently on Zeroping
    $chars = unserialize(file_get_contents('http://psstatus.uglyhorst.de/chars_array.txt'));
    echo('Alphabetically last character: ' . $chars[count($chars)-1]);
?>

You can download a more detailed PHP example from here (you'll find usage instructions inside the zip file).

JSON / JSONP

Though primarily aimed at JavaScript, JSON support is now available on most major web languages in some form or another. The list can be downloaded in this form from the following address:

http://psstatus.uglyhorst.de/chars_json.txt

To take advantage of it from JavaScript, there's also JSONP support. Just set the GET variable 'p' to the name of your callback function. Using jQuery, you can load the list like this:

$.getJSON('http://psstatus.uglyhorst.de/chars_json.txt?p=?', function(chars) {
    document.write('Alphabetically first character: ' + chars[0]);
});

If you don't want to or can't install jQuery, you have to type a bit more to manually get JSONP working:

// JSONP callback function
function callback(chars) {
    id = Math.floor(Math.random() * chars.length);
    alert('Totally random character: ' + chars[id]);
}

// Insert a <script> node to load the remote file
var head = document.getElementsByTagName('head')[0];
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = 'http://psstatus.uglyhorst.de/chars_json.txt?p=callback';
head.appendChild(script);

Plain text

If you're using a language with no JSON support (for example, one that is not web-oriented), you can also download the list in a plain text format, where names are separated by line feed characters. Its address is:

http://psstatus.uglyhorst.de/chars_list.txt

For example, to get an array of online characters in Ruby, try this:

require 'net/http'

# Load the array of characters currently on Zeroping
chars = Net::HTTP.get('psstatus.uglyhorst.de', '/chars_list.txt').split("\n")
number = chars.count { |name| name.start_with?('D') }
puts "Number of characters whose names start with a 'D': #{number}"

Other formats might be added on request or at will.

Afterword

I hope you enjoy using this little script! Or ignore it if you don't like it.