Forum


Notice to all users

We are migrating towards a new forum system located at community.teamspeak.com, as such this forum will become read-only on January 29, 2020

Page 94 of 100 FirstFirst ... 44849293949596 ... LastLast
Results 1,396 to 1,410 of 1498
  1. #1396
    Join Date
    April 2014
    Location
    Seattle, WA, USA
    Posts
    141
    Quote Originally Posted by savos View Post
    // connect to local server, authenticate and spawn an object for the virtual server on port 9987
    $ts3_VirtualServer = TeamSpeak3::factory("serverquery://<username>:<password>@<address>:10011/?server_port=9987");
    Maybe you're just hiding credentials for the post, but you did make sure to put in real values for <username>, <password>, <address>?

    Otherwise, your code looks fine...

    Quote Originally Posted by mr-brown View Post
    Hello ma friends,

    i have a problem where i need help.

    The API is working fine when i am running it local under xampp with a puplic (not local) teamspeak.
    Then i uploaded it to my webspace and i only get the following message:



    The teamspeak server is working, i also can connect the server query with putty.
    I think my webspace provider (https://www.hetzner.de/) is blocking outgoing connections like it is used in the API.
    How can i verify this?
    It is possible to check the requirements with phpinfo()?

    I would appreciate help.
    Your web host should provide you with ssh access. You can login, and then test with using telnet:
    $ telnet <remote teamspeak IP> 10011

    You should see the TeamSpeak 3 Server Query prompt.

    Quote Originally Posted by Webster23 View Post
    Hello,

    I am trying to make a function that moves people when they login. However, the functions of
    Code:
    $ts3_VirtualServer->notifyRegister("server");
    $ts3_VirtualServer->notifyRegister("channel");
    TeamSpeak3_Helper_Signal::getInstance()->subscribe("notifyLogin", "onLogin");
    function onLogin(TeamSpeak3_Node_Host $host){
    ....
    }
    are not working. I believe the notifyLogin is what is called when someone joins the server, however it is not firing. Any help would be nice.
    notifyLogin is not emitted when someone joins the server.

    It is emitted from TeamSpeak3_Node_Host::login().
    "Authenticates with the TeamSpeak 3 Server instance using given ServerQuery login credentials."
    [doc] [src]


    The notify event you're looking for is notifyCliententerview.
    You can subscribe and register as follows:

    PHP Code:
      // Subscribe to event.
      
    TeamSpeak3_Helper_Signal::getInstance()->subscribe("notifyCliententerview""onClientEnterView");

      
    // Connect to server, login and get TeamSpeak3_Node_Host object by URI
      
    $ts3 TeamSpeak3::factory("serverquery://" $cfg["user"] . ":" $cfg["pass"] . "@" $cfg["host"] . ":" $cfg["query"] . "/?server_port=" $cfg["voice"] . "&blocking=0");

      
    // Register for events as needed...
      
    $ts3->notifyRegister("server");
      
    $ts3->notifyRegister("channel");
      
    $ts3->notifyRegister("textserver");
      
    $ts3->notifyRegister("textchannel");
      
    $ts3->notifyRegister("textprivate");

      function 
    onClientEnterView(TeamSpeak3_Node_Host $host){
        
    // move client to target channel...
      

    Quote Originally Posted by DerRene View Post
    How can i give a channel group to a user?
    Please search the documentation before posting:

    TeamSpeak3_Node_Server::clientSetChannelGroup($cld bid, $cid, $cgid)

    Quote Originally Posted by ibot3 View Post
    Hello,
    I'm trying to get a TS viewer. It's working fine on the one mashine but not working on the other. I'm getting this error:

    https://pastebin.com/dnDeaCW0
    (Can't paste it here, because the page forbids me to submit the post with the error)

    My Code:
    Code:
    public function GetViewer(){
                return $this->worker->getViewer(new TeamSpeak3_Viewer_Html("assets/img/teamspeak_viewer/", "assets/img/countryflags-dis/", "data:image"));
    }
    Retrieving server information like online users is working fine with the same instance of the API.
    I recommend double-checking the file locations on the other machine:
    'assets/img/teamspeak_viewer/'
    'assets/img/countryflags-dis/'

    You might also try absolute path ('/....../assets/img/.....', etc) just to be safe.

    Quote Originally Posted by Myszax View Post
    I think I found some kind of bugs.
    1. When channel is named as number eg. 123456 then channelList() return this channel_name as integer not as TeamSpeak3_Helper_String.

    Edit:
    I found fix for second bug on github: https://github.com/planetteamspeak/t...07492fb7e32225
    Also I found another issue in situation that normally can not happen.
    3. When I tried to download avatar and avatar file does not exist in ts_server_dir/files/virtualserver_1/internal my script get stuck, some kind of freeze and the only way to handle this is to kill process.
    This could happen when some own copy server without files folder like I did for fast backup for tests only.

    Myszax.
    2nd bug is on GitHub repo as you found.

    I can confirm 1st bug. If you have not already, I highly recommend opening two issues (one of each bug, 1st and 3rd).
    This will greatly speed testing / fix implementation.

    Thank you for pointing this out and providing examples, really helps a lot!

    Quote Originally Posted by specialMen_ View Post
    Guys I make a control panel, To control my server, Stop the server, start the server, Server Information.
    When I stop the server The Website Is stop.
    So how I can fix that problem?,
    What do you mean by 'the website is stop'?
    From your code, I see no loop logic that would stop the webpage from stopping after the framework request is finished.
    If you want live server info, you need to use a loop (not recommended) or asynchronous refresh your server properties.

    However, I'm still not sure exactly what issue you're having.

    Quote Originally Posted by mr-brown View Post
    Please close the threat. Doesn't make sense to post here.

    There is no support at all.
    There are many ways to find the information for yourself:

    With almost 100 pages of questions / examples in this forum, you can search google: 'how do I... site:forum.teamspeak.com'
    You can check docs: https://docs.planetteamspeak.com/ts3/php/framework/
    You can search source code: https://github.com/planetteamspeak/ts3phpframework
    If you need real support, in the form of a bug fix, you can create an issue at the GitHub repo.

    (not meaning to aggravate, just pointing out many sources of information, in case you are not aware...)

    Quote Originally Posted by orydek View Post
    My bot only working 10min. Someone have any solutions?
    You need to handle keepalive, otherwise your bot will be timed out by the TeamSpeak 3 server after 10 minutes.

    Please search before simply posting, there are many examples of this. Some keywords to search with might be 'timeout', 'keepalive', etc.

    NOTE: There may be bug in published / release version of the framework. Recommend downloading the latest directly from GitHub.
    onServerQueryTimeout Bug: https://github.com/planetteamspeak/t...c9e88dca9dae19
    Download latest version: https://github.com/planetteamspeak/t...ive/master.zip

    Here is an example ScP gave for 'event based daemon', which implements onTimeout() keepalive logic:

    PHP Code:
    <?php

    /* load framework library */
    require_once("TeamSpeak3/TeamSpeak3.php");

    /* initialize */
    TeamSpeak3::init();

    try
    {
      
    /* subscribe to various events */
      
    TeamSpeak3_Helper_Signal::getInstance()->subscribe("serverqueryConnected""onConnect");
      
    TeamSpeak3_Helper_Signal::getInstance()->subscribe("serverqueryWaitTimeout""onTimeout");
      
    TeamSpeak3_Helper_Signal::getInstance()->subscribe("notifyLogin""onLogin");
      
    TeamSpeak3_Helper_Signal::getInstance()->subscribe("notifyEvent""onEvent");
      
    TeamSpeak3_Helper_Signal::getInstance()->subscribe("notifyServerselected""onSelect");

      
    /* connect to server, login and get TeamSpeak3_Node_Host object by URI */
      
    $ts3 TeamSpeak3::factory("serverquery://username:[email protected]:10011/?server_port=9987&blocking=0");

      
    /* wait for events */
      
    while(1$ts3->getAdapter()->wait();
    }
    catch(
    Exception $e)
    {
      die(
    "[ERROR]  " $e->getMessage() . "\n");
    }

    // ================= [ BEGIN OF CALLBACK FUNCTION DEFINITIONS ] =================

    /**
     * Callback method for 'serverqueryConnected' signals.
     *
     * @param  TeamSpeak3_Adapter_ServerQuery $adapter
     * @return void
     */
    function onConnect(TeamSpeak3_Adapter_ServerQuery $adapter)
    {
      echo 
    "[SIG]\tconnected to TeamSpeak 3 Server on " $adapter->getHost() . "\n";

      echo 
    "[INFO]\tserver is running with version " $adapter->getHost()->version("version") . " on " $adapter->getHost()->version("platform") . "\n";
    }

    /**
     * Callback method for 'serverqueryWaitTimeout' signals.
     *
     * @param  integer $seconds
     * @return void
     */
    function onTimeout($secondsTeamSpeak3_Adapter_ServerQuery $adapter)
    {
      echo 
    "[SIG]\tno reply from the server for " $seconds " seconds\n";

      if(
    $adapter->getQueryLastTimestamp() < time()-300)
      {
        echo 
    "[INFO]\tsending keep-alive command\n";

        
    $adapter->request("clientupdate");
      }
    }

    /**
     * Callback method for 'notifyLogin' signals.
     *
     * @param  TeamSpeak3_Node_Host $host
     * @return void
     */
    function onLogin(TeamSpeak3_Node_Host $host)
    {
      echo 
    "[SIG]\tauthenticated as user " $host->whoamiGet("client_login_name") . "\n";
    }

    /**
     * Callback method for 'notifyEvent' signals.
     *
     * @param  TeamSpeak3_Adapter_ServerQuery_Event $event
     * @param  TeamSpeak3_Node_Host $host
     * @return void
     */
    function onEvent(TeamSpeak3_Adapter_ServerQuery_Event $eventTeamSpeak3_Node_Host $host)
    {
      echo 
    "[SIG]\treceived notification " $event->getType() . "\n\t" $event->getMessage() . "\n";
    }

    /**
     * Callback method for 'notifyServerselected' signals.
     *
     * @param  string $cmd
     * @return void
     */
    function onSelect(TeamSpeak3_Node_Host $host)
    {
      echo 
    "[SIG]\tselected virtual server with ID " $host->serverSelectedId() . "\n";
      
      
    $host->serverGetSelected()->notifyRegister("server");
      
    $host->serverGetSelected()->notifyRegister("channel");
      
    $host->serverGetSelected()->notifyRegister("textserver");
      
    $host->serverGetSelected()->notifyRegister("textchannel");
      
    $host->serverGetSelected()->notifyRegister("textprivate");
    }
    [ref]

    Quote Originally Posted by DerRene View Post
    I got the following script to list all connected Clients, but i want to show the Server Group Icons of the Users as well in the list. How can i add that? I dont understand...

    Code:
    echo "<div class='list-group'>";
    foreach($ts3_VirtualServer->clientList() as $client) {
    	echo "<a href='#' class='list-group-item'>" . $client . "</a>";
    }
    echo "</div>";
    This is just some pseudo-code to get you going in the right direction:

    PHP Code:
    echo "<div class='list-group'>";
    foreach(
    $ts3_VirtualServer->clientList() as $client) {
      
    // Open row / line / link tag
      
    echo "<a href='#' class='list-group-item'>" $client;

        foreach(
    $client->memberOf() as $group) {
          
    // Get raw byte data for image, encoded in whatever the icon's Mime type is.
          
    $iconData $group->iconDownload();
          
          
    // Dump raw image data by base64 encoding into HTML <img /> tag.
          
    echo ' <img src="data:' TeamSpeak3_Helper_Convert::imageMimeType($iconData) . ';base64,' base64_encode($iconData) . '" alt="'.$group['name'].'" /> ';
        }
      echo 
    "</a>";
    }
    echo 
    "</div>"
    Again, this is untested pseudo-code, please troubleshoot / adjust as needed, but hopefully will give you an idea of how to do it.

    You will probably need additional styling to render icons inline, etc.
    Last edited by Chris; March 30th, 2017 at 07:57 AM. Reason: merged 10 posts in a row.

  2. #1397
    Join Date
    April 2017
    Posts
    1

    How do I find the number of clients in each channel using the API

    I'm trying to use the API to make a script that will help me find out which channels are used and which channels aren't so I can get rid of unused channels. I can't figure out how to get the number of users for each channel. Here is the script I've been testing with and it cycles through all the channels correctly but each loop just shows the number of clients in the entire server and not just that channel.

    PHP Code:
    <?php

    //Config
    $user "USER";
    $pass "PASS";
    $serverIP "IP";

    // load framework files
    require_once("libraries/TeamSpeak3/TeamSpeak3.php");

    // connect to local server, authenticate and spawn an object for the virtual server on port 9987
    $ts3_VirtualServer TeamSpeak3::factory("serverquery://{$user}:{$pass}@{$serverIP}:10011/?server_port=9987");

    // cycle through each channel and list how many clients there are
    foreach ($ts3_VirtualServer->channelList() as $ts3_Channel) {
      
    $number $ts3_Channel->clientCount();
      echo 
    $ts3_Channel " " $number "\n";
    }

    ?>
    Last edited by bamajoe411; April 6th, 2017 at 09:24 PM.

  3. #1398
    Join Date
    April 2014
    Location
    Seattle, WA, USA
    Posts
    141
    Quote Originally Posted by bamajoe411 View Post
    I'm trying to use the API to make a script that will help me find out which channels are used and which channels aren't so I can get rid of unused channels. I can't figure out how to get the number of users for each channel. Here is the script I've been testing with and it cycles through all the channels correctly but each loop just shows the number of clients in the entire server and not just that channel.

    PHP Code:
    <?php

    //Config
    $user "USER";
    $pass "PASS";
    $serverIP "IP";

    // load framework files
    require_once("libraries/TeamSpeak3/TeamSpeak3.php");

    // connect to local server, authenticate and spawn an object for the virtual server on port 9987
    $ts3_VirtualServer TeamSpeak3::factory("serverquery://{$user}:{$pass}@{$serverIP}:10011/?server_port=9987");

    // cycle through each channel and list how many clients there are
    foreach ($ts3_VirtualServer->channelList() as $ts3_Channel) {
      
    $number $ts3_Channel->clientCount();
      echo 
    $ts3_Channel " " $number "\n";
    }

    ?>
    The best way to do this is hinted at in the PHP TS3 Framework for TeamSpeak3_Node_Channel::clientList():

    PHP Code:
    foreach($this->getParent()->clientList() as $client)
    {
      if(
    $client["cid"] == $this->getId())
      {
        
    $clients[$client->getId()] = $client;
      }

    [ref]

    Adapted for your purpose, something like this might work:
    PHP Code:
    $channels = [];

    foreach(
    $ts3_VirtualServer->clientList() as $client)
    {
      if (!
    $channels[$client["cid"]]) {
        
    $channels[$client["cid"]] = 1
      
    } else {
        
    $channels[$client["cid"]]++
      }
    }

    // Sort by value, low to high, maintain key association:
    asort($channels);

    // Print Channels, lowest number of clients will show first.
    print_r($channels); 
    Please note: this logic is the reverse (or inverse) of your described method.

    It loops the entire set of clients, initializing a counter for any channel a client is in.
    If the channel already has a counter, it is incremented by one.
    Last edited by Ronin Design; April 10th, 2017 at 04:52 PM. Reason: Added doc reference

  4. #1399
    Join Date
    April 2017
    Posts
    1
    Hey,

    I coded a little Plugin for my User Control Panel, sending out a Poke Message with a randomly generated code to an User.
    The Plugin works great too.

    The only Problem we have is, that for some Users, the Poke Messages doesn't arrive...
    Now it happened to 2 People and I can't explain myself why.

    Does anybody maybe know something?

  5. #1400
    Join Date
    April 2017
    Posts
    1

    List all clients in one specific channel

    Hi. Trying to get a list of all clients in one specific channel. Currently using this but getting 500 error.
    (the username and password has been omitted)

    Code:
    <?php
    
        error_reporting(-1);
        ini_set("display_errors", 1); 
    // load framework files
    require_once("libraries/TeamSpeak3/TeamSpeak3.php");
    // connect to local server, authenticate and spawn an object for the virtual server on port 9987
    $ts3_VirtualServer = TeamSpeak3::factory("serverquery://USERNAME:[email protected]:10011/?server_port=9987");
    
    // grab current channel ID
    $current_cid = $ts3->whoamiGet("cid");
    
    // query the client list and filter by cid
    $ts3->clientList(array("cid" => 28))
    
    // spit out client nicknames
    foreach($clients as $clid => $client)
    {
      echo $client . "\n";
    }  
    
    ?>

  6. #1401
    Join Date
    April 2014
    Location
    Seattle, WA, USA
    Posts
    141
    Quote Originally Posted by GambarojaLP View Post
    Hey,

    I coded a little Plugin for my User Control Panel, sending out a Poke Message with a randomly generated code to an User.
    The Plugin works great too.

    The only Problem we have is, that for some Users, the Poke Messages doesn't arrive...
    Now it happened to 2 People and I can't explain myself why.

    Does anybody maybe know something?
    ...it's hard to say without seeing your code around the poke logic.

    There could be several things, are you getting any errors?

    Some idea though:
    Poking a client that no longer has the same client_id (e.g. you're not keeping client list updated).
    Poke message is too long?
    Server throttling / antiflood?
    Client timeout while waiting for something or after being loaded for 10 minutes (keepalive)?
    Needed poke power?
    Internal interrupting logic, e.g. something causing the plugin to error / except before it gets a chance to send poke?

    Really could be lots of things...
    Maybe try sending textmessage along with the poke to increase chance of delivery...

    Quote Originally Posted by samlmao View Post
    Hi. Trying to get a list of all clients in one specific channel. Currently using this but getting 500 error.
    (the username and password has been omitted)

    Code:
    <?php
    
        error_reporting(-1);
        ini_set("display_errors", 1); 
    // load framework files
    require_once("libraries/TeamSpeak3/TeamSpeak3.php");
    // connect to local server, authenticate and spawn an object for the virtual server on port 9987
    $ts3_VirtualServer = TeamSpeak3::factory("serverquery://USERNAME:[email protected]:10011/?server_port=9987");
    
    // grab current channel ID
    $current_cid = $ts3->whoamiGet("cid");
    
    // query the client list and filter by cid
    $ts3->clientList(array("cid" => 28))
    
    // spit out client nicknames
    foreach($clients as $clid => $client)
    {
      echo $client . "\n";
    }  
    
    ?>
    From your code, $clients does not exist (was not assigned) before it was used (accessed).

    Recommend:
    PHP Code:
    // ...

    // query the client list and filter by cid
    // $ts3->clientList(array("cid" => 28)) // Change to:
    $clients $ts3->clientList(array("cid" => 28))

    // spit out client nicknames
    foreach($clients as $clid => $client)
    // ... 
    Assuming this is the most likely case as you're getting 500 server error.
    Last edited by Ronin Design; April 21st, 2017 at 11:15 AM. Reason: Combining additional answer to single post.

  7. #1402
    Join Date
    March 2011
    Location
    Russia
    Posts
    24
    PHP Code:
    $ignorecid 145385125114156;
    foreach(
    $tsAdmin->channelList() as $channels) {
    echo 
    $channels;

    How to ignore cid $ignorecid in channelList, not show channel with id ($ignorecid)?

  8. #1403
    Join Date
    April 2014
    Location
    Seattle, WA, USA
    Posts
    141
    Quote Originally Posted by qeekus View Post
    PHP Code:
    $ignorecid 145385125114156;
    foreach(
    $tsAdmin->channelList() as $channels) {
    echo 
    $channels;

    How to ignore cid $ignorecid in channelList, not show channel with id ($ignorecid)?
    $tsAdmin->channelList() has a $filter argument, but it does not work with an array.

    An obvious or straight forward solution might be simply:

    PHP Code:
    $ignorecid = [145385125114156];
    foreach(
    $tsAdmin->channelList() as $channel) {
      if (!
    in_array($channel->cid$ignorecid)) {
        echo 
    $channel;
      }

    NB: This is nk runtime (n channels x k ignorecids), depending on how many channels and how often you're doing this, you may want to cache or limit how often you run this.
    Last edited by Ronin Design; May 9th, 2017 at 09:26 PM. Reason: Formatting.

  9. #1404
    Join Date
    March 2011
    Location
    Russia
    Posts
    24
    this solution show channel whis id $ignorecid

  10. #1405
    Join Date
    April 2014
    Location
    Seattle, WA, USA
    Posts
    141
    I've updated original post. My apologies you want converse set by:
    PHP Code:
    $ignorecid = [145385125114156];
    foreach(
    $tsAdmin->channelList() as $channel) {
      if (!
    in_array($channel->cid$ignorecid)) {
        echo 
    $channel;
      }


  11. #1406
    Join Date
    March 2011
    Location
    Russia
    Posts
    24
    Ronin Design thx u, nice work)

  12. #1407
    Join Date
    May 2017
    Posts
    1

    Nested Wrong?

    I've removed my nesting from the framework as I don't want the lines to show, however - this was a problem before as well.

    If I have a channel named Channel 1. Within that channel is sub 1, sub 2, sub 3.

    Channel 1
    . Sub 1
    . Sub 2
    . Sub 3

    If you are in Sub 1, all appears correct
    Channel 1
    . Sub 1
    . . User
    . Sub 2
    . Sub 3

    But if you are in Channel 1, it looks like this.
    Channel 1
    . Sub 1
    . Sub 2
    . Sub 3
    . User

    I would rather it look like this:

    Channel 1
    . User
    . Sub 1
    . Sub 2
    . Sub 3

    I think the fix might be in /Node/Abstract.php line 192 which is function getViewer, but I am unsure. Has anyone else experienced this nesting issue and know how to resolve it?
    Name:  Capture.PNG
Views: 2664
Size:  31.4 KB
    There's an example.. Those users are in Lounge of All Lounges, not Bastard Chat.

  13. #1408
    Join Date
    October 2003
    Location
    Germany
    Posts
    2,527
    Quote Originally Posted by mr.jeffpaul View Post
    I think the fix might be in /Node/Abstract.php line 192 which is function getViewer, but I am unsure. Has anyone else experienced this nesting issue and know how to resolve it?
    http://forum.teamspeak.com/attachmen...id=15609&stc=1
    There's an example.. Those users are in Lounge of All Lounges, not Bastard Chat.
    Try using the clients_before_channels option in your factory or call the setLoadClientlistFirst() method on any node object.

    PHP Code:
    $node->setLoadClientlistFirst(TRUE); 
    Basically, this setting is similar to the "Sort clients below channels" option in the TeamSpeak 3 Client design settings.

  14. #1409
    Join Date
    March 2011
    Location
    Russia
    Posts
    24
    Not working line break in user description?
    PHP Code:
    $output '
    This is line 1\r\n
    This is line 2\r\n
    This is line 3'
    ;
    $client->client_description $output

  15. #1410
    Join Date
    July 2017
    Posts
    7

    How to get Host Banner and Host Banner URL?

    Hey,

    which command I need to show my servers Banner and Banner URL? Like:

    Host Banner: [img]
    Host Banner URL: [link]

    If you go over with your mouse on [img] it will show the Image and if you click on [link] it will forward you to the Banner URL.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. PHP Framework
    By Multivit4min in forum Permission System
    Replies: 1
    Last Post: June 29th, 2015, 11:28 AM
  2. PHP Framework
    By phil998 in forum Server Support
    Replies: 0
    Last Post: February 25th, 2015, 06:27 PM
  3. TS3 PHP Framework Visualizations
    By Ronin Design in forum Tools / Web Based
    Replies: 2
    Last Post: February 22nd, 2015, 05:04 AM
  4. Extraction using the Framework
    By HarryMW in forum Tools / Web Based
    Replies: 1
    Last Post: August 3rd, 2012, 07:04 PM
  5. Teamspeak, PHP Framework?
    By mario2027 in forum General Questions
    Replies: 1
    Last Post: December 21st, 2010, 09:30 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •