Skip to content

Instantly share code, notes, and snippets.

@gamerlv
Created February 17, 2016 00:13
Show Gist options
  • Save gamerlv/92d28f7b813adebc970c to your computer and use it in GitHub Desktop.
Save gamerlv/92d28f7b813adebc970c to your computer and use it in GitHub Desktop.
--
-- schijt initialisation, this script is called via autoload mechanism when the
-- TeamSpeak 3 client starts.
--
require("ts3init") -- Required for ts3RegisterModule
require("ts3defs")
require("ts3errors")
local s_moduleMenuItemID = 1
local s_MenuIDs = {
MENU_ID_CLIENT_SAY = 1
}
local function createMenus(moduleMenuItemID)
-- Store value added to menuIDs to be able to calculate menuIDs for this module again for setPluginMenuEnabled (see demo.lua)
s_moduleMenuItemID = moduleMenuItemID
-- Create the menus
-- There are three types of menu items:
-- ts3defs.PluginMenuType.PLUGIN_MENU_TYPE_CLIENT: Client context menu
-- ts3defs.PluginMenuType.PLUGIN_MENU_TYPE_CHANNEL: Channel context menu
-- ts3defs.PluginMenuType.PLUGIN_MENU_TYPE_GLOBAL: "Plugins" menu in menu bar of main window
--
-- Menu IDs are used to identify the menu item when onMenuItemEvent is called, see testmodule/events.lua for the implementation of onMenuItemEvent
-- Valid menu IDs are 0 to 999.
--
-- The menu text is required, max length is 128 characters
--
-- The icon is optional, max length is 128 characters. When not using icons, just pass an empty string.
-- Icons are loaded from a subdirectory in the TeamSpeak client plugins folder. The subdirectory must be named like the
-- plugin filename, without dll/so/dylib suffix
-- e.g. for "test_plugin.dll", icon "1.png" is loaded from <TeamSpeak 3 Client install dir>\plugins\test_plugin\1.png
-- In this example we reuse the existing icons from the plugins\test_plugin\ directory, which resides as "..\test_plugin" relative to
-- the lua_plugin directory.
return {
{ts3defs.PluginMenuType.PLUGIN_MENU_TYPE_CLIENT, s_MenuIDs.MENU_ID_CLIENT_SAY, "Spam say", ""}
}
end
--
-- Called when a plugin menu item (see ts3plugin_initMenus) is triggered. Optional function, when not using plugin menus, do not implement this.
--
-- Parameters:
-- serverConnectionHandlerID: ID of the current server tab
-- type: Type of the menu (ts3defs.PluginMenuType.PLUGIN_MENU_TYPE_CHANNEL, ts3defs.PluginMenuType.PLUGIN_MENU_TYPE_CLIENT or ts3defs.PluginMenuType.PLUGIN_MENU_TYPE_GLOBAL)
-- menuItemID: Id used when creating the menu item
-- selectedItemID: Channel or Client ID in the case of PLUGIN_MENU_TYPE_CHANNEL and PLUGIN_MENU_TYPE_CLIENT. 0 for PLUGIN_MENU_TYPE_GLOBAL.
--
local function onMenuItemEvent(serverConnectionHandlerID, menuType, menuItemID, selectedItemID)
if menuItemID == s_MenuIDs.MENU_ID_CLIENT_SAY then
local error = nil
for i=1,50 do
ts3.requestSendPrivateTextMsg(serverConnectionHandlerID, "Hallo Albertor! Dit is msg nr. " .. i, selectedItemID) > error
if error then
print("Something broke! " .. error)
-- break
end
end
end
end
local events = {
createMenus = createMenus,
onMenuItemEvent = onMenuItemEvent
}
local schijt = {
init = function(){
print "HAAYY"
}
}
ts3RegisterModule("schijt", events)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment