PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: Woodster on 16 February, 2004, 18:02:46

Title: Rules Bot
Post by: Woodster on 16 February, 2004, 18:02:46
Bot = "BOT"


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


If i am correct - then that will send to connected users the "Rules"

Still fairly new to LUA and was wondering from this that i have used - how would i now develop this to not show a bot on the userlist??

Title:
Post by: pHaTTy on 16 February, 2004, 18:17:08
well u can simply do


function Main()
frmHub:RegBot(Bot)
end

Title:
Post by: Woodster on 16 February, 2004, 18:19:59
So that would work ??

function Main()
frmHub:RegBot(Bot)
end

function NewUserConnected(user)
if strfind(data, "rules",1,1) then
readfrom("rules.txt")
while 1 do
line = read()
if line == nil then break end
user:SendPM(Bot,line)
end
readfrom()
end
end
Title:
Post by: pHaTTy on 16 February, 2004, 18:20:56
QuoteOriginally posted by Woodster
So that would work ??

function Main()
frmHub:RegBot(Bot)
end

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


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


this is wrong ;)

if strfind(data, "rules",1,1) then

what data?

function NewUserConnected(user)
readfrom("rules.txt")
while 1 do
line = read()
if line == nil then
break
end
user:SendPM(Bot,line)
end
readfrom()
end
Title:
Post by: Woodster on 16 February, 2004, 18:22:12
Just tested it and it doesnt send the Rules on connection???

What have i done wrong?
Title:
Post by: pHaTTy on 16 February, 2004, 18:24:18
^
Title:
Post by: Woodster on 16 February, 2004, 18:33:24
I dont know what im doing wrong but still it is not sending the rules to connecting users??
Title:
Post by: pHaTTy on 16 February, 2004, 18:34:53
QuoteOriginally posted by Woodster
I dont know what im doing wrong but still it is not sending the rules to connecting users??

hvae you made file named rules.txt?
Title:
Post by: Woodster on 16 February, 2004, 18:37:56
Yup! This is what i using:

function Main()
frmHub:RegBot(Bot)
end

function NewUserConnected(user)
   readfrom("rules.txt")
   while 1 do
      line = read()
      if line == nil then
         break
      end
      user:SendPM(Bot,line)
   end
   readfrom()
end

(its probably that which is incorrect)
Title:
Post by: pHaTTy on 16 February, 2004, 18:42:10
my mistake lol


function Main()
frmHub:RegBot(Bot)
end

function NewUserConnected(user)
readfrom("rules.txt")
while 1 do
line = read()
if line == nil then
break
end
user:SendPM(Bot,line)
readfrom()
end
end


plz when posying code use [ c o d e ] [ / c o d e ] without spaces :)
Title:
Post by: Woodster on 16 February, 2004, 18:43:53
ok then :) sorry
Title:
Post by: Woodster on 16 February, 2004, 18:48:27
LOL

Bet ya getting annoyed now!! lol

still not working......

where do i save the rules.txt?
Title:
Post by: pHaTTy on 16 February, 2004, 18:51:51
lol dont forget to add

Bot = "whatever"

and the rules file goes in scripts dir
Title:
Post by: Woodster on 16 February, 2004, 18:56:50

Bot = "Rules"

function Main()
frmHub:RegBot(Bot)
end

function NewUserConnected(user)
readfrom("rules.txt")
while 1 do
line = read()
if line == nil then
break
end
user:SendPM(Bot,line)
readfrom()
end
end

lol, this lua thing is frustrating when it dont work lol!!

Last attempt otherwise im not gonna bother!

Will that pm Users, Reg's, Op's, Masters etc.. the rules on connection??
Title:
Post by: pHaTTy on 16 February, 2004, 19:00:44
no

add this line


OpConnected = NewUserConnected

Title:
Post by: pHaTTy on 16 February, 2004, 19:06:15
grr got me all confused lol


Bot = "Rules"

function Main()
frmHub:RegBot(Bot)
end

OpConnected = NewUserConnected
function NewUserConnected(user)
readfrom("rules.txt")
while 1 do
line = read()
if line == nil then
break
end
user:SendPM(Bot,line)
end
readfrom()
end