Games::AssaultCube::ServerQuery - Queries a running AssaultCube server for information


        use Games::AssaultCube::ServerQuery;
        my $query = Games::AssaultCube::ServerQuery->new( '' );
        #my $query = Games::AssaultCube::ServerQuery->new( '', 12345 );
        #my $query = Games::AssaultCube::ServerQuery->new({ server => '', port => 12345, timeout => 5 });
        my $response = $query->run;
        if ( defined $response ) {
                print "Server is running with " . $response->players . " players\n";
        } else {
                print "Server is not responding!\n";


This module queries a running AssaultCube server for information.


This module queries a running AssaultCube server for information. This has been tested extensively on AssaultCube-1.0.2 servers, so beware if you try older/newer ones! Also, not all servers return all data, so be sure to check for it in your code...


This module uses Moose, so you can pass either a hash, hashref, or a server/port to the constructor. Passing a string means we're passing in a server hostname/ip. If you want to specify more options, please use the hash/hashref method.

The attributes are:


The server hostname or ip.


The server port. Defaults to 28763.

WARNING: AssaultCube uses $port+1 for the query port. Please do not do pass $port+1 to the constructor, we do it internally. Maybe in the future AC will use $port+2 or another system, so let us deal with it :)


Should we also retrieve the playerlist? This is a boolean which defaults to false.


The timeout waiting for the server response in seconds. Defaults to 30.

WARNING: We use alarm() internally to do the timeout. If you used it somewhere else, it will cause conflicts and potentially render it useless. Please inform me if there's conflicts in your script and we can try to work around it.


Currently, there is only one method: run(). You call this and get the response object back. For more information please look at the Games::AssaultCube::ServerQuery::Response class. You can call run() as many times as you want, no need to re-instantiate the object for each query.

WARNING: run() will die() if errors happen. For sanity, you should wrap it in an eval.


You can modify some attributes before calling run() on the object. They are:


Same as the constructor


Same as the constructor


Same as the constructor


Apocalypse <>

Props goes to Getty and the BS clan for the support!

This project is sponsored by

Also, thanks goes out to PxL for the initial PHP implementation which helped in unraveling the AssaultCube mess.

We also couldn't have done it without staring at the AssaultCube C++ code for hours, ha!


Copyright 2009 by Apocalypse

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.