Forum

Results 1 to 9 of 9
  1. #1
    Join Date
    October 2015
    Posts
    5

    Get Client IP in plugin

    Could you help me to make it in LUA that's pretty easyer and customizable?
    I need to printout CONNECTION_CLIENT_IP with using a LUA function, I'm Server Admin, so I have permission to get/view/read it.

  2. #2
    Join Date
    October 2015
    Posts
    5

    can't get and print CONNECTION_CLIENT_IP

    I'm going crazy during the last week, trying in LUA, and C, to get and printout CONNECTION_CLIENT_IP.

    In the LUA case I'm editing showClients in custom.lua after added Connection stuffs in ts3defs.lua without results.
    In the C case I'm editing plugin.c of test_plugin got from pluginsdk folder, editing the function that print CLIENT_NICKNAME in data info.

    In both cases I succesfully got and printed all CLIENTS/CHANNELS stuffs in various situations, but I'm unable to get and print CONNECTION_CLIENT_IP, I', reading and reading include files of pluginsdk, and searching on internet for solutions, but I'm lost, and I need a little help.

    Hope that anyone'll help me this time. (I also PMed some mod and some expert users, that already released plugins with that function, but I received no answer)
    Last edited by dante696; October 20th, 2015 at 03:28 PM. Reason: merged, same topic from same user

  3. #3
    Join Date
    October 2015
    Posts
    4
    Quote Originally Posted by aGFjaw View Post
    Could you help me to make it in LUA that's pretty easyer and customizable?
    I need to printout CONNECTION_CLIENT_IP with using a LUA function, I'm Server Admin, so I have permission to get/view/read it.
    hi
    before using the "CONNECTION_CLIENT_IP", you need to call:
    ts3functions.requestConnectionInfo(...);

    and try to using "CONNECTION_CLIENT_IP"

  4. #4
    Join Date
    October 2015
    Posts
    5
    Quote Originally Posted by hamzeh_ghanemi View Post
    hi
    before using the "CONNECTION_CLIENT_IP", you need to call:
    ts3functions.requestConnectionInfo(...);

    and try to using "CONNECTION_CLIENT_IP"
    Thanks a lot for the info.
    I'll explain you my errrors, you'll understand that I'm not so good in programming, because I always programmed in .net that's pretty easier, but I know basics so I'll understanding that.
    Well :



    For C, I tried :
    Code:
    case PLUGIN_CLIENT:
    			if(ts3Functions.requestConnectionInfo(serverConnectionHandlerID, (anyID)id, CONNECTION_CLIENT_IP, &name) != ERROR_ok) {
    				printf("Error getting client nickname\n");
    				return;
    			}
    			break;
    And teamspeak crashed immediatly when I enable plugin.



    For LUA, I tried :
    Code:
    require("ts3defs")
    require("ts3errors")
    require("ts3events")
    
    -- Run with "/lua run showIP"
    function showIP(serverConnectionHandlerID)
    	local clients, error = ts3.getClientList(serverConnectionHandlerID)
    	if error == ts3errors.ERROR_not_connected then
    		ts3.printMessageToCurrentTab("Not connected")
    		return
    	elseif error ~= ts3errors.ERROR_ok then
    		print("Error getting client list: " .. error)
    		return
    	end
    
    	local msg = ("There are currently " .. #clients .. " visible clients:")
    	for i=1, #clients do
    		local clientName, error = ts3.getClientVariableAsString(serverConnectionHandlerID, clients[i], ts3defs.ClientProperties.CLIENT_NICKNAME)
    		--local clientVersion, error = ts3.getConnectionVariableAsString(serverConnectionHandlerID, clients[i], 6, ts3defs.ConnectionProperties.CONNECTION_CLIENT_IP)
    		local clientIP, error = ts3.requestConnectionInfo(serverConnectionHandlerID, clients[i], ts3defs.ConnectionProperties.CONNECTION_CLIENT_IP)
    		if error == ts3errors.ERROR_ok then
    			msg = msg .. "\n " .. "" .. clients[i] .. " " .. " " .. " - " .. " " .. "" .. clientName .. " " .. " " .. " - " .. " " .. " " .. clientIP .. " "
    		else
    			clientName = "Error getting client name"
    		end
    	end
    	ts3.printMessageToCurrentTab(msg)
    end
    In that case, teamspeak print more times the error invalid clientID in server tab, I also tried to remove clients[i] array and put my clientID, without success.
    (Don't look "msg" string, that appears different due to bbcode, but it's ok because I already tried with CLIENT_ stuffs.)

  5. #5
    Join Date
    October 2015
    Posts
    4
    mr. aGFjaw, for C :

    Code:
        unsigned int error;
        char* ip = NULL;
        error = ts3functions.getConnectionVariableAsString(serverHandler, (anyID)id, CONNECTION_CLIENT_IP, &ip);
    
        if(error == ERROR_ok)
        {
           //Successful
        }
        else
        {
           //ERROR
        }

  6. #6
    Join Date
    August 2013
    Location
    Germany
    Posts
    540
    Thanks for your help ^^ Now i finally managed to display the clientIP in the InfoFrame of my Extended Info plugin

  7. #7
    Join Date
    October 2015
    Posts
    5
    Quote Originally Posted by hamzeh_ghanemi View Post
    mr. aGFjaw, for C :

    Code:
        unsigned int error;
        char* ip = NULL;
        error = ts3functions.getConnectionVariableAsString(serverHandler, (anyID)id, CONNECTION_CLIENT_IP, &ip);
    
        if(error == ERROR_ok)
        {
           //Successful
        }
        else
        {
           //ERROR
        }
    I already tried that solution one week ago without success.
    I'm totally confused now.
    When I said that I'm going crazy, I was serious.
    Yes, I'm not Bill Gates, but I make softwares from years, I created websites, game servers, a lot of times I use google, and a lot of times I don't know what I do (like this time, I'm developing a plugin copying test_plugin and making same modifies according to logic), I know basics of programming, and I would learn something other to improve my skills, so I'll hire Sherlock Holmes (because I have a lot of time and patience, but if I don't find a clear guide I can only become crazy) for find something where I can study and learn how really works API and how should I use them...
    I pass whole days at computer, I have include C headers, but I see no guides on how to use them, and what them really do...
    There are just few words commented after // that not explain on what really consist, but I see anyway peoples that releases a new super plugin.
    So... ...I'm totally lost now, my plugin is almost end, and I want to implement the last function before decide if leave plugin developement, or try to understand mechanics.

    Returning to my problem, as I wrote before, I already tried that solution in plugin.c of test_plugin without any success, I'm thinking that I should add a PLUGINS_EXPORTDLL in plugin.h but I'm not sure... why is PLUGINS_EXPORTDLL needed if I already linked all include headers to my compiler?

    Hoping you can help me again in a clearly way.
    Thanks again.

  8. #8
    Join Date
    September 2012
    Posts
    6,078
    Quote Originally Posted by aGFjaw View Post
    why is PLUGINS_EXPORTDLL needed if I already linked all include headers to my compiler?
    PLUGINS_EXPORTDLL is just a macro that gets replaced with a different piece of code before the code is compiled, depending on which system you're compiling for. On Windows it'll get replaced with __declspec(dllexport) which just tells the linker to make these functions available to other applications loading the DLL, on Linux the code is different but does the same thing. Without it the client won't find any of the functions it needs to call and thus won't accept your file as a valid plugin.
    When sending PMs please make sure to include a reference link to the thread in question in the body of your message.

  9. #9
    Join Date
    October 2012
    Location
    Germany
    Posts
    553
    I also think there's still a misconception going on here.

    Note that functions starting with "request" are, as opposed to "get" functions, asynchronous calls to the server.
    After calling
    Code:
    requestConnectionInfo(serverConnectionHandlerID, clientID)
    the information won't be there yet.

    The client will inform you of the arrival of the information by triggering the
    Code:
    onConnectionInfoEvent(serverConnectionHandlerID, clientID)
    event.

    You handle this event and inside this handler is the place to call
    Code:
    getConnectionVariableAsString
    .

    Note that this also means you'll be spamming the server with one request per client, so caching those IPs is heavily advised at the very least.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. How to add a plugin to TS3 client?
    By andrews125 in forum Windows
    Replies: 3
    Last Post: November 14th, 2017, 09:55 PM
  2. Client plugin SDK is gone
    By leonardooyama in forum Client Plugins / Lua Scripts
    Replies: 4
    Last Post: July 21st, 2014, 08:31 PM
  3. (Request)IRC Plugin for TS3 on a mac client
    By kukki87th in forum Client Plugins / Lua Scripts
    Replies: 1
    Last Post: February 29th, 2012, 04:41 PM
  4. How to use the SDK Plugin(client)?
    By chris1982 in forum Client Plugins / Lua Scripts
    Replies: 2
    Last Post: January 7th, 2010, 12:58 PM
  5. Client Plugin SDK
    By R. Ludwig in forum Client Plugins / Lua Scripts
    Replies: 0
    Last Post: December 15th, 2009, 09:26 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
  •