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 1 of 2 12 LastLast
Results 1 to 15 of 27

Thread: Move to Channel

  1. #1
    Join Date
    October 2014
    Posts
    60

    Move to Channel

    I'm trying to edit a TS3 Plugin with very little programming knowledge, as I can't find a plugin to do what I want.

    I'm hoping somebody can help me out with a correct piece of code similar to below.

    if (something == channelname)
    {
    (move client to that channel);
    }


    Any help is appreciated.

    Roo

  2. #2
    Join Date
    December 2009
    Location
    Germany
    Posts
    2,360
    Do you need something like this?
    http://forum.teamspeak.com/showthrea...o-move-clients

    If not, I don't understand you...

  3. #3
    Join Date
    October 2014
    Posts
    60
    Thanks for the reply Stefan.
    I'm looking to create a plugin that will interface with a Flight Sim.

    I am already working on the Flight Sim side of the plugin to get the frequencies of my aircraft radio.

    I would then like to autoswitch to a certain teamspeak channel when I select a certain frequency in my flight simulator.

    So I'm looking for the teamspeak part of my plugin code (C++).

    Example
    if (frequency == channelname)
    {
    (move client to that channel);
    }

  4. #4
    Join Date
    September 2012
    Posts
    6,079
    You can switch to a different channel by calling requestClientMove, get a list of all channels using getChannelList and the name of a particular channel using getChannelVariableAsString
    When sending PMs please make sure to include a reference link to the thread in question in the body of your message.

  5. #5
    Join Date
    October 2014
    Posts
    60
    I'm still unable to move my client.
    I am trying to edit the SDK example to do this as it seems to have all the functions in place already.

    So far I have tried a few different things including editing uint64 channelID = (uint64)atoi(param1);
    to read uint64 channelID = (118.75); and renamed a channel on the server as 118.75 In the hope that it would auto switch.
    I was thinking eventually I would define it as FREQ so uint64 channelID = (FREQ); and could then name the data I pull from the Flight Sim as FREQ etc etc.

    Lots of help REALLY APPRECIATED this way as I am thick as... when it comes to code.
    The only reason I am doing this is because there isn't anything about that does it for TS3 currently.

    If I could just get my client to move to a channel that would be a start.

  6. #6
    Join Date
    September 2012
    Posts
    6,079
    Code:
    		uint64 targetChannelId = 23;
    		anyID myId = 0;
    		ts3Functions.getClientID(serverConnectionHandlerID, &myId);
    		if (myId > 0)
    			ts3Functions.requestClientMove(serverConnectionHandlerID, myId, targetChannelId, "", NULL);
    		else
    			ts3Functions.printMessageToCurrentTab("Not connected (got no client ID)");
    Nothing to it
    When sending PMs please make sure to include a reference link to the thread in question in the body of your message.

  7. #7
    Join Date
    October 2014
    Posts
    60
    Thank you I will try this later.
    Is there a way to specify a channel name instead of a Channel ID?

  8. #8
    Join Date
    December 2009
    Location
    Germany
    Posts
    2,360
    Quote Originally Posted by ATC_ROO View Post
    Thank you I will try this later.
    Is there a way to specify a channel name instead of a Channel ID?
    No, but you can request a channel list, search for the right channel name to have the channel id.

  9. #9
    Join Date
    September 2012
    Posts
    6,079
    Quote Originally Posted by Stefan1200 View Post
    No, but you can request a channel list, search for the right channel name to have the channel id.
    Actually, that's not true, you can get the channel ID from a channel name using getChannelIDFromChannelNames

    Code:
    		uint64 channelId = 0;
    		char *chpath[] = {"Gaming", "Battlefield 4", "USMC" }; // Channel Structure
    		// Get the ID from the name
    		if (ts3Functions.getChannelIDFromChannelNames(serverConnectionHandlerID, chpath, &channelId) == ERROR_ok && channelId > 0) {
    			anyID myId = 0;
    			ts3Functions.getClientID(serverConnectionHandlerID, &myId);
    			if (myId > 0)
    				ts3Functions.requestClientMove(serverConnectionHandlerID, myId, channelId, "", NULL);
    			else
    				ts3Functions.printMessageToCurrentTab("We don't have a client ID");
    		} else
    			ts3Functions.printMessageToCurrentTab("Error getting the channel ID");
    Last edited by Chris; January 22nd, 2015 at 10:56 AM.
    When sending PMs please make sure to include a reference link to the thread in question in the body of your message.

  10. #10
    Join Date
    October 2014
    Posts
    60
    I'm obviously missing something.

    Default Plugin example but edited as below.

    Code:
    switch(cmd) {
    		case CMD_NONE:
    			return 1;  /* Command not handled by plugin */
    		case CMD_JOIN:  /* /test join <channelID> [optionalCannelPassword] */
    			if(param1) {
    				uint64 channelId = 0;
    				char* password = param2 ? param2 : "";
    				char returnCode[RETURNCODE_BUFSIZE];
    				anyID myId = 0;
    				char *chpath[] = {"118.75", "USMC" }; // Channel Structure
    		
    				/* Get own clientID */
    				if(ts3Functions.getClientID(serverConnectionHandlerID, &myId) != ERROR_ok) {
    					ts3Functions.logMessage("Error querying client ID", LogLevel_ERROR, "Plugin", serverConnectionHandlerID);
    					break;
    				}
    
    				/* Create return code for requestClientMove function call. If creation fails, returnCode will be NULL, which can be
    				 * passed into the client functions meaning no return code is used.
    				 * Note: To use return codes, the plugin needs to register a plugin ID using ts3plugin_registerPluginID */
    				ts3Functions.createReturnCode(pluginID, returnCode, RETURNCODE_BUFSIZE);
    
    				/* In a real world plugin, the returnCode should be remembered (e.g. in a dynamic STL vector, if it's a C++ plugin).
    				 * onServerErrorEvent can then check the received returnCode, compare with the remembered ones and thus identify
    				 * which function call has triggered the event and react accordingly. */
    
    				/* Request joining specified channel using above created return code */
    				
    		// Get the ID from the name
    		if (ts3Functions.getChannelIDFromChannelNames(serverConnectionHandlerID, chpath, &channelId) == ERROR_ok && channelId > 0) {
    			
    			ts3Functions.getClientID(serverConnectionHandlerID, &myId);
    			if (myId > 0)
    				ts3Functions.requestClientMove(serverConnectionHandlerID, myId, channelId, "", NULL);
    			else
    				ts3Functions.printMessageToCurrentTab("We don't have a client ID");
    		} else
    			ts3Functions.printMessageToCurrentTab("Error getting the channel ID");
    
    				
    			} 
    			break;
    Results in no channel movement.
    would this code switch me automatically upon entering the server?

    Name:  ts3.png
Views: 1861
Size:  138.9 KB

  11. #11
    Join Date
    August 2013
    Location
    Germany
    Posts
    541
    Lol, its teamspeak, u have to work with events for that. Search the sdk doc for onConnectStatuschangedEvent or something like it. Will add an example lua code when im back on my pc

  12. #12
    Join Date
    September 2012
    Posts
    6,079
    1) you query your own client ID twice in the same code path, which is unnecessary as you've already got it.
    2) Your Channel Structure in the code is wrong. There is no Top Level Channel 118.75, nor does the existing channel 118.75 have a subchannel called USMC.
    3) Your code indentation is bad...

    To answer your question:
    Quote Originally Posted by ATC_ROO View Post
    would this code switch me automatically upon entering the server?
    No it won't, since you seem to have put it inside the processCommand function which is only called when you enter a command starting with "/<Your command keyword>"
    When sending PMs please make sure to include a reference link to the thread in question in the body of your message.

  13. #13
    Join Date
    October 2014
    Posts
    60
    LOL I did warn you.
    Quote Originally Posted by ATC_ROO View Post
    Lots of help REALLY APPRECIATED this way as I am thick as... when it comes to code.
    I'll edit it now and see what happens.

  14. #14
    Join Date
    October 2014
    Posts
    60
    OK thanks for all the help so far it is appreciated.

    So far I have been able to switch to a channel ID upon entering a server.
    But I haven't been able to get a channel name and switch to channel name.

    The 2 codes I am using are as below.

    Move to Channel Name...
    Code:
    void ts3plugin_onConnectStatusChangeEvent(uint64 serverConnectionHandlerID, int newStatus, unsigned int errorNumber) {
        /* Some example code following to show how to use the information query functions. */
    	/*TEST INFO */
    		uint64 channelId = 0;
    		char *chpath[] = {"Air Traffic Control", "Tower -" }; // Channel Structure
    		// Get the ID from the name
    		if (ts3Functions.getChannelIDFromChannelNames(serverConnectionHandlerID, chpath, &channelId) == ERROR_ok && channelId > 0) {
    			anyID myId = 0;
    			ts3Functions.getClientID(serverConnectionHandlerID, &myId);
    			if (myId > 0)
    				ts3Functions.requestClientMove(serverConnectionHandlerID, myId, channelId, "", NULL);
    			else
    				ts3Functions.printMessageToCurrentTab("We don't have a client ID");
    		} else
    			ts3Functions.printMessageToCurrentTab("Error getting the channel ID");
    		/* TEST INFO END */
    and Move to channel ID...
    Code:
    void ts3plugin_onConnectStatusChangeEvent(uint64 serverConnectionHandlerID, int newStatus, unsigned int errorNumber) {
        /* Some example code following to show how to use the information query functions. */
    	/*TEST INFO */
    		uint64 targetChannelId = 23;
    		anyID myId = 0;
    		ts3Functions.getClientID(serverConnectionHandlerID, &myId);
    		if (myId > 0)
    			ts3Functions.requestClientMove(serverConnectionHandlerID, myId, targetChannelId, "", NULL);
    		else
    			ts3Functions.printMessageToCurrentTab("Not connected (got no client ID)");
    		/* TEST INFO END */
    Would it also be possible to check a users channel periodically ie every second and switch them if they have moved?

  15. #15
    Join Date
    October 2012
    Location
    Germany
    Posts
    553
    An Addon Dev's strength flows from the Event System. But beware of the dark side. Timers, Polling, Blocking; the dark side of the Force are they. Easily they flow, quick to join you in a fight. If once you start down the dark path, forever will it dominate your destiny, consume you it will, as it would Teamspeak's stability.
    When you are calm, at peace, passive observing the
    onClientMoved events, you'll see the observer pattern binds this galaxy together.

    Debug outputs you shall use to isolate your problem. Like printing out the channelID you receive and compare that with the expected value to see if it's that function not delivering what you'd expect. Quite soon we'd have a more specific problem report, e.g. the channelNameArray:
    Array defining the position of the channel: "grandparent", "parent", "channel", "". The array is terminated by an empty string.
    ...not being fulfilled entirely.

    While not related to the Channel Names problem, let's condense this
    enum ConnectStatus {
    STATUS_DISCONNECTED = 0,
    //There is no activity to the server, this is the default value

    STATUS_CONNECTING,
    //We are trying to connect, we haven't got a clientID yet, we
    //haven't been accepted by the server

    STATUS_CONNECTED,
    //The server has accepted us, we can talk and hear and we got a
    //clientID, but we don't have the channels and clients yet, we
    //can get server infos (welcome msg etc.)

    STATUS_CONNECTION_ESTABLISHING,
    //we are CONNECTED and we are visible

    STATUS_CONNECTION_ESTABLISHED,
    //we are CONNECTED and we have the client and channels available };
    into
    Code:
    if (newStatus != STATUS_CONNECTION_ESTABLISHED)
      return;
    shall we.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 7
    Last Post: July 23rd, 2014, 03:38 PM
  2. [suggestion]move user to own channel for channel admin
    By El_makong in forum Suggestions and Feedback
    Replies: 3
    Last Post: November 9th, 2013, 10:26 AM
  3. Replies: 4
    Last Post: June 18th, 2013, 06:37 PM
  4. Replies: 1
    Last Post: May 15th, 2013, 11:06 AM
  5. [Rejected] Move menu option for "Move client to own channel"
    By maggy in forum Suggestions and Feedback
    Replies: 1
    Last Post: March 23rd, 2013, 08:22 PM

Posting Permissions

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