Lua脚本用于解释TS3中的客户端poke

这是一个工作中的TS3 poke脚本,可以poke所有用户:

function pokeall(serverConnectionHandlerID)
 local clients, error = ts3.getClientList(serverConnectionHandlerID)
  for i=1, #clients do
 local clname, clientNameError = ts3.getClientVariableAsString(serverConnectionHandlerID, clients[i], ts3defs.ClientProperties.CLIENT_NICKNAME)
 ts3.requestClientPoke(serverConnectionHandlerID, clients[i], "Lua Pokeall script :-)")
 --ts3.printMessage(serverConnectionHandlerID, "Poked "..clname.." (id: "..clients[i]..")!")
end
end

ts3.printMessage现在是一个注释(可选)。

使用命令运行这个脚本:**/lua run pokeall**

我是Lua的新手。我想了解这段代码是如何工作的。 因此,如果我理解正确: 我们有2个变量clientsclnamefor是一个循环操作。它从索引1开始(因此是第2个元素)。为什么不以0(i = 0)开始?

clname获取用户名,我想是吗?

如何poke具体的用户? (使用命令仅poke 1个用户:/lua run pokeall USER_NICKNAME-->>用户的名称)

ts3.requestClientPoke中将clients[i]更改为clname是否足够?

点赞
用户2858170
用户2858170

为什么不使用 0(i = 0)?

因为 Lua 序列从索引 1 开始,不像大多数其他编程语言。

ts3.requestClientPoke 中将 clients [i] 改为 clname 足够了吗?

您使用客户端 ID 而不是名称来 poke 用户。

2020-04-16 16:34:42