PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: Einar on 09 February, 2005, 21:48:09

Title: Need a !rar script
Post by: Einar on 09 February, 2005, 21:48:09
I Need a script that opens a .txt file when you writes !rar, you problaly thinks im a noob now but i have never done any scripting before..Can somewon help me whit that?
Title:
Post by: imby on 09 February, 2005, 22:38:16
check out plop's texter series ;)
Title:
Post by: Einar on 10 February, 2005, 12:28:41
QuoteOriginally posted by Mutor
--Readme 1.0
--by Mutor
--
Command ="+readme"
TextFile ="Readme.txt"
Send2All ="no" --Show all users? "yes"/"no"
--
function DataArrival(user, data)
s,e,cmd = strfind(data,"^%b<>%s(%S+)|")
if cmd == Command then
if user.bOperator then
ReadText(user)
return 1
end
end
end

function ReadText(user)
readfrom(TextFile)
while 1 do
local line = read()
if line == nil then break end
if Send2All =="yes" then
SendToAll(line)
else
user:SendData(line)
end
end
readfrom()
end

How can i do so it opens in a pm?
Title:
Post by: 6Marilyn6Manson6 on 10 February, 2005, 13:29:12
QuoteHow can i do so it opens in a pm?

I things is it ok:

--Readme 1.0 in pm o main
--by 6Marilyn6Manson6
BotName = "R-BOT"

function DataArrival(user, data)  
if( strsub(data, 1, 1) == "<" ) then  
local s,e,cmd = strfind( data, "%b<>%s+(%S+)%s*")  
local cmd=strsub(cmd,1,strlen(cmd)-1)  
if (cmd=="+readme") then  
Readtextfile("Readme.txt",user,"pm")  
else
user:SendPM(BotName,"Unknown file or command")  
end
end  
end

Readtextfile = function(file, user, where)
local text = ""
local line
local handle = openfile(file, "r")
if (handle) then
local line = read(handle)
while line do
if line then
text = text..line.."\r\n"
end
line = read(handle)
end
closefile(handle)
else
text = text.."Error file "..file.." not found!\r\n"
end
if where == "pm" then
user:SendPM(BotName, text)
elseif where == "main" then
user:SendData(BotName, text)
end
end

bye bye