B1uscr34m

Teamspeak TS 3 TS3 Plugin LUA Script - Client Dump Script

Nov 14th, 2014
447
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. require("ts3defs")
  2. require("ts3errors")
  3. local SCRIPT = "TS3 Dump Script"
  4. local SCRIPTSHORT = "TS3DS"
  5. local VERSION = "0.2"
  6. local AUTHOR = "B1uscr34m"
  7. local EMAIL = "piracy@teamspeakusa.com"
  8. ------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  9. -- Installation Instructions:
  10. ------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  11. -- %ts3dir%: "c:\program files (x68)\teamspeak 3 client" OR "c:\program files\teamspeak 3 client" OR "C:\Users\YOUR USERNAME\AppData\Roaming\TS3Client"
  12. -- a) If you want to use the full plugin:
  13. -- a1) Download the plugin here:
  14. -- a2) Install the plugin
  15. -- a3) Goto step c)
  16. -- b) If you want to run this script seperatly:
  17. -- b1) Save this script as "masscontrolmodule.lua" in your "%ts3dir%\plugins\lua_plugin" folder.
  18. -- b2) In teamspeak, any window, where chat would be enter: "/lua load masscontrolmodule.lua" -- Response will be: "Lua script loaded"
  19. -- b3) Now go to step c)
  20. -- c) In Teamspeak press [CTRL]+[SHIFT]+[P] or go to 'Settings -> Plugins' and check the 'Lua Plugin' Checkbox.
  21. -- c1) Click on Reload all then mark 'Lua Plugin' and click on Settings.
  22. -- c2) Uncheck 'testmodule' and restart Teamspeak 3 Client or click on 'Reload all'
  23. -- d) Call everything in here named "function TEXTHERE" from the TeamSpeak 3 chat via: /lua run <function>
  24. -- Note that the serverConnectionHandlerID of the current server is always passed.
  25. --
  26. -- Settings
  27. -- local TS3DS_DEBUG = true
  28. -- local ts3dsCol = { 'Green', 'Yellow', 'Red', 'Blue' }
  29. -- local RANDCOL = ( ts3dsCol[ math.random( #ts3dsCol ) ] )
  30. -- local ts3dsPrefix = "[color="Blue"]([/color][color="Green"]EMC[/color][color="Blue"])[/color] "
  31.  
  32. function dumpClientsTXT(serverConnectionHandlerID,Func)
  33.         ts3.requestServerVariables(serverConnectionHandlerID)
  34.         local clients, error = ts3.getClientList(serverConnectionHandlerID)
  35.         local myClientID, error = ts3.getClientID(serverConnectionHandlerID)
  36.         local chanID, error = ts3.getChannelOfClient(serverConnectionHandlerID,myClientID)
  37.         local serverUID, error = ts3.getServerVariableAsString(serverConnectionHandlerID, ts3defs.VirtualServerProperties.VIRTUALSERVER_UNIQUE_IDENTIFIER)
  38.         local serverNAME, error = ts3.getServerVariableAsString(serverConnectionHandlerID, ts3defs.VirtualServerProperties.VIRTUALSERVER_NAME)
  39.         local serverCLIENTS, error = ts3.getServerVariableAsInt(serverConnectionHandlerID, ts3defs.VirtualServerProperties.VIRTUALSERVER_CLIENTS_ONLINE)
  40.         local serverMAXCLIENTS, error = ts3.getServerVariableAsString(serverConnectionHandlerID, ts3defs.VirtualServerProperties.VIRTUALSERVER_MAXCLIENTS)
  41.         local serverCHANNELS, error = ts3.getServerVariableAsInt(serverConnectionHandlerID, ts3defs.VirtualServerProperties.VIRTUALSERVER_CHANNELS_ONLINE)
  42.         local serverVERSION, error = ts3.getServerVariableAsString(serverConnectionHandlerID, ts3defs.VirtualServerProperties.VIRTUALSERVER_VERSION)
  43.         local serverPLATFORM, error = ts3.getServerVariableAsString(serverConnectionHandlerID, ts3defs.VirtualServerProperties.VIRTUALSERVER_PLATFORM)
  44.         local date = os.date()
  45.         local time = os.time()
  46.         if Func == "All" and Func ~= "Room" then
  47.             --file = io.open("C:/Users/Timo/AppData/Roaming/TS3Client/dumps/serverclientdump_" .. serverUID .. ".txt", "w")
  48.             file = io.open("C:/Users/Timo/AppData/Roaming/TS3Client/dumps/" .. serverNAME .. ".txt", "w")
  49.             ts3.printMessageToCurrentTab("Server Clients Dump of Server: " .. serverNAME .. " at " .. date .. "\n")
  50.             file:write("Server Clients Dump of Server: " .. serverNAME .. " at " .. date .. "\n")
  51.             ts3.printMessageToCurrentTab("ServerID: " .. serverConnectionHandlerID .. " ServerUID: " .. serverUID .. "\n")
  52.             file:write("ServerID: " .. serverConnectionHandlerID .. " ServerUID: " .. serverUID .. "\n")
  53.             ts3.printMessageToCurrentTab("Online Clients: " .. serverCLIENTS .. "/" .. serverMAXCLIENTS .." Channels: " .. serverCHANNELS .. "\n")
  54.             file:write("Online Clients: " .. serverCLIENTS .. "/" .. serverMAXCLIENTS .." Channels: " .. serverCHANNELS .. "\n")
  55.             ts3.printMessageToCurrentTab("Running " .. serverVERSION .. " on " .. serverPLATFORM .. "\n")
  56.             file:write("Running " .. serverVERSION .. " on " .. serverPLATFORM .. "\n")
  57.         end
  58.         if chanID == clientsChanID and Func ~= "All" and Func == "Room" then
  59.             file = io.open("C:/Users/Timo/AppData/Roaming/TS3Client/dumps/channelclientdump_" .. serverUID .. "_" .. chanID .. ".txt", "w")
  60.             file:write("Channel Clients Dump of Server: " .. serverNAME .. " in " .. chanID .. " at " .. date .. "\nServerID: " .. serverConnectionHandlerID .. " ServerUID: " .. serverUID .. "\n")
  61.         end
  62.         for i=1, #clients do
  63.                 local clientsChanID, error = ts3.getChannelOfClient(serverConnectionHandlerID,clients[i])
  64.                 if Func == "All" and Func ~= "Room" then
  65.                         local tclientID = clients[i]
  66.                         ts3.requestClientVariables(serverConnectionHandlerID, tclientID)
  67.                         local AllMyRoomClientsDB, error = ts3.getClientVariableAsString(serverConnectionHandlerID,clients[i],ts3defs.ClientProperties.CLIENT_DATABASE_ID)
  68.                         local AllMyRoomClientName, error = ts3.getClientVariableAsString(serverConnectionHandlerID,clients[i],ts3defs.ClientProperties.CLIENT_NICKNAME)
  69.                         local AllMyRoomClientUID, error = ts3.getClientVariableAsString(serverConnectionHandlerID,clients[i],ts3defs.ClientProperties.CLIENT_UNIQUE_IDENTIFIER)
  70.                         local AllMyRoomClientVERSION, error = ts3.getClientVariableAsString(serverConnectionHandlerID,clients[i],ts3defs.ClientProperties.CLIENT_VERSION)
  71.                         local AllMyRoomClientPLATFORM, error = ts3.getClientVariableAsString(serverConnectionHandlerID,clients[i],ts3defs.ClientProperties.CLIENT_PLATFORM)
  72.                         -- local AllMyRoomClientCOUNTRY, error = ts3.getClientVariableAsString(serverConnectionHandlerID,clients[i],ts3defs.ClientProperties.CLIENT_COUNTRY)
  73.                         local AllMyRoomClientTYPE, error = ts3.getClientVariableAsString(serverConnectionHandlerID,clients[i],ts3defs.ClientProperties.CLIENT_TYPE)
  74.                         if AllMyRoomClientTYPE == "1" then
  75.                             AllMyRoomClientTYPE = "QUERY"
  76.                         elseif AllMyRoomClientTYPE == "0" then
  77.                             AllMyRoomClientTYPE = "CLIENT"
  78.                         else
  79.                             AllMyRoomClientTYPE = "UNKOWN"
  80.                         end
  81.                         ts3.printMessageToCurrentTab(AllMyRoomClientTYPE .. " > " .. clientsChanID .. " > ClientName: "..AllMyRoomClientName.." | ClientDB: "..AllMyRoomClientsDB.." | ClientID: "..clients[i])
  82.                         file:write(AllMyRoomClientTYPE..": "..AllMyRoomClientName.." | Channel: "..clientsChanID.." | DBID: "..AllMyRoomClientsDB.." | CID: "..clients[i].." | VER: "..AllMyRoomClientVERSION.." | OS: "..AllMyRoomClientPLATFORM.." | UID: "..AllMyRoomClientUID.."\n")
  83.                         --file:write("\n")
  84.                 end
  85.                 if chanID == clientsChanID and Func ~= "All" and Func == "Room" then
  86.                         local AllMyRoomClientsDB, error = ts3.getClientVariableAsString(serverConnectionHandlerID,clients[i],ts3defs.ClientProperties.CLIENT_DATABASE_ID)
  87.                         local AllMyRoomClientName, error = ts3.getClientVariableAsString(serverConnectionHandlerID,clients[i],ts3defs.ClientProperties.CLIENT_NICKNAME)
  88.                         ts3.printMessageToCurrentTab("ClientName: "..AllMyRoomClientName.." | ClientDB: "..AllMyRoomClientsDB.." | ClientID: "..clients[i]..".")
  89.                         -- file:write("ClientName: "..AllMyRoomClientName.." | ClientDB: "..AllMyRoomClientsDB.." | ClientID: "..clients[i]..".")
  90.                         -- file:write("\n")
  91.                 end
  92.         end
  93.         if Func ~= "All" and Func ~= "Room" then
  94.                 ts3.printMessageToCurrentTab("[ERROR]: DO Command: /lua run info [All/Room]")
  95.         end
  96.         if Func == "All" and Func ~= "Room" then
  97.         file:close()
  98.         end
  99. end
  100.  
  101. function dumpClientsCSV(serverConnectionHandlerID,Func)
  102.         ts3.requestServerVariables(serverConnectionHandlerID)
  103.         local clients, error = ts3.getClientList(serverConnectionHandlerID)
  104.         local myClientID, error = ts3.getClientID(serverConnectionHandlerID)
  105.         local chanID, error = ts3.getChannelOfClient(serverConnectionHandlerID,myClientID)
  106.         local serverNAME, error = ts3.getServerVariableAsString(serverConnectionHandlerID, ts3defs.VirtualServerProperties.VIRTUALSERVER_NAME)
  107.         local date = os.date()
  108.         local time = os.time()
  109.         if Func == "All" and Func ~= "Room" then
  110.             file = io.open("C:/Users/Timo/AppData/Roaming/TS3Client/dumps/" .. serverNAME .. ".csv", "w")
  111.             ts3.printMessageToCurrentTab("Server Clients Dump of Server: " .. serverNAME .. " at " .. date .. "\n")
  112.             file:write("TYPE,Nickname,Channel ID,DBID,CID,VERSION,PLATFORM,UID\n")
  113.         end
  114.         if chanID == clientsChanID and Func ~= "All" and Func == "Room" then
  115.             file = io.open("C:/Users/Timo/AppData/Roaming/TS3Client/dumps/channelclientdump_" .. serverUID .. "_" .. chanID .. ".csv", "w")
  116.         end
  117.         for i=1, #clients do
  118.                 local clientsChanID, error = ts3.getChannelOfClient(serverConnectionHandlerID,clients[i])
  119.                 if Func == "All" and Func ~= "Room" then
  120.                         local tclientID = clients[i]
  121.                         ts3.requestClientVariables(serverConnectionHandlerID, tclientID)
  122.                         local AllMyRoomClientsDB, error = ts3.getClientVariableAsString(serverConnectionHandlerID,clients[i],ts3defs.ClientProperties.CLIENT_DATABASE_ID)
  123.                         local AllMyRoomClientName, error = ts3.getClientVariableAsString(serverConnectionHandlerID,clients[i],ts3defs.ClientProperties.CLIENT_NICKNAME)
  124.                         local AllMyRoomClientUID, error = ts3.getClientVariableAsString(serverConnectionHandlerID,clients[i],ts3defs.ClientProperties.CLIENT_UNIQUE_IDENTIFIER)
  125.                         local AllMyRoomClientVERSION, error = ts3.getClientVariableAsString(serverConnectionHandlerID,clients[i],ts3defs.ClientProperties.CLIENT_VERSION)
  126.                         local AllMyRoomClientPLATFORM, error = ts3.getClientVariableAsString(serverConnectionHandlerID,clients[i],ts3defs.ClientProperties.CLIENT_PLATFORM)
  127.                         -- local AllMyRoomClientCOUNTRY, error = ts3.getClientVariableAsString(serverConnectionHandlerID,clients[i],ts3defs.ClientProperties.CLIENT_COUNTRY)
  128.                         local AllMyRoomClientTYPE, error = ts3.getClientVariableAsString(serverConnectionHandlerID,clients[i],ts3defs.ClientProperties.CLIENT_TYPE)
  129.                         if AllMyRoomClientTYPE == "1" then
  130.                             AllMyRoomClientTYPE = "QUERY"
  131.                         elseif AllMyRoomClientTYPE == "0" then
  132.                             AllMyRoomClientTYPE = "CLIENT"
  133.                         else
  134.                             AllMyRoomClientTYPE = "UNKOWN"
  135.                         end
  136.                         file:write(AllMyRoomClientTYPE..","..AllMyRoomClientName..","..clientsChanID..","..AllMyRoomClientsDB..","..clients[i]..","..AllMyRoomClientVERSION..","..AllMyRoomClientPLATFORM..","..AllMyRoomClientUID.."\n")
  137.                         --file:write("\n")
  138.                 end
  139.                 if chanID == clientsChanID and Func ~= "All" and Func == "Room" then
  140.                         local AllMyRoomClientsDB, error = ts3.getClientVariableAsString(serverConnectionHandlerID,clients[i],ts3defs.ClientProperties.CLIENT_DATABASE_ID)
  141.                         local AllMyRoomClientName, error = ts3.getClientVariableAsString(serverConnectionHandlerID,clients[i],ts3defs.ClientProperties.CLIENT_NICKNAME)
  142.                         ts3.printMessageToCurrentTab("ClientName: "..AllMyRoomClientName.." | ClientDB: "..AllMyRoomClientsDB.." | ClientID: "..clients[i]..".")
  143.                         -- file:write("ClientName: "..AllMyRoomClientName.." | ClientDB: "..AllMyRoomClientsDB.." | ClientID: "..clients[i]..".")
  144.                         -- file:write("\n")
  145.                 end
  146.         end
  147.         if Func ~= "All" and Func ~= "Room" then
  148.                 ts3.printMessageToCurrentTab("[ERROR]: DO Command: /lua run info [All/Room]")
  149.         end
  150.         if Func == "All" and Func ~= "Room" then
  151.         file:close()
  152.         end
  153. end
RAW Paste Data