request code

tiro

Member
Joined
Jun 6, 2016
Messages
27
Reaction score
4
Points
43
Hello,

I have control panel for games , but I want to add like this in my panel >> http://prntscr.com/bzv6h0
show how many client have this group ..

* SORRY FOR BAD ENGLISH *
 

Najsr

Moderator
TeamSpeak Developer
Joined
Apr 23, 2016
Messages
483
Reaction score
249
Points
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
Joined
Jun 6, 2016
Messages
27
Reaction score
4
Points
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
Joined
Apr 23, 2016
Messages
483
Reaction score
249
Points
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