Reputation: 132
This is a working TS3 poke script, which pokes all of the users:
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
is a comment now (optional).
This script is working with command: /lua run pokeall
I'm new in Lua. I want to understand how this code works.
So here, if i get it correctly:
we have 2 variables clients
and clname
. clients[i]
with for
it's obviously a loop. It starts with index 1 (so it's the 2. element). Why not with 0 (i = 0) ?
clname
gets the user name, i think...
How can i poke a concrete user ? (to poke only 1 user with command: /lua run pokeall USER_NICKNAME --> name of the user)
Enough to change the clients[i]
to clname
in ts3.requestClientPoke
?
Upvotes: -1
Views: 632
Reputation: 28950
Why not with 0 (i = 0) ?
Because Lua sequences start at index 1 unlike most other programming languages.
Enough to change the clients[i] to clname in ts3.requestClientPoke ?
You poke a user with its client id, not with its name.
Upvotes: 1