Clients online via server group

Archie

Member
Feb 8, 2016
129
8
53
Name of the script: Clients online via server group
Functions of the script: The script will scan the server and display how many people are online per server group. For example it would be on my website and it would say X - Admins online

Why do you want it: For my website
Screenshots: None
Orginal source (if any): None
Other notes: Of course it needs to be in PHP.

Thanks if you can help!
 

JetFox

Active Member
Sep 25, 2015
175
76
73
PHP:
<?php
require_once('libraries/TeamSpeak3/TeamSpeak3.php');

// server 1
$s1_user = 'username';
$s1_pass = 'password';
$s1_ip = '1.1.1.1:10011';
$s1_port = 9987;

$ts3 = TeamSpeak3::factory("serverquery://$s1_user:$s1_pass@$s1_ip/?server_port=$s1_port");

$admins = 0; foreach($ts3->serverGroupGetById(12)->clientList() as $client) { if($ts3->clientList($client)) { $admins++; } }

?>

Just a quick throw together..
Make sure to change the group id from 12 to the group your looking for
 

Archie

Member
Feb 8, 2016
129
8
53
PHP:
<?php
require_once('libraries/TeamSpeak3/TeamSpeak3.php');

// server 1
$s1_user = 'username';
$s1_pass = 'password';
$s1_ip = '1.1.1.1:10011';
$s1_port = 9987;

$ts3 = TeamSpeak3::factory("serverquery://$s1_user:$s1_pass@$s1_ip/?server_port=$s1_port");

$admins = 0; foreach($ts3->serverGroupGetById(12)->clientList() as $client) { if($ts3->clientList($client)) { $admins++; } }

?>

Just a quick throw together..
Make sure to change the group id from 12 to the group your looking for
Thanks for this but i've changed it to my group numbers 9,15,133 but it isn't working? http://prntscr.com/ce4dy3 Same goes for if I only have 9 etc
 

JetFox

Active Member
Sep 25, 2015
175
76
73
Do a <?php echo $admins ?> before the admins online the top part was just to get the $admins counter
 

JetFox

Active Member
Sep 25, 2015
175
76
73
Oh i dont think it allows commas in it..

Use this:

PHP:
<?php
require_once('libraries/TeamSpeak3/TeamSpeak3.php');

// server 1
$s1_user = 'username';
$s1_pass = 'password';
$s1_ip = '1.1.1.1:10011';
$s1_port = 9987;

$ts3 = TeamSpeak3::factory("serverquery://$s1_user:$s1_pass@$s1_ip/?server_port=$s1_port");

$admins = 0; foreach($ts3->serverGroupGetById(9)->clientList() as $client) { if($ts3->clientList($client)) { $admins++; } }

foreach($ts3->serverGroupGetById(15)->clientList() as $client) { if($ts3->clientList($client)) { $admins++; } }

foreach($ts3->serverGroupGetById(133)->clientList() as $client) { if($ts3->clientList($client)) { $admins++; } }

echo $admins;

?>
 
Last edited:

Archie

Member
Feb 8, 2016
129
8
53
Oh i dont think it allows commas in it..

Use this:

PHP:
<?php
require_once('libraries/TeamSpeak3/TeamSpeak3.php');

// server 1
$s1_user = 'username';
$s1_pass = 'password';
$s1_ip = '1.1.1.1:10011';
$s1_port = 9987;

$ts3 = TeamSpeak3::factory("serverquery://$s1_user:$s1_pass@$s1_ip/?server_port=$s1_port");

$admins = 0; foreach($ts3->serverGroupGetById(9)->clientList() as $client) { if($ts3->clientList($client)) { $admins++; } }

$admins2 = 0; foreach($ts3->serverGroupGetById(15)->clientList() as $client) { if($ts3->clientList($client)) { $admins2++; } }

$admins3 = 0; foreach($ts3->serverGroupGetById(133)->clientList() as $client) { if($ts3->clientList($client)) { $admins3++; } }

$finale = $admins+$admins2+$admins3;

echo $finale;

?>
This still doesn't work, displays 3 when 5 are on. Could you try something different please
 

JetFox

Active Member
Sep 25, 2015
175
76
73
Try the above one more time, modified it..

If not try this
PHP:
<?php
require_once('libraries/TeamSpeak3/TeamSpeak3.php');

// server 1
$s1_user = 'username';
$s1_pass = 'password';
$s1_ip = '1.1.1.1:10011';
$s1_port = 9987;

$ts3 = TeamSpeak3::factory("serverquery://$s1_user:$s1_pass@$s1_ip/?server_port=$s1_port");

$admins = 0; foreach($ts3-> serverGroupGetByName("Head Admin")->clientList() as $client) { if($ts3->clientList($client)) { $admins++; } }

 foreach($ts3-> serverGroupGetByName("Admin")->clientList() as $client) { if($ts3->clientList($client)) { $admins++; } }

foreach($ts3-> serverGroupGetByName("Moderator")->clientList() as $client) { if($ts3->clientList($client)) { $admins++; } }

echo $admins;

?>
 

Archie

Member
Feb 8, 2016
129
8
53
Try the above one more time, modified it..

If not try this
PHP:
<?php
require_once('libraries/TeamSpeak3/TeamSpeak3.php');

// server 1
$s1_user = 'username';
$s1_pass = 'password';
$s1_ip = '1.1.1.1:10011';
$s1_port = 9987;

$ts3 = TeamSpeak3::factory("serverquery://$s1_user:$s1_pass@$s1_ip/?server_port=$s1_port");

$admins = 0; foreach($ts3-> serverGroupGetByName("Head Admin")->clientList() as $client) { if($ts3->clientList($client)) { $admins++; } }

foreach($ts3-> serverGroupGetByName("Admin")->clientList() as $client) { if($ts3->clientList($client)) { $admins++; } }

foreach($ts3-> serverGroupGetByName("Moderator")->clientList() as $client) { if($ts3->clientList($client)) { $admins++; } }

echo $admins;

?>
Nope sorry now it only says 2 when we have 5 online.
 

JetFox

Active Member
Sep 25, 2015
175
76
73
This code wont do everyone its just a test since im not home but comment out the $admin echo and put this in

PHP:
// query specific clientlist from virtual server test

$arr_ClientList = $ts3-> serverGroupGetByName("Head Admin")->clientList();

foreach($arr_ClientList as $value){
    echo $value;   
?>  <br />
<?php
}
?>

And let me know what it says
 
Last edited:
Dec 19, 2015
114
15
53
Can you Make It With The Admins Names
Oh i dont think it allows commas in it..

Use this:

PHP:
<?php
require_once('libraries/TeamSpeak3/TeamSpeak3.php');

// server 1
$s1_user = 'username';
$s1_pass = 'password';
$s1_ip = '1.1.1.1:10011';
$s1_port = 9987;

$ts3 = TeamSpeak3::factory("serverquery://$s1_user:$s1_pass@$s1_ip/?server_port=$s1_port");

$admins = 0; foreach($ts3->serverGroupGetById(9)->clientList() as $client) { if($ts3->clientList($client)) { $admins++; } }

foreach($ts3->serverGroupGetById(15)->clientList() as $client) { if($ts3->clientList($client)) { $admins++; } }

foreach($ts3->serverGroupGetById(133)->clientList() as $client) { if($ts3->clientList($client)) { $admins++; } }

echo $admins;

?>
 
Top