TS3 FRAMEWORK - Get server information and values

spadeX

Member
Jun 9, 2018
6
4
38
Hi,
I want to get

server name
number of online users
server status

<?php

require_once('libraries/TeamSpeak3/TeamSpeak3.php');
$ts3 = TeamSpeak3::factory("serverquery://serveradmin:[email protected]:10011/?server_port=9987");

?>

I don't know how to get the values...
Can someone explain how to get them?

EDIT
Move this topic to "Script requests" please.
 
Last edited:

kalle

high minded
Contributor
Oct 28, 2015
411
253
178
Hope it helps xd.

PHP:
<?php
// First include our framework that we are gonna use
include_once('TeamSpeak3/TeamSpeak3.php');

// Connection configuration
$login_name = 'serveradmin';              // query login info
$login_password = '9kg6eRKk';             // =||=
$ip = 'localhost';                        // ex. 127.0.0.1/ 254.13.121.12
$query_port = '10011';                      // default 10011
$virtualserver_port= '9987';             // virtual server port

// Using try/ catch to resolve feature 'check if server is online'
try
{
    // Connecting query bot to the our specific  TS3  server
    $ts3 = TeamSpeak3::factory("serverquery://".$login_name.":".$login_password."@".$ip.":".$query_port."/?server_port=".$virtualserver_port."&nickname=R4P3&blocking=0");

    /*
        Now we have object in $ts3 variable so lets continue.
        To check what info object give to us, we can var_dump($ts3);
        This gives us a shit load of information so thats good.
    */

    // Shows the ip of your server
    echo ($ts3->getAdapterHost().'<br>');

    // Shows the port of your server
    echo ($ts3->virtualserver_port.'<br>');

    // Shows the name of your server
    echo ($ts3->virtualserver_name.'<br>');

    // Shows the uptime of your server
    echo (TeamSpeak3_Helper_Convert::seconds($ts3->virtualserver_uptime).'<br>');

    // Shows server current version
    echo (TeamSpeak3_Helper_Convert::version($ts3->virtualserver_version).'<br>');

    // Shows currents clients online / current slots on server
    echo ($ts3->virtualserver_clientsonline."/ ".$ts3->virtualserver_maxclients);
}
    catch(Exception $e)
{
  // Grab error and show server as offline
  echo ("Server Status: offline <br>" . $e);
}

?>

Output:
1543108489862.png

Gist: https://gist.github.com/kallefrombosnia/47743643d62d0511ef12e9e700d3ddc4
 
Last edited:
Top