TeamSpeak 3 PHP Framework

mardi 15 septembre 2015

I am still learning PHP and it's the first time I am using this library (TeamSpeak 3 PHP Framework), I am trying to return a count of online users in a specific group, I tried a few different ways and no success.

This one, counts all users in the group (including offline users):

PHP Code:

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


So I tried to compare that list with the online users list:

PHP Code:

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


And it works sometimes, I say sometimes because I tried it on my virtual server and no issues, the count was right, but when I tried it on another virtual server (I changed the group ID and port) I get this:

PHP Code:

Warningpreg_match(): Unknown modifier '9' in C:\xampp\htdocs\serverstatus\libraries\TeamSpeak3\Helper\String.php on line 192 

That warning only shows up with some server groups, I don't know the reason.



PHP Code:

$admins 0;
foreach(
$ts3->clientList($client) as $client) {
    
$admins++;


I guess this piece of code should show all online users but I tested it and the value is not always the online users, like I said before on my virtual server it shows the right count but when I tried it on another virtual server I got 48 but there are 61 users online.
TeamSpeak 3 PHP Framework

0 commentaires:

Enregistrer un commentaire