I wanted a script which will send any text message
or ascii from the text file at the start of connecting
hub in PM
( text to be displayed is not to be saved in script
but in different text file )
---------------------------------------------------------------------------------- ascii PM sender , on connect
--added newuserconnected, by Dessamator
--by stravides
-- LUA 5
--03/02/05
sBot = frmHub:GetHubBotName() -- your main bot here
file1 ="ascii" --name of file
function Main()
frmHub:RegBot(sBot)
end
function NewUserConnected(user,data)
showtext(user, file1)
end
OpConnected = NewUserConnected
function showtext(user, file)
local contents ="\r\n\r\n"
for line in io.lines(file..".txt") do
contents = contents..line.."\r\n"
end
user:SendPM(sBot,"\r\n"..contents.."\r\n|")
end
Done!!
in case u want to add anymore txts, just add two lines :
eg.:
file2 ="ascii2" --name of file
and
showtext(user, file2)
Unfortunately, it doesn't work m8
Can you please check again....
QuoteUnfortunately, it doesn't work m8
Can you please check again....
hmm it does work, just follow these 3 steps:
1. create a folder named, "images", in the scripts folder
2. copy a file which u want the users to receive to that folder
3.put the file name here eg.: ascii.txt :
file1 ="ascii" --name of file
(ps the file u select must have an extension of .txt)
run the script, and reconnect, and voila ull receive ur msg !!!
I did it earler also and I did it again but
still it doesn't work...:-(
The text file to be displayed can be saved in scripts
folder rather making different folder.....
plz help...
It's working well with me...
I am getting this error.....
20: bad argument #1 to `lines' (No such file or directory
)
Done !!, post edited u can put in a normal scripts folder
I am getting this error
.lua:22: bad argument #1 to `lines' (No such file or directory)
QuoteOriginally posted by kash?
I am getting this error
.lua:22: bad argument #1 to `lines' (No such file or directory)
ok, lets c how to solve this, first, post ur script here, with all the changes u made!
i haven't modified I think.....
this is...
---------------------------------------------------------------------------------- ascii PM sender , on connect
--added newuserconnected, by Dessamator
--by stravides
-- LUA 5
--03/02/05
sBot = frmHub:GetHubBotName() -- your main bot here
file1 ="ascii" --name of file
function Main()
frmHub:RegBot(sBot)
end
function NewUserConnected(user,data)
showtext(user, file1)
end
OpConnected = NewUserConnected
function showtext(user, file)
local contents ="\r\n\r\n"
for line in io.lines(file..".txt") do
contents = contents..line.."\r\n"
end
user:SendPM(sBot,"\r\n"..contents.."\r\n|")
end
ok, and where exactly did u put the file, with the info u want to send?, and whats the name of the file?
i put that lua file in scripts folder and
and text also in scripts folder with info and
I tried with ascii and ascii.txt also...
QuoteOriginally posted by kash?
i put that lua file in scripts folder and
and text also in scripts folder with info and
I tried with ascii and ascii.txt also...
hmm, the name should be: ascii.txt , and it should be in : \ptokax\scripts
like this :
\(ptokax folder)\scripts\ascii.txt
I have done as u told me
Still I am getting same error
try some other script for it
regards
Try this one (put the text files in ur scripts folder alongside the lua files):
--added newuserconnected, by Dessamator
--by stravides
-- LUA 5
--03/02/05
sBot = frmHub:GetHubBotName() -- your main bot here
file1 ="asciis" --name of file1
function Main()
frmHub:RegBot(sBot)
end
function NewUserConnected(user,data)
showtext(user, file1)
end
OpConnected = NewUserConnected
function showtext(user, filename)
local contents ="\r\n\r\n"
local f = io.open(filename..".txt", "r")
if f then
for line in f:lines() do
contents = contents..line.."\r\n"
end
f:close()
user:SendPM(sBot,"\r\n"..contents.."\r\n|")
else
user:SendPM(sBot,filename..".txt doesn't exist")
end
end
Cheers
---------------------------------------------------------------------------------- ascii PM sender , on connect
--added newuserconnected, by Dessamator
--by stravides
-- LUA 5
--03/02/05
sBot = frmHub:GetHubBotName() -- your main bot here
file1 ="ascii.txt" --name of file
function Main()
frmHub:RegBot(sBot)
CreateFile(file1)
end
function CreateFile(filename)
if checkfile(filename)=="false" then
io.output(filename)
io.output()
WriteToFile(filename)
end
end
function NewUserConnected(user,data)
showtext(user, file1)
end
OpConnected = NewUserConnected
function showtext(user, file)
local contents ="\r\n\r\n"
for line in io.lines(file) do
contents = contents..line.."\r\n"
end
user:SendPM(sBot,"\r\n"..contents.."\r\n|")
end
function checkfile(filename)
local f = io.open(filename, "r")
if f then
f:close()
return "true"
else
return "false"
end
end
function WriteToFile(filename)
local file = io.open(filename, "w+") -- "w" write
file:write("Type ur info here(ps u can delete this line)")
file:close()
end
Done !!
here u go Kash, no need to create a file, just search for "ascii.txt"(without quotation marks), and edit it and put the info you want there !
thanx guys
Dessamator you script is not working
however it is not showing any errors
jiten ur script is working
but it works only once after starting hub, i.e.if I close dc++ and open it again it doesn't show any text,
that too only I received that ascii and no other
user in hub received it
I want it to work whenever I connect hub and
whoever connect it
Is it possible to display two text files (ascii)
thanx both for help
regards
QuoteOriginally posted by Dessamator
Done!!
in case u want to add anymore txts, just add two lines :
eg.:
file2 ="ascii2" --name of file
and
showtext(user, file2)