PDA

View Full Version : Simple Script : users count ?


ZeTortue
09-04-2006, 14: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, 19: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, 20:05
Sorry the scrpt time out (over 60 seconds).

Used the same configuration (IP server) and ports as I use for TS Display script...

twitch
11-04-2006, 21:28
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

Cyrus
12-04-2006, 09:53
<?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

twitch
12-04-2006, 15:04
<?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

Frazze
06-05-2006, 19:21
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

Cyrus
06-05-2006, 19:41
http://de.php.net/manual/de/introduction.php

Slacker.
07-05-2006, 20: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";
?>

ScP
07-05-2006, 21:23
@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

Cyrus
08-05-2006, 14:35
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, 02:07
@ScP hehehe

where it didnt work for me 1st time than i fix that part and it did =P

darkdaemonlord
29-05-2006, 23:28
this'll help u
http://forum.goteamspeak.com/showthread.php?p=133396#post133396

tiamacik
31-05-2006, 18: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, 22:39
click the channel?!