• If you need help or want to discuss things, you now can also join us on our Discord Server!
  • A first preview of the unlimited version of SinusBot can be found in the Upcoming Changes thread. A version for Windows will follow, but we don't have a release date, yet.

Feature get/set VirtualServerProperties

Status
Not open for further replies.

VJean

Member
Hello.
In client plugin SDK exist code for get/set information about Server (VirtualServerProperties/getServerVariableAs***):
/pluginsdk/include/teamspeak/public_definitions.h
Code:
enum VirtualServerProperties {
   VIRTUALSERVER_UNIQUE_IDENTIFIER = 0,  //available when connected, can be used to identify this particular server installation
   VIRTUALSERVER_NAME,  //available and always up-to-date when connected
   VIRTUALSERVER_WELCOMEMESSAGE,  //available when connected,  (=> requestServerVariables)
   VIRTUALSERVER_PLATFORM,  //available when connected
   VIRTUALSERVER_VERSION,  //available when connected
   VIRTUALSERVER_MAXCLIENTS,  //only available on request (=> requestServerVariables), stores the maximum number of clients that may currently join the server
   VIRTUALSERVER_PASSWORD,  //not available to clients, the server password
   VIRTUALSERVER_CLIENTS_ONLINE,  //only available on request (=> requestServerVariables),
   VIRTUALSERVER_CHANNELS_ONLINE,  //only available on request (=> requestServerVariables),
   VIRTUALSERVER_CREATED,  //available when connected, stores the time when the server was created
   VIRTUALSERVER_UPTIME,  //only available on request (=> requestServerVariables), the time since the server was started
   VIRTUALSERVER_CODEC_ENCRYPTION_MODE,  //available and always up-to-date when connected
   VIRTUALSERVER_ENDMARKER,
};


/pluginsdk/include/teamspeak/public_rare_definitions.h
Code:
enum VirtualServerPropertiesRare {
   /* ...  */
}


/pluginsdk/include/ts3_functions.h
Code:
    /* Server info */
    unsigned int (*getServerConnectionHandlerList)(uint64** result);
    unsigned int (*getServerVariableAsInt)(uint64 serverConnectionHandlerID, size_t flag, int* result);
    unsigned int (*getServerVariableAsUInt64)(uint64 serverConnectionHandlerID, size_t flag, uint64* result);
    unsigned int (*getServerVariableAsString)(uint64 serverConnectionHandlerID, size_t flag, char** result);
    unsigned int (*requestServerVariables)(uint64 serverConnectionHandlerID);


/pluginsdk/src/plugin.c
Code:
        case CMD_SERVERINFO: {  /* /test serverinfo */
            /* Query host, port and server password of current server tab.
             * The password parameter can be NULL if the plugin does not want to receive the server password.
             * Note: Server password is only available if the user has actually used it when connecting. If a user has
             * connected with the permission to ignore passwords (b_virtualserver_join_ignore_password) and the password,
             * was not entered, it will not be available.
             * getServerConnectInfo returns 0 on success, 1 on error or if current server tab is disconnected. */
            char host[SERVERINFO_BUFSIZE];
            /*char password[SERVERINFO_BUFSIZE];*/
            char* password = NULL;  /* Don't receive server password */
            unsigned short port;
            if(!ts3Functions.getServerConnectInfo(serverConnectionHandlerID, host, &port, password, SERVERINFO_BUFSIZE)) {
                char msg[SERVERINFO_BUFSIZE];
                snprintf(msg, sizeof(msg), "Server Connect Info: %s:%d", host, port);
                ts3Functions.printMessageToCurrentTab(msg);
            } else {
                ts3Functions.printMessageToCurrentTab("No server connect info available.");
            }
            break;
        }
Code:
        /* Print virtual server name */
        if((error = ts3Functions.getServerVariableAsString(serverConnectionHandlerID, VIRTUALSERVER_NAME, &s)) != ERROR_ok) {
            if(error != ERROR_not_connected) {  /* Don't spam error in this case (failed to connect) */
                ts3Functions.logMessage("Error querying server name", LogLevel_ERROR, "Plugin", serverConnectionHandlerID);
            }
            return;
        }
        printf("PLUGIN: Server name: %s\n", s);
        ts3Functions.freeMemory(s);

Has who get this information in sinus javascript?
 
Status
Not open for further replies.
Top