PtokaX forum

Archive => Archived 4.0 boards => Finished Lua 4 scripts => Topic started by: BossiDeLeon on 30 December, 2004, 00:03:00

Title: MOTD problem
Post by: BossiDeLeon on 30 December, 2004, 00:03:00
hey everyone,

i use this code to display "message" in the main chat to a user who has just connected:
function NewUserConnected(sUser)
SendToNick(sUser, "message")
end
but it doesn't seem to work.

consequently, this code for displaying a text file as the MOTD doesn't work either:
MOTD_FILE = "MOTD.txt"

function NewUserConnected(sUser)
SendToNick(sUser, TextFile(MOTD_FILE))
end

function TextFile(file)
readfrom(file, "r")
local message = ""
while 1 do
local line = read()
if line == nil the break
else
message = message..line.."\n"
end
end
readfrom()
return message
end
any help would be very appreciated!
thanks!
Title:
Post by: DJ Bert on 30 December, 2004, 01:05:52
This should work. It gives no errors in my hub.
MOTD_FILE = "motd.txt"

function NewUserConnected(sUser)
SendPm(sUser, "message")
end

function TextFile(file)
readfrom(file, "r")
local message = ""
while 1 do
local line = read()
if line == nil then break
else
message = message..line.."\n"
end
end
readfrom()
return message
end


Grtzzz
DJ Bert
Title:
Post by: [_XStaTiC_] on 30 December, 2004, 01:43:30
try this :)

motd = "MOTD.txt" -- textfile
bot = "welcome" -- botname Give it the same name as your main bot

function Main()
frmHub:RegBot(bot)
end

OpConnected = NewUserConnected
function NewUserConnected(sUser)
sUser:SendPM(bot,TextFile(motd))
end

function TextFile(file)
readfrom(file, "r")
local message = ""
while 1 do
local line = read()
if line == nil then break
else
message = message..line.."\n"
end
end
readfrom()
return message
end
Title:
Post by: BossiDeLeon on 03 January, 2005, 06:00:43
thanks so much for your help guys!! works great now!!

here's the code:
MOTD = "MOTD.txt" -- textfile

function NewUserConnected(sUser)
sUser:SendData(TextFile(MOTD))
end

function TextFile(file)
readfrom(file, "r")
local message = ""
while 1 do
local line = read()
if line == nil then break
else
message = message..line.."\n"
end
end
readfrom()
return message
end