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 5 of 5
  1. #1
    Join Date
    December 2014
    Posts
    6

    Question SDK Plugin: ts3Functions.setChannelVariableAsString() not working

    Hello,

    Currently i'm programming a simple plugin for teamspeak3 Clients on Linux.

    The Addon should change a channel name when someone moves to another channel.

    The Problem is, that the function doesn't return ERROR_ok, but the channel won't change the name.

    But i don't know why. There is no error. so it should change. But it doesn't

    Here's my code:

    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include <assert.h>
    
    #include <ts3_functions.h>
    #include <teamspeak/public_errors.h>
    
    
    #define _strcpy(dest, destSize, src) { strncpy(dest, src, destSize-1); (dest)[destSize-1] = '\0'; }
    
    #define PLUGIN_API_VERSION 20
    
    #define PATH_BUFSIZE 512
    #define COMMAND_BUFSIZE 128
    #define INFODATA_BUFSIZE 128
    #define SERVERINFO_BUFSIZE 256
    #define CHANNELINFO_BUFSIZE 512
    #define RETURNCODE_BUFSIZE 128
    
    static struct TS3Functions ts3Functions;
    
    
    static char* pluginID = NULL;
    
    
    /** Required **/
    
    const char* ts3plugin_name(){return "Channelrename";}
    
    const char* ts3plugin_version(){return "0.1";}
    
    int ts3plugin_apiVersion(){return PLUGIN_API_VERSION;}
    
    const char* ts3plugin_author(){return "binarycode";}
    
    const char* ts3plugin_description(){return "Change Channel Name!";}
    
    void ts3plugin_setFunctionPointers(const struct TS3Functions funcs) 
    {
    	ts3Functions = funcs;
    }
    
    int ts3plugin_init() 
    {
    
    	printf("PLUGIN %s init()\n", ts3plugin_name());
    
    	
    	return 0;
    }
    
    void ts3plugin_shutdown() 
    {
    	printf("PLUGIN: shutdown\n");
    	/* Free pluginID if we registered it */
    	if (pluginID) {
    		free(pluginID);
    		pluginID = NULL;
    	}
    }
    
    
    /* OPT */
    int ts3plugin_onTextMessageEvent(uint64 serverConnectionHandlerID, anyID targetMode, anyID toID, anyID fromID, const char* fromName, const char* fromUniqueIdentifier, const char* message, int ffIgnored) 
    {
    	printf("PLUGIN: onTextMessageEvent %llu %d %d %s %s %d\n", (long long unsigned int)serverConnectionHandlerID, targetMode, fromID, fromName, message, ffIgnored);
    	return 0;  /* 0 = handle normally, 1 = client will ignore the text message */
    }
    
    void ts3plugin_onClientMoveEvent(uint64 serverConnectionHandlerID, anyID clientID, uint64 oldChannelID, uint64 newChannelID, int visibility, const char* moveMessage) 
    {
    	char eventmsg[512];
    
    	printf("PLUGIN: ClientMoveEvent: %d, %d", (int)oldChannelID, (int)newChannelID);
    	sprintf(eventmsg, "ClientMoveEvent: User %d went from %d to %d", clientID, (int)oldChannelID, (int)newChannelID);
    
    	ts3Functions.requestSendChannelTextMsg(serverConnectionHandlerID, eventmsg, 6, NULL);
    
    
    	if(ts3Functions.setChannelVariableAsString(serverConnectionHandlerID, 6, CHANNEL_NAME, "Technik | Manuel Manz | Online") != ERROR_ok)
    	{
    		ts3Functions.requestSendChannelTextMsg(serverConnectionHandlerID, "error Setting Channel name", 6, NULL);
    	}
    
    	if(ts3Functions.flushChannelUpdates(serverConnectionHandlerID,6, NULL) != ERROR_ok)
    	{
    		ts3Functions.requestSendChannelTextMsg(serverConnectionHandlerID, "Error flushing channel updates", 6, NULL);
    	}
    
    	ts3Functions.requestSendChannelTextMsg(serverConnectionHandlerID, "END", 6, NULL);
    
    }
    Thanks,
    binarycode

  2. #2
    Join Date
    December 2014
    Posts
    6
    ok i've solved the problem just myself.

    it Was a right problem

    But that leads to the question, why the function is not returning some error?

  3. #3
    Join Date
    September 2012
    Posts
    6,079
    You're casting unsigned 64 bit unsigned integers to 32bit signed, which could lead to problems. Just use %llu instead of %d in the sprintf and remove the cast and you'll be fine.

    You can only send chat messages to the server, the current channel you're in or a specific client.

    As for the error thing you stumbled upon:
    Pretty much any function you call that starts with "request" is asynchronous, which means that the client will have to talk to the server to execute the function. You'll hear back about the success and error conditions in a callback (which one depends on the function), but most will trigger an onServerErrorEvent, which you can use to check for error conditions on the server side. The return value for these functions is just used if the client knows for sure that it cannot work (such as you're not connected to a server on the tab you're trying to run the function on), if there are no error conditions on the client side it'll return ERROR_ok and send the request on to the server, which will do permission checking among other things and tell the client if the request succeeded or not. The client will then call the callback to inform your code about the status (with an onServerErrorEvent) and, depending on the function, will provide the data requested in another callback (which as mentioned depends on the function that you called).
    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
    October 2012
    Location
    Germany
    Posts
    553
    Note also that for debugging/error logging it's more convenient to use the logMessage or print functions than sending text to the server.

  5. #5
    Join Date
    September 2012
    Posts
    6,079
    Quote Originally Posted by Philosound View Post
    Note also that for debugging/error logging it's more convenient to use the logMessage or print functions than sending text to the server.
    If you want to see it right in the client, printMessageTo*Tab works well too.
    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)

Similar Threads

  1. Problem with ts3Functions.getClientID()
    By Dione in forum Client Plugins / Lua Scripts
    Replies: 2
    Last Post: August 30th, 2014, 11:40 AM
  2. possibilities for setChannelVariableAsString / setChannelVariableAsInt
    By ZauberPole in forum Client Plugins / Lua Scripts
    Replies: 1
    Last Post: February 21st, 2014, 03:19 PM
  3. Replies: 1
    Last Post: March 14th, 2013, 10:06 AM
  4. ts3Functions.createIdentity - where the heck is it?
    By sea212 in forum Client Plugins / Lua Scripts
    Replies: 7
    Last Post: March 1st, 2010, 07:14 PM
  5. [Solved] ts3Functions.requestClientMove
    By tomix in forum Client Plugins / Lua Scripts
    Replies: 2
    Last Post: February 22nd, 2010, 10:31 AM

Posting Permissions

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