hi
i need some advices about scripting lua in dc++ client...
what does mean dcpp:setListener?
what are the other words that are basic and necessary in scripting lua in dc++?
es:hub:sendChat hub:injectChat ecc ecc.
QuoteOriginally posted by -Slash-
hi
i need some advices about scripting lua in dc++ client...
what does mean dcpp:setListener?
what are the other words that are basic and necessary in scripting lua in dc++?
es:hub:sendChat hub:injectChat ecc ecc.
There is no documentation on it, you should tell us what you want to do and we will help you sort it out.
what is the command to send a string to all user in chat?
hub:sendChat???
Yes.
hub:sendChat("Hey, I am just sending a chat message by script! :-)")
i'm making a script that after my command, start the timer and the script send in chat a mex every 30 minutes...
help me to make this script run correctly
--TimerScriptForClients
Tempo={}
--Nome bot
Bot="Spike401k"
--Timer
Tempo = 30
--Abilitazione script 1=abilitato, 0=disabilitato
TimeStatus=1
--comandi
Comando1="+inizia"
Comando2="+ferma"
frasi = {"\n ciao ecco il nuovo script per client fatto da slash",
"\n ciao ecco il nuovo script per client fatto da slash",
}
c=table.getn(frasi)
function Main()
SetTimer(Tempo*60000)
if TimeStatus==1 then
StartTimer()
end
dcpp:setListener( "timerscript", "Tempo",
function ( hub, text )
local s = string.lower( text )
if text == Commando1 then
hub:sendChat(Bot,"Hai avviato lo script")
TimeStatus=1
StartTimer()
return 1
elseif text == Commando2 then
hub:sendChat(Bot, "Hai fermato lo script")
TimeStatus=0
StopTimer()
return 1
end
end
)
function OnTimer()
if TimeStatus==1 then
TopA = frasi[math.random(1,c)]
hub:sendChat(""..Bot.." "..TopA.."")
end
end
end
DC():PrintDebug( " ** TimerScriptForClients.lua ? stato caricato **" )
Work in progress... I am totally a newbie when it comes to clientside scripting.
--TimerScriptForClients
-- we cannot use botname here, only the client's nick
-- also there is no OnTimer(), everything goes by listeners here
--Timer
Tempo =1
--Abilitazione script 1=abilitato, 0=disabilitato
TimeStatus=1
--comandi
Comando1="+inizia"
Comando2="+ferma"
-- enter the IPs of the hubs you wanna make this work in
HubIPs=
{
["127.0.0.1"]=1,
}
frasi = {"\n ciao ecco il nuovo script per client fatto da slash",
"\n ciao ecco il nuovo script per client fatto da slash",
}
k=0
dcpp:setListener( "chat", "Tempo-all",
function(hub,user,text)
local s = string.lower( text )
if text==Comando1 then
hub:sendChat("Hai avviato lo script")
TimeStatus=1
return 1
elseif text == Comando2 then
hub:sendChat("Hai fermato lo script")
TimeStatus=0
return 1
end
end)
dcpp:setListener( "ownChatOut", "Tempo-own",
function(hub,text)
local s = string.lower( text )
if text==Comando1 then
hub:sendChat("Hai avviato lo script")
TimeStatus=1
return 1
elseif text == Comando2 then
hub:sendChat("Hai fermato lo script")
TimeStatus=0
return 1
end
end)
dcpp:setListener("timer","tmr",
function ()
if TimeStatus==1 then
if k==Tempo*60 then
local TopA = frasi[math.random(table.getn(frasi))]
for _,hub in dcpp:getHubs() do
if hubaddresses[hub:getAddress()] then
hub:sendChat(TopA)
end
end
k=0
else
k=k+1
end
end
end)
DC():PrintDebug( " ** TimerScriptForClients.lua e stato caricato **" )
dcpp:setListener( "chat", "Tempo-all",
function(hub,user,text)
local s = string.lower( text )
if text==Comando1 then
hub:sendChat("Hai avviato lo script")
TimeStatus=1
return 1
elseif text == Comando2 then
hub:sendChat("Hai fermato lo script")
TimeStatus=0
return 1
end
end)
dcpp:setListener( "ownChatOut", "Tempo-own",
function(hub,text)
local s = string.lower( text )
if text==Comando1 then
hub:sendChat("Hai avviato lo script")
TimeStatus=1
return 1
elseif text == Comando2 then
hub:sendChat("Hai fermato lo script")
TimeStatus=0
return 1
end
end)
why did u written it 2 times?
only the dcpp:setListener changes...
PS:do u set casually the text near dcpp:setListener or not? --->"ownChatOut", "Tempo-own", or "chat", "Tempo-all",
Because otherwise it raises an error. You are using a weird way of 'thank you' by the way...
:rolleyes:
-- // Edit
Sorted out:
--TimerScriptForClients
-- we cannot use botname here, only the client's nick
-- also there is no OnTimer(), everything goes by listeners here
--Timer
Tempo =1
--Abilitazione script 1=abilitato, 0=disabilitato
TimeStatus=1
--comandi
Comando1="+inizia"
Comando2="+ferma"
-- enter the IPs of the hubs you wanna make this work in
HubIPs=
{
["127.0.0.1"]=1,
}
frasi = {"\n ciao ecco il nuovo script per client fatto da slash",
"\n ciao ecco il nuovo script per client fatto da slash",
}
k=0
function Commands(hub,user,text)
text=text or user
local s = string.lower( text )
if text==Comando1 then
hub:sendChat("Hai avviato lo script")
TimeStatus=1
return 1
elseif text == Comando2 then
hub:sendChat("Hai fermato lo script")
TimeStatus=0
return 1
end
end
dcpp:setListener( "chat", "Tempo-all",function (hub,user,text) return Commands(hub,user,text) end)
dcpp:setListener( "ownChatOut", "Tempo-own",function(hub,text) return Commands(hub,text) end)
dcpp:setListener("timer","tmr",
function ()
if TimeStatus==1 then
if k==Tempo*60 then
local TopA = frasi[math.random(table.getn(frasi))]
for _,hub in dcpp:getHubs() do
if HubIPs[hub:getAddress()] then
hub:sendChat(TopA)
end
end
k=0
else
k=k+1
end
end
end)
DC():PrintDebug( " ** TimerScriptForClients.lua e stato caricato **" )
no no...i'm very grateful for your help...but i was so exciting to know how u did the script...however thank u!
PS:the script doestn't work...because after my command doesn't start the sentences with the timer
QuoteOriginally posted by -Slash-
no no...i'm very grateful for your help...but i was so exciting to know how u did the script...however thank u!
PS:the script doestn't work...because after my command doesn't start the sentences with the timer
What hub address have you specified? It should be an IP, not a DNS. By the way I have found a minor annoyance as well, but fixed. ;-) Edited the above post.
nothing....doesn't work...
LUA Error: ...0.047\DCDM++-0.047\scripts\TimerScriptForClients.lua:50: attempt to index global `hubaddresses' (a nil value)
you are the only one who can hel me! =) tnks
What if you used the latest code I posted?
yes...the last!
QuoteOriginally posted by -Slash-
yes...the last!
Just asking because there is no 'hubaddresses' in it. Copy and save again.
what should i copy?
QuoteOriginally posted by -Slash-
what should i copy?
The code I posted.
wow u are the best!!! now it work
thank u a lot!!!