Forum

Results 1 to 14 of 14
  1. #1
    Join Date
    December 2009
    Location
    Taiwan
    Posts
    313

    Solved [LUA] Unable to set self description

    I was trying to write a script on changing oneself's description, however, it is not working as intended.

    Here's the following code that I've used.

    Code:
    	-- Reset Self Description
    	local error = ts3.setClientSelfVariableAsString(serverConnectionHandlerID, 45, "")
    	if error ~= ts3errors.ERROR_ok then
    		print("Error resetting own description: " .. error)
    		return
    	end
    	ts3.printMessageToCurrentTab("== Note: Emptied self description ==")
    Note: According to the flags, description is flag code 45

    This applies when I tried to get one's own description with getClientSelfVariableAsString, it returns empty.

    However, the other similar command "getClientVariableAsString" does properly retrieve the descriptiong

    so ... yeah.

  2. #2
    Join Date
    October 2012
    Location
    Germany
    Posts
    553
    After setting a (number of) client variable(s), you need to
    ts3.flushClientSelfUpdates(serverConnectionHandler ID) > error

    and expect the value to be changed not earlier than by handling
    onClientSelfVariableUpdateEvent

    Remembered that?
    Last edited by Philosound; March 8th, 2013 at 04:52 PM.

  3. #3
    Join Date
    December 2009
    Location
    Taiwan
    Posts
    313
    Quote Originally Posted by Philosound View Post
    After setting a (number of) client variable(s), you need to
    ts3.flushClientSelfUpdates(serverConnectionHandler ID) > error

    and expect the value to be changed not earlier than by handling
    onClientSelfVariableUpdateEvent

    Remembered that?
    Actually, I was expecting flushClientSelfUpdates means to "revert all changes", because that's the idea I got from "flush", but, alright.

    Code:
    function setOwnDesc(serverConnectionHandelerID)
    	local error = ts3.setClientSelfVariableAsString(serverConnectionHandelerID, 45, "Description Update Test")
    	if error ~= ts3errors.ERROR_ok then
    		print("Error setting self variable: " .. error)
    		return
    	end
    
    	local error = ts3.flushClientSelfUpdates(serverConnectionHandlerID)
    	if error ~= ts3errors.ERROR_ok then
    		print("Error flushing client self update: " .. error)
    		return
    	end
    end
    by executing /lua run setOwnDesc, nothing happend, however, on the console, you can clearly see the following error messages:

    LUA_PLUGIN: process command 'run setOwnDesc'
    Lua: Error setting client self variable: 1538
    Error setting self variable: 1538
    So, no, it's not working.

    Then I tried to flush all updates first prior to change it

    Code:
    function setOwnDesc(serverConnectionHandelerID)
    
    	local error = ts3.flushClientSelfUpdates(serverConnectionHandlerID)
    	if error ~= ts3errors.ERROR_ok then
    		print("Error flushing client self update: " .. error)
    		return
    	end
    
    	local error = ts3.setClientSelfVariableAsString(serverConnectionHandelerID, 45, "Description Update Test")
    	if error ~= ts3errors.ERROR_ok then
    		print("Error setting self variable: " .. error)
    		return
    	end
    
    end
    Again, error expected

    LUA_PLUGIN: process command 'run setOwnDesc'
    Lua: Error flushing client self variables: 3
    Error flushing client self update: 3
    Even flushing is not functioning as is =\

  4. #4
    Join Date
    October 2012
    Location
    Germany
    Posts
    553
    Usually, you'd flush after setting the variable.
    The point of this mechanism that all these changes can be sent together to the server, instead of necessarily sending each one alone.
    However, the error obviously happens before/independently of that.

    One might get to the bottom of this by getting the error in a more convenient format for the human eye:
    local errorMsg = ts3.getErrorMessage(error)
    print("Error setting self variable: " .. error ..":"..errorMsg)

  5. #5
    Join Date
    October 2012
    Location
    Germany
    Posts
    553
    Note that you have some writing typo with serverConnectionHand(e)lerID at some places.
    Imo you'd probably end up with sth. like

    Code:
    local function printError(errorCode, strg)
      local errorMessage, errorNr = ts3.getErrorMessage(errorCode)
      if (errorNr ~= ts3errors.ERROR_ok) then
        print("error Code: " .. errorCode .. ", Comment: " .. (strg or "none"))
      else
        print("error Code: " .. errorCode .. ", msg: " .. errorMessage .. ", Comment: " .. (strg or "none"))
      end
    end
    
    -- must be properly inserted
    function onClientSelfVariableUpdateEvent(serverConnectionHandlerID, flag, oldValue, newValue)
      print("Lua: onClientSelfVariableUpdateEvent: " .. serverConnectionHandlerID .. " " .. flag .. " " .. oldValue .. " " .. newValue)
    end
    
    function setOwnDesc(serverConnectionHandlerID)
      serverConnectionHandlerID = tonumber(serverConnectionHandlerID)
    	
      if not serverConnectionHandlerID then
        print("no valid serverConnectionHandlerID delivered, getting current.")
        serverConnectionHandlerID = ts3.getCurrentServerConnectionHandlerID()
      end
    	
      local status, errorCode = ts3.getConnectionStatus(serverConnectionHandlerID)
      if errorCode ~= ts3errors.ERROR_ok then
        printError(errorCode,"(setOwnDesc)(getConnectionStatus)")
        return
      end
      if status ~= ts3defs.ConnectStatus.STATUS_CONNECTION_ESTABLISHED
        return
      end
    	
      errorCode = ts3.setClientSelfVariableAsString(serverConnectionHandlerID, 45, "Description Update Test")
      if errorCode ~= ts3errors.ERROR_ok then
      printError(errorCode,"(setOwnDesc)(setClientSelfVariableAsString): ")
        return
      end
    
      errorCode = ts3.flushClientSelfUpdates(serverConnectionHandlerID)
      if errorCode ~= ts3errors.ERROR_ok then
        printError(errorCode,"(setOwnDesc)(flushClientSelfUpdates): ")
        return
      end
    end
    Untested, though.

  6. #6
    Join Date
    December 2009
    Location
    Taiwan
    Posts
    313
    Just did with your code, fixing some small syntax errors

    when executed:

    LUA_PLUGIN: process command 'run setOwnDesc'
    Lua: Error flushing client self variables: 1538
    Error Code:1538, msg: invalid parameter, comment: (setOwnDesc)(setClientSelfVariableAsString):
    As stated on the top of this thread, this flag is NOT accepting string, or at least something that we do not know.

    because using getClientSelfVariableAsString on flag 45, we get empty string, however, when using getClientVariableAsString, it is returning proper description.

    so, yeah =\

  7. #7
    Join Date
    October 2012
    Location
    Germany
    Posts
    553
    Hm, well it'll work once it's fixed
    Changing the name instead of the description works fine with the same code, therefor, yes indeed, there's something wrong with that.

    However, the client log shows more specifically:
    09.03.2013 12:27:53 ClientLib Warning Setting invalid flag in ts3client_setClientSelfVariableAsString

    indicating that there may be a bug with the flag parameter instead of the string.
    Last edited by Philosound; March 9th, 2013 at 12:29 PM.

  8. #8
    Join Date
    December 2009
    Location
    Taiwan
    Posts
    313
    just wanted to demonstrate

    Technically ... these two should reflect same values for both, as I'm looking up myClientID , and used that to query getClientVariableAsString, while the other one, as the name suggest, is to look up own variable, however, they turns out to be totally different.

    Code:
    function getSelfVar(serverConnectionHandlerID)
    
    	-- Get Self ID
    	local myClientID, error = ts3.getClientID(serverConnectionHandlerID)
    	if error ~= ts3errors.ERROR_ok then
    		print("Error getting own client ID: " .. error)
    		return
    	end
    	if myClientID == 0 then
    		ts3.printMessageToCurrentTab("Not connected")
    		return
    	end
    
    	for i=0,59 do
    		local clientVar, error = ts3.getClientVariableAsString(serverConnectionHandlerID, myClientID, i)
    		if error ~= ts3errors.ERROR_ok then
    			print("Error getting client variable: " .. error)
    			return
    		end
    
    		local selfVar, error = ts3.getClientSelfVariableAsString(serverConnectionHandlerID, i)
    		if error ~= ts3errors.ERROR_ok then
    			print("Error getting self variable: " .. error)
    			return
    		end
    		ts3.printMessageToCurrentTab("clientVar[" .. i .. "] = " .. clientVar .. " | selfVar[" .. i .. "] = " .. selfVar .. "")
    	end
    
    end

  9. #9
    Join Date
    June 2008
    Location
    -
    Posts
    252
    Yep, this does not look like it should.
    Thank you for reporting this

    Added to bugtracker

  10. #10
    Join Date
    December 2009
    Location
    Taiwan
    Posts
    313
    while you are at it, want to know if it's also possible to assign groups to others via scripting?

    PS: when trying to print index out of bound will crash the entire TS3 client
    Last edited by willy_sunny; March 14th, 2013 at 02:19 AM.

  11. #11
    Join Date
    June 2008
    Location
    -
    Posts
    252
    We are aware about that problem and it has been reported already.
    But thank you for your help.

    Ps: It's not possible to assign groups via lua right now.

  12. #12
    Join Date
    September 2012
    Posts
    6,080
    As for the differences between getClientVariable and getClientSelfVariable you observed: This won't be fixed, some variables are not available through getClientSelfVariable.

    Quote Originally Posted by willy_sunny View Post
    PS: when trying to print index out of bound will crash the entire TS3 client
    This is an assertion and intended behavior to show you that you did something wrong. You should prevent accessing indexes out of bound in your code.
    Last edited by Chris; March 15th, 2013 at 11:30 AM.

  13. #13
    Join Date
    October 2012
    Location
    Germany
    Posts
    553
    local client mute yes, as in not available for other clients, but client description the other way round? Wouldn't have guessed that.

  14. #14
    Join Date
    September 2012
    Posts
    6,080
    The next client release will include a new LUA function to set the client description:
    ts3.requestClientEditDescription(serverConnectionH andlerID, clientID, clientDescription)

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [Not possible] Load webpage in description / use Html in description
    By Squelch87 in forum Server Support
    Replies: 2
    Last Post: May 6th, 2013, 01:01 PM
  2. Description
    By whiti in forum Server Support
    Replies: 1
    Last Post: January 23rd, 2013, 11:01 AM
  3. Channel Admins are unable to change Channel Description
    By sinister_evil in forum Permission System
    Replies: 4
    Last Post: January 17th, 2012, 03:13 PM
  4. [Resolved] Unable to use mysql data base... unable to create tables
    By 3dhomejoe in forum Windows
    Replies: 4
    Last Post: October 3rd, 2011, 05:28 PM
  5. Mp3 In description?
    By Chief in forum General Questions
    Replies: 1
    Last Post: July 9th, 2010, 09:20 AM

Tags for this Thread

Posting Permissions

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