View Full Version : php users list
XenoMorpH
03-04-2008, 18:47
Does any1 have a php script which will show the online users in a list without the channels?
I have seen alot of scripts, but all of them show the channel names too.
maxi1990
03-04-2008, 20:24
<?php
include('cyts.class.php');
$ts = new cyts();
$ts->connect('127.0.0.1',51234,8767);
foreach($ts->info_playerList() as $user) {
echo $user['nick'] . '<br>';
};
$ts->disconnect;
?>
Not tested.
You need the cyts teamspeak php library in the same directory.
[EK]sparky
13-04-2008, 23:11
Thanks maxi for the code just about what i was looking for
I did what to display user for a gadet i am making but that started to look to big with the more users that entered to i have a flyout now that show all ts user in channels etc
Now i just need to edit your code so that it echos
users online or server empty
My php is not great heres what i came up with
<?php
include('cyts.class.php');
$ts = new cyts();
$ts->connect('209.135.157.14',51234,8767);
foreach ($ts->info_playerList() as $user) {
$result = sizeof($user);
//echo $user['nick'] . '<br>';
if ( $result == 0) {
echo "Empty";
}else{
echo "In Use";
}
};
$ts->disconnect;
?>
now it sort of works if the server has users in it will say
In Use but it will repeat it ie
4 users
in Use in use in use in use
i assume that is because of the array but how do i get out of it
also if there are no users in server nothing is echo
Please help
screenshots below
http://www.lawler-online.com/ts/1.jpg
http://www.lawler-online.com/ts/2.jpg
foreach ($ts->info_playerList() as $user) {
$result = sizeof($user);
//echo $user['nick'] . '<br>';
if ( $result == 0) {
echo "Empty";
} else{
echo "In Use";
}
};
I will do something like
instead of quoted code
$n=count($ts->info_playerList());
if ($n>0) echo ' There is '.$n.' users';
else echo 'everyone is outside sun is roasting xD';
used function from cyts class returns array with users
not tested just when I look here ... this came out
[EK]sparky
14-04-2008, 15:20
Thanks for reply Tomas
got it working now the problem was where the echo and else statments were, your code and mine behaved in the same repeating it self if there were users and nothing if empty
<?php
include('cyts.class.php');
$ts = new cyts();
$ts->connect('209.135.157.14',51234,8767);
foreach ($ts->info_playerList() as $user) {
$result = sizeof($user);
};
if ( $result == 0) {
echo "Empty";
}else{
echo "In Use";
}
$ts->disconnect;
?>
I guess by moving outside };
it must have broke the array
Anyway when gadet is finished ill post a link to any one who wants it
To do
Add setting option for use and pass 4 quick join icon
mske it all look nice and shiny :D
sparky;177541'] ...
lets be nice
I don't know what you did :mad: but ... ;) :
you know the code I posted is working. (I just tested)
just edit my echo-es as you need // like
<?php
include('cyts.class.php');
$ts = new cyts();
$ts->connect('209.135.157.14',51234,8767);
$n=count($ts->info_playerList());
if ($n>0) echo ' In use ';
else echo ' Empty ';
$ts->disconnect;
?>
[EK]sparky
15-04-2008, 12:39
Your code works fine and my code the problem was it would repeat it self
as many time as there was uses if the echo was before };
if you move the echo and else out side it did not repeat it self and Empty
or everyone is outside sun is roasting xD worked
So thanks again :D
I searched a lot, but where I can find the cyts.class.php ??:confused:
http://www.planetteamspeak.com/component/option,com_docman/task,doc_details/gid,41/Itemid,69/
Katana*GFR*
18-04-2008, 22:22
If you want to hide channels add &channels=0 to the link. Then it will display only the
users. This are the possible settings:
info=1 or info=0
channels=1 or channels=0
users=1 or users=0
Here is one example:
http://www.tsviewer.com/ts_viewer_pur.php?ID=27343&info=1&channels=0&users=1
http://www.tsviewer.com/ts_viewer_pur.php?ID=27343&info=1&channels=0&users=1
Just to add.
props go to Marius for helping me get a clean list to use on my cellphone. ( need it to check serverstatus, and to see who is online when im at work :D )
XenoMorpH
10-05-2008, 09:03
My pc brooke down, so I couldn't cehck for updates on this post.
Tnx for the codes :)
My intentions were also to create a Vista Gadget, which I succeeded to create :)
:cool:
Sparrky, Your version looks very nice :) Mine is a little different though :)
I will post a SS when I'm back on my PC.
vBulletin® v3.7.0, Copyright ©2000-2008, Jelsoft Enterprises Ltd.