View Full Version : Simple Script : users count ?
ZeTortue
09-04-2006, 15:18
Hello :)
I'm looking for a very simple script, it would just connect to my TS server and count the online users.
Do you know if it already exist ?
Thank you. :)
SilverCloud
09-04-2006, 20:44
Try to connect to the Telnet Service of TeamSpeak and query it with 'gi' (Global Info).
This should work in PHP, I've wrote this script on-the-fly so it could have some errors in it (not tested):
<?php
$server = '127.0.0.1';
$port = 51234;
// ///////
$fp = fsockopen($server, $port, $errno, $errstr, 5);
fwrite($fp, 'gi');
$content = '';
while(!feof($fp))
{
$content .= fread($fp, 1);
}
$array = explode("\n", $content);
$info = Array();
foreach($array AS $item)
{
list($key, $value) = explode("=", $item, 2);
$info[$key] = $value;
}
echo 'Number of players connected: ' . $info['total_users_online'];
?>
ZeTortue
10-04-2006, 21:05
Sorry the scrpt time out (over 60 seconds).
Used the same configuration (IP server) and ports as I use for TS Display script...
Hello :)
I'm looking for a very simple script, it would just connect to my TS server and count the online users.
Do you know if it already exist ?
Thank you. :)
Yes, something simple to display if the teamspeak server ip with online/offline and how many people are connected to the server, just actual number of people.
The above script didn't work for me either
<?php
require("cyts.class.php");
$ts = new cyts;
//Parameters are: IP-Address, TCP-Queryport, UDP-Port
$ts->connect("123.123.123.123", 51234, 8767) or die ("Unable to connect to TeamSpeak-server");
$srvinfo = $ts->info_serverInfo();
echo $srvinfo["server_currentusers"] . " user online";
?>
Save the above code as a file e.g. "servercount.php" and put it together with the cyts.class.php from http://cyts.midlink.org into one directory and run the servercount.php
<?php
require("cyts.class.php");
$ts = new cyts;
//Parameters are: IP-Address, TCP-Queryport, UDP-Port
$ts->connect("123.123.123.123", 51234, 8767) or die ("Unable to connect to TeamSpeak-server");
$srvinfo = $ts->info_serverInfo();
echo $srvinfo["server_currentusers"] . " user online";
?>
Save the above code as a file e.g. "servercount.php" and put it together with the cyts.class.php from http://cyts.midlink.org into one directory and run the servercount.php
Thanks for helping out :) That works like a champ, now I just need to pretty it up and maybe add an image for online or offline
Save the above code as a file e.g. "servercount.php" and put it together with the cyts.class.php from http://cyts.midlink.org into one directory and run the servercount.php
Could anyone please tell me how i can run a .php file ?
I' am trying to write me some scripts, for exampe kick someone, ... or similar things.
After reading the posts here I know that it is possible to do this commands with scripts, but how can I run .php files ? :confused:
Thanks for (hopefully) many answers :D
p.s.: Sorry if my English is a bit bad, cause I' am German and I' am learning English "only" since/for (fucking Englisch grammar :p, I think it' s "for", isn' t it??? ) 6 years xD
http://de.php.net/manual/de/introduction.php
Slacker.
07-05-2006, 21:55
<?php
require("cyts.class.php");
$ts = new cyts;
//Parameters are: IP-Address, TCP-Queryport, UDP-Port
$ts->connect("123.123.123.123", 51234, 8767) or die ("Unable to connect to TeamSpeak-server");
$srvinfo = $ts->info_serverInfo();
echo $srvinfo["server_currentusers"] . " user online";
?>
Save the above code as a file e.g. "servercount.php" and put it together with the cyts.class.php from http://cyts.midlink.org into one directory and run the servercount.php
Your code is wrong on the cyts you have just ts should be cyts
<?php
require("cyts.class.php");
$cyts = new cyts;
//Parameters are: IP-Address, TCP-Queryport, UDP-Port
$cyts->connect("123.123.123.123", 51234, 8767) or die ("Unable to connect to TeamSpeak-server");
$srvinfo = $cyts->info_serverInfo();
echo $srvinfo["server_currentusers"] . " user online";
?>
@Slacker.:
I don't think the name of an object will change something. In addition DarkCyrus knows what he's writing since he's the author of the cyts.class.php.
:o
All right ;-)
Explanation:
An object an instance of a class, an object (for example, "Lassie" the Dog) is the run-time manifestation (instantiation) of a particular exemplar of a class.
http://en.wikipedia.org/wiki/Object_oriented_programming#Fundamental_concepts
In our example: cyts is the class and $ts is the object (instance)
Slacker.
11-05-2006, 03:07
@ScP hehehe
where it didnt work for me 1st time than i fix that part and it did =P
darkdaemonlord
30-05-2006, 00:28
this'll help u
http://forum.goteamspeak.com/showthread.php?p=133396#post133396
tiamacik
31-05-2006, 19:00
Hi, I'm looking for players counting script, but showing only number of users in one of the channels - how to do it?
darkdaemonlord
08-06-2006, 23:39
click the channel?!
vBulletin® v3.7.3, Copyright ©2000-2009, Jelsoft Enterprises Ltd.