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

Results 1 to 7 of 7
  1. #1
    Join Date
    October 2014
    Posts
    60

    Help Please with my code

    I use the following code to switch channels in Teamspeak and it works flawlessly.

    Code:
    /*Start Channel Switch */
        if (NULL == hSimConnect) StartSimConnect();
            uint64 channelId = 0;
    		snprintf(FREQ, "%3.3f", GetCom1());
    	char *chpath[] = {"Air Traffic Control", FREQ, ""}; // Channel Structure
            anyID myId = 0;
            // Get the ID from the name
    		        if (ts3Functions.getChannelIDFromChannelNames(serverConnectionHandlerID, chpath, &channelId) == ERROR_ok && channelId > 0) {
                ts3Functions.getClientID(serverConnectionHandlerID, &myId);
                if (myId == clientID)
                    {
                    uint64 uiMyChannel = 0;
    			ts3Functions.getChannelOfClient(serverConnectionHandlerID, myId, &uiMyChannel);
                    if (uiMyChannel != channelId) ts3Functions.requestClientMove(serverConnectionHandlerID, myId, channelId, "", NULL);
                    }
            
            }
            /* End Channel Switch */
    But.....
    I would like to add text after the frequency which I have pulled from my program.

    For instance at the moment if a channel is named "123.450" and FREQ = 123.450 I will move channels.

    But if my channel is named "123.450 ATC Tower" I will not move.

    I'm sure this is simple but I've tried everything I can think of and can't find the solution.

    All help is appreciated.

  2. #2
    Join Date
    September 2012
    Posts
    6,079
    Quote Originally Posted by ATC_ROO View Post
    I'm sure this is simple but I've tried everything I can think of and can't find the solution.
    You're right it's simple and you've everything you need right there already:

    Quote Originally Posted by ATC_ROO View Post
    Code:
    snprintf(FREQ, "%3.3f", GetCom1());
    char *chpath[] = {"Air Traffic Control", FREQ, ""}; // Channel Structure
    All it needs is a change in the first line of the code I quoted above.
    When sending PMs please make sure to include a reference link to the thread in question in the body of your message.

  3. #3
    Join Date
    October 2014
    Posts
    60
    Quote Originally Posted by Chris View Post
    You're right it's simple and you've everything you need right there already:



    All it needs is a change in the first line of the code I quoted above.
    Thank you for the reply Chris.
    Below is some of what I have tried and normally get a buffer error.

    Code:
    snprintf(FREQ, """%3.3f", GetCom1());
    snprintf(FREQ, "%3.3f""", GetCom1());
    snprintf(FREQ, "%3.3f", GetCom1(),"");
    snprintf(FREQ, "%3.3f","", GetCom1());
    snprintf(FREQ, "\"""3.3f\", GetCom1());

  4. #4
    Join Date
    May 2006
    Location
    Europe/Czech Rep.
    Posts
    1,616
    Just in fantasy now I'm sprintf:
    you told me you want me to return 3.3 float, and on input you give me "123.450 ATC Tower"
    That means you want me to split that string and give you first float I stumbled on in it^.
    But if you want to reassemble to channel name again, and you use my return value, it will not be the channel name anymore now will it?

    So if you ask teamspeak3 to give you channelId of 123.450 you will
    - get error
    - get switched to a different channel that is called "123.450" instead "123.450 ATC Tower"

    perhaps I would focus also on
    variable chpath

    I'm guessing you are trying to get that FREQ for something outside that snippet you shared here ;-)

  5. #5
    Join Date
    October 2014
    Posts
    60
    Thank you for your reply Tomas, but I'm still feeling as stupid as... :?

    I understand if I were to use snprintf(FREQ, "%3.3f ATC Tower",GetCom1()); it would work.
    or using something like
    snprintf(FREQ, "%3.3f %3.3f",GetCom1(), GetCom2()); means I could name a channel with 2 different variables which also works.

    But I don't get how I can include the 2nd variable when I don't know what it will be?

    snprintf(FREQ, "%3.3f %s",GetCom1(), WHAT WOULD I PUT HERE?);

    The idea is anybody could potentially name a channel anything as long as FREQ is first in the channel name.
    ie 123.450 ATC Tower or 123.450 Ground or 123.450 Approach etc etc.

  6. #6
    Join Date
    September 2012
    Posts
    6,079
    Well you'd need to know how they would want to name the channel (that is the user defined part of the channel name). In case you do know the user supplied part of the channel name it would be as simple as changing the snprintf to
    Code:
    snprintf("%3.3f %s", GetCom1(), getUserSuppliedChannelName());
    I had assumed you'd create the channel in your code in the first place, be it in the plugin or in query from the server part.

    If you don't then one way that quickly comes to mind without thinking about it, would be to get the list of channels below the desired main channel (which you have hardcoded to be "Air Traffic Control") and loop through all the channels finding the one that starts with your desired frequency. Of course each frequency would have to be unique and only used once, as you'd probably only ever use the first subchannel with the desired frequency.
    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
    Quote Originally Posted by Chris View Post
    Well you'd need to know how they would want to name the channel (that is the user defined part of the channel name). In case you do know the user supplied part of the channel name it would be as simple as changing the snprintf to
    Code:
    snprintf("%3.3f %s", GetCom1(), getUserSuppliedChannelName());
    Afraid not.
    I have no way of knowing what the channel name would be due to the amount of different variations that it could be.
    For example think of the number of airports there are around the world.
    Then each airport will have at least three different divisions, Approach, Tower and Ground for instance.

    Also if the plugin was used by a non english speaking group the name would then be in a different Language.

    I was hoping that my code could look at the channel name and if FREQ was anywhere within that channel name then it could switch.

    Quote Originally Posted by Chris View Post
    one way that quickly comes to mind without thinking about it, would be to get the list of channels below the desired main channel (which you have hardcoded to be "Air Traffic Control") and loop through all the channels finding the one that starts with your desired frequency.
    That sounds like exactly what I'd like to do but I have no idea how to do it?

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. BB-Code und TS3
    By XTheOtherSideX in forum Off Topic
    Replies: 1
    Last Post: October 8th, 2012, 01:35 PM
  2. Code for something
    By wyd3x in forum Server Support
    Replies: 3
    Last Post: October 5th, 2012, 01:29 PM
  3. BB Code
    By rebz01 in forum General Questions
    Replies: 2
    Last Post: November 17th, 2010, 03:02 AM
  4. [Bug] BB-Code
    By x!sign.dll in forum General Questions
    Replies: 3
    Last Post: December 25th, 2009, 08:04 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
  •