PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: Pieltre on 21 January, 2004, 03:55:54

Title: an easy one
Post by: Pieltre on 21 January, 2004, 03:55:54
Hi,

I got this script that pretty simple:

botname = "Bot"

function Main()
frmHub:RegBot(botname)
end

function DataArrival(user,data)
if strfind(data, "+rules",1,1) then
   readfrom("rules.txt")
   while 1 do
      line = read()
      if line == nil then break end
      user:SendPM(botname,line)
      end
   readfrom()
   end
end


But I want to make it so when the command it performed by OPs, a files called, say, rules_Y.txt is displayed in a PM  and when regs or VIP perform the same command, a file called rules_X.txt is displayed.

thanks in advance,
pieltre
Title:
Post by: Pieltre on 21 January, 2004, 04:09:17
Hi again,

I forgot to mention, ideally I'd like the bot to pick the txt files from a 'text' folder in the script folder...

thanks again,
pieltre
Title:
Post by: pHaTTy on 21 January, 2004, 04:27:08
well hers a little example

Kos = "[RuLeR]"

Command = "+rules"

MasRules = "text/masrules.txt"
OpRules = "text/oprules.txt"
VipRules = "text/viprules.txt"
RegRules = "text/regrules.txt"

function Main()
frmHub:RegBot(Kos)
end

function DataArrival(ustring,dstring)
if strsub(dstring, 1, 1) == "<" then
dstring=strsub(dstring,1,strlen(dstring)-1)
local s,e,cmd = strfind(dstring,"%b<>%s+(%S+)")

if cmd == Command then
if ustring.iProfile == 0 then
file = MasRules
WhileRead(ustring,file)
elseif ustring.bOperator then
file = OpRules
WhileRead(ustring,file)
elseif ustring.iProfile == 2 then
file = VipRules
WhileRead(ustring,file)
else
file = RegRules
WhileRead(ustring,file)
end
end
end
end

function WhileRead(ustring,file)
readfrom(file)
while 1 do
line = read()
if line == nil then
break
end
ustring:SendPM(Kos,line)
end
  readfrom()
end

gives u a start (depending on ur profiles.dat)

cant remember the idx thingy not used in long time
Title:
Post by: Pieltre on 21 January, 2004, 09:38:20
works fine. thanks.
Title:
Post by: ????L?F?? on 21 January, 2004, 10:09:33
damn I even i know the answer to that question ^^

I wanted to help, but oh wel i'll let phatty off this time ^^
Title:
Post by: pHaTTy on 21 January, 2004, 13:32:06
QuoteOriginally posted by ????L?F????
 oh wel i'll let phatty off this time ^^

?? pmsl
Title:
Post by: ????L?F?? on 21 January, 2004, 15:29:54
lol, just messing man