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
    August 2014
    Posts
    27

    CLIENT_TOTALCONNECTIONS always 0?

    Hi! Hopefully I got the right place since I'm new here.

    Anyway, I've stumbled upon a strange problem while trying to make a plugin that part of its job gets the total connections of a client.
    Here's a little snippet of my code.
    Code:
    int connections;
    ts3Functions.requestClientVariables(serverConnectionHandlerID, clientID, "2");
    ts3Functions.getClientVariableAsInt(serverConnectionHandlerID, clientID, CLIENT_TOTALCONNECTIONS, &connections);
    Since it's written that CLIENT_TOTALCONNECTIONS needs to be requested with .requestClientVariables, I obviously do that first. Then I try to acquire it as an int (because it makes sense) and store it in "connections". Here's the problem though: for some reason, the value of CLIENT_TOTALCONNECTIONS is always 0. Every single time. I've tried storing it as uint64, not request ClientVariables first, checking if the get method actually stores the value properly (it does) and some other things I can't remember anymore. I can't see any obvious reason why it turns up as 0. .requestClientVariables is successful, because onUpdateClientEvent is being called (I've made it print lines into the console, so I can see quite a lot). Unless... it actually isn't successful? After the onUpdateClientEvent, there should be latest data, but apparently there isn't. I can see total connections on the right side though with the modified .tpl file, so getting info from the server is not a problem.
    What am I missing?

  2. #2
    Join Date
    November 2013
    Posts
    57
    First: pretty much all functions return a value which indicates if the call was successful or not. you could have done this to check if the "request" was actually executed. from the documentation:
    Returns ERROR_ok on success, otherwise an error code as defined in public_errors.h
    second: it's a request to the server which will probably have a delay, so the information you want is not there yet, if you try to get the requested data instantly.
    After requesting the information, the following event is called. This event is also called everytime a client variable has beenchanged:
    void ts3plugin_onUpdateClientEvent(uint64 serverConnectionHandlerID, anyID clientID, anyID invokerID, const char* invokerName, const char* invokerUniqueIdentifier)
    you have to wait for this event before you call "getClientVariableAsInt"

  3. #3
    Join Date
    September 2012
    Posts
    6,079
    Don't forget that you will actually get quite a few onUpdateClientEvent calls depending on the server and subscribed channels. You'll have to make sure you're receiving the event for the client you're interested in before getting the information for said client.
    When sending PMs please make sure to include a reference link to the thread in question in the body of your message.

  4. #4
    Join Date
    August 2014
    Posts
    27
    Indeed. I made it print out specific lines for that occasion, so I knew what it was. However, making the script wait a little bit after requesting data from the server did the trick. Funny thing is, I did actually wonder if the time delay might be the cause, but when I tried it, I was already in the middle of trying other properties and as it happened, I tested waiting with CLIENT_IDLE_TIME, which is only for internal use, but at that time I did not know that.
    Anyways, thanks for pointing that out! If I may ask as a side question, why is client idle time only for internal use? Or should I make a separate topic about that? I could really use that property too without having to use server query, but I guess there is some logic behind that?

  5. #5
    Join Date
    September 2012
    Posts
    6,079
    There is and it most likely won't change. You can still guesstimate idle time though.
    When sending PMs please make sure to include a reference link to the thread in question in the body of your message.

  6. #6
    Join Date
    August 2014
    Posts
    27
    What do you mean by "guesstimate"? And where should I ask about the logic behind "internal use only", because I'm curious.

  7. #7
    Join Date
    September 2012
    Posts
    6,079
    It's internal use only, because developers decided it would be unwise to expose that information that easily.

    And yes, that's all the information you'll get on here. Don't make me lock the topic.
    When sending PMs please make sure to include a reference link to the thread in question in the body of your message.

Thread Information

Users Browsing this Thread

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

Posting Permissions

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