Solved Get client from Group ID's

Status
Not open for further replies.

BayX

I'm the Root. Fear me!
Joined
Dec 18, 2015
Messages
75
Reaction score
27
Points
96
Heey peeps,
I hope everything's good!

I ran into a little dump yesterday.
I try to get users from a specific servergroup, which isn't any problems by using:
Code:
foreach($ts3->serverGroupClientList(groupid) as $user) {
echo $user['client_nickname'];
}

But I want to get clients from 2 or more groups, so I tried:
Code:
$uGroups = 1, 2;
foreach($ts3->serverGroupClientList($uGroups) as $user) {

echo $user['client_nickname'];

}
I also tried:
Code:
$uGroups = array(1, 2);
but that only got users from ServerGroup 1, not 2.

Anybody who have a little trick to get this to work?
 

adiksch

Member
Joined
Feb 11, 2016
Messages
7
Reaction score
1
Points
35
$users = [];
$users[] = $ts3->serverGroupClientList(1);
$users[] = $ts3->serverGroupClientList(2);
foreach($users as $user) {

echo $user['client_nickname'];

}
 

BayX

I'm the Root. Fear me!
Joined
Dec 18, 2015
Messages
75
Reaction score
27
Points
96
$users = [];
$users[] = $ts3->serverGroupClientList(1);
$users[] = $ts3->serverGroupClientList(2);
foreach($users as $user) {

echo $user['client_nickname'];

}

Hi adiksch,

I tried something similar yesterday but didn't work :confused:. I will modify the code a little and use your example and see if it works
 
Last edited:

adiksch

Member
Joined
Feb 11, 2016
Messages
7
Reaction score
1
Points
35
Update:

Use getelement ;)

$users = [];
$users[] = $ts3->getElement('data', $ts3->serverGroupClientList(1));
$users[] = $ts3->getElement('data', $ts3->serverGroupClientList(2));
foreach($users as $user) {

echo $user['client_nickname'];

}
 

BayX

I'm the Root. Fear me!
Joined
Dec 18, 2015
Messages
75
Reaction score
27
Points
96
Code:
Fatal error: Uncaught exception 'TeamSpeak3_Node_Exception' with message 'node method 'getElement()' does not exist' in /libraries/TeamSpeak3/Node/Abstract.php:381 Stack trace: #0 [internal function]: TeamSpeak3_Node_Abstract->__call('getElement', Array) #1 [internal function]: TeamSpeak3_Node_Host->getElement('data', Array) #2 /libraries/TeamSpeak3/Node/Abstract.php(378): call_user_func_array(Array, Array) #3 /extsubLib/test4.php(31): TeamSpeak3_Node_Abstract->__call('getElement', Array) #4 /extsubLib/test4.php(31): TeamSpeak3_Node_Server->getElement('data', Array) #5 {main} thrown in/libraries/TeamSpeak3/Node/Abstract.phpon line 381
Almost the same error as yesterday. I don't get it, or I'm just too tired to see it.. :confused:
 

adiksch

Member
Joined
Feb 11, 2016
Messages
7
Reaction score
1
Points
35
ohh you are not using ts3admin class use the first example
 

BayX

I'm the Root. Fear me!
Joined
Dec 18, 2015
Messages
75
Reaction score
27
Points
96
If I'm not wrong, getElement is only used by ts3admin and not TS3 PHP Framework. I was a little confused when I saw your reply with getElement :p

But I will modify it all again
 

BayX

I'm the Root. Fear me!
Joined
Dec 18, 2015
Messages
75
Reaction score
27
Points
96
No problem. I'm a little tired atm, maybe it's not my day today :p

When I var_dump($user); I get all values, but PHP throws the following error in my face when trying echo $user['client_nickname'];
Code:
Notice: Undefined index: client_nickname in /extsubLib/test4.php on line 37

UPDATE

I got it to work, but it kind of feels like a dirty fix
Code:
foreach($users as $user) {
         foreach($user as $userResult){
                 echo $userResult['client_nickname'];
          }
}

Remade the code and check functions, so this thread can be closed!

Mod edit: Locked;
 
Last edited by a moderator:
Status
Not open for further replies.
Top