request code

Najsr

Moderator
TeamSpeak Developer
Apr 23, 2016
483
249
167
Try this one.
PHP:
require_once('libraries/TeamSpeak3/TeamSpeak3.php');
$ts3_VirtualServer = TeamSpeak3::factory("username:password//localhost:10011/?server_port=9987");
$groups = array(10,11,12);
foreach($groups as $group)
{
    $group = $ts3_VirtualServer->serverGroupGetById($group);
    $count = 0;
    foreach($group->clientList() as $client)
    {
        $count = $count + 1;
    }
    echo "Group " . $group . " has " . $count . "clients";
}
 

tiro

Member
Jun 6, 2016
27
4
43
Try this one.
PHP:
require_once('libraries/TeamSpeak3/TeamSpeak3.php');
$ts3_VirtualServer = TeamSpeak3::factory("username:password//localhost:10011/?server_port=9987");
$groups = array(10,11,12);
foreach($groups as $group)
{
    $group = $ts3_VirtualServer->serverGroupGetById($group);
    $count = 0;
    foreach($group->clientList() as $client)
    {
        $count = $count + 1;
    }
    echo "Group " . $group . " has " . $count . "clients";
}
not work
 

Najsr

Moderator
TeamSpeak Developer
Apr 23, 2016
483
249
167
PHP:
require_once('libraries/TeamSpeak3/TeamSpeak3.php');
$ts3_VirtualServer = TeamSpeak3::factory("serverquery://user:pw@localhost:10011/?server_port=9987");
$groups = array(90,94,95);
foreach($groups as $group)
{
    $group = $ts3_VirtualServer->serverGroupGetById($group);
    $count = 0;
    foreach($group->clientList() as $client)
    {
        $count = $count + 1;
    }
    echo "Group " . $group . " has " . $count . " clients<br/>";
}
Had a mistake in connection. Now it works! (tested :p)
EDIT: Or if you want it as a function...
PHP:
require_once('libraries/TeamSpeak3/TeamSpeak3.php');
$ts3_VirtualServer = TeamSpeak3::factory("serverquery://user:pw@localhost:10011/?server_port=9987");
function getClientsInServerGroup($group)
{
    $group = $ts3_VirtualServer->serverGroupGetById($group);
    $count = 0;
    foreach($group->clientList() as $client)
    {
        $count = $count + 1;
    }
    return $count;
}
//64 - group ID
echo "Group Admin has " . getClientsInServerGroup(64) . " members.";

 
Last edited:
Top