-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathevents.lua
79 lines (67 loc) · 2.62 KB
/
events.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
require("ts3defs")
require("ts3errors")
local MODULE_NAME = "guestsound"
--- C O N F I G U R A T I O N ---
-- Monitor for specific user (You must know user id)
local user_array = {
"MnfjhODyEeAWpRKhcFRZSse3o4c=", -- SomeUsername
"qioeb8wGoUQ/Cw5jbFFTnnpE8Nc=", -- MyBigFriend
-- "lmiGld35Qabf7xv+ZJJ6LYA2BbE=" -- Disabled for this user
}
-- First (TOP) Channel name
local monitor_for_server_name = "You server name"
-- replace 8 with the serverguest group id
-- Permission->Server Groups->Example: Guest(8)
local monitor_for_group_id = "8"
---------------------------------
---------------------------------
local function has_value (tab, val)
for index, value in ipairs (tab) do
if value == val then
return true
end
end
return false
end
local pluginPath = ts3.getPluginPath()
local function playSound (schid, wav)
local wavPath = pluginPath.."lua_plugin/guestsound/sound/"..wav
--ts3.printMessageToCurrentTab(wavPath)
local error = ts3.playWaveFile(schid, wavPath)
if error ~= ts3errors.ERROR_ok then
ts3.printMessageToCurrentTab("Error playing "..wavPath..": " .. error)
end
end
local function onClientMoveEvent(schid, clientID, oldChannelID, newChannelID, visibility, moveMessage)
--if visibility == ts3defs.Visibility.ENTER_VISIBILITY then
if oldChannelID == 0 then -- only then enter server
local nickname, errorCode = ts3.getClientVariableAsString(schid, clientID, ts3defs.ClientProperties.CLIENT_NICKNAME)
if errorCode ~= ts3errors.ERROR_ok then
ts3.printMessage(schid, (MODULE_NAME .. ": Error getting nickname: " .. errorCode), 0)
return
end
if (has_value(user_array, clientID)) then
ts3.printMessageToCurrentTab("Our user: "..nickname)
playSound(schid, "new_connection.wav")
return
end
local server_name, errorCode = ts3.getServerVariableAsString(schid, ts3defs.VirtualServerProperties.VIRTUALSERVER_NAME)
if (errorCode ~= ts3errors.ERROR_ok) then
ts3.printMessage(schid, (MODULE_NAME .. ": Error getting server name: " .. errorCode), 0)
return
end
--ts3.printMessageToCurrentTab(nickname.." come to server: "..server_name)
if server_name == monitor_for_server_name then
local grps, error = ts3.getClientVariableAsString(schid, clientID, ts3defs.ClientProperties.CLIENT_SERVERGROUPS)
if error == ts3errors.ERROR_ok then
if grps == monitor_for_group_id then
ts3.printMessageToCurrentTab("Our guest: "..nickname.." GroupId: "..grps)
playSound(schid, "new_connection_ru.wav")
end
end
end
end
end
guestsound_events = {
onClientMoveEvent = onClientMoveEvent
}