PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: pizzamonstret on 26 December, 2004, 16:01:59

Title: +help command *Need help, change script*
Post by: pizzamonstret on 26 December, 2004, 16:01:59
Hello there...  ?(

I need help with this script --->
------------------------------------------------------------------------------------------------------------------------------------------------

botname = "-DvD][SWE-"

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

------------------------------------------------------------------------------------------------------------------------------------------------

When I type +rules, then the bot sends me a PM with all the rules BUT the name om the bot is infront of every line.
It looks like this for example --->

------------------------------------------------------------------------------------------------------------------------------------------------
<-DvD][SWE-> #01:   Slot rule. min 2 slots max 10slots MAX 4 Slot`s if your upload is lower then 1Mbit!!
<-DvD][SWE-> #02:   10 GB minshare.
<-DvD][SWE-> #03:   Max 8 hubs.
------------------------------------------------------------------------------------------------------------------------------------------------

Like I said, bot name infront of every line.. I want the botname in the top of the message and not everywhere in the message. (Just ONE botname)..

Could someone please help me with this?

Thanks  8)
Title:
Post by: enema on 26 December, 2004, 16:21:29
Try this one, but make sure you copy rules in right place (every line should start with msg = msg.."\t\t and end with \r\n")

\t stands for tab, r\ for return... not sure, what does n\ means.. lol :D

--- info bot made by enema. sends anykind of info in PM when cmd is recived
--- date - 26.12.2004
----------------------------------------------------------------

msg=""
msg = "\r\n\t=-=<>=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=<>=-=\r\n"
msg = msg.."\t\t"..frmHub:GetHubName().."\r\n"
msg = msg.."\t=-=<>=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=<>=-=\r\n"
msg = msg.."\t\t                   COPY THE RULES HERE ONE LINE BY ONE \r\n"
msg = msg.."\t\t \r\n"
msg = msg.."\t\t \r\n"
msg = msg.."\t\t \r\n"
msg = msg.."\t\t \r\n"
msg = msg.."\t\t \r\n"
msg = msg.."\t\t \r\n"
msg = msg.."\t\t \r\n"
msg = msg.."\t\t \r\n"
msg = msg.."\t=-=<>=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=<>=-=\r\n"

prefix = "+"
bot = "-DvD][SWE-"

function DataArrival(user,data)
if strsub(data, 1, 1) == "<" then
data=strsub(data,1,strlen(data)-1)
s,e,cmd = strfind(data,"%b<>%s+(%S+)")
if cmd == prefix.."rules" then
user:SendPM(bot, msg)
return 1
end
end
end

havent tested it, but should work..
Title:
Post by: bolamix on 27 December, 2004, 01:47:02
Hi,

I use this:--Made by Piglja(Just learning;P )
--Many thanks to aMustex 4 being so patient and with helping 4 some probs within the script:)
--Bits and pieces added by bolamix for Aiwadirock!

botname = "your-bots-name"
--De-anonymize your bot
bot_email = "whatever"
bot_speed = "whatever"
bot_descr = "whatever"
gb = 0 * 1024 * 1024
bot_share_size = 0 * 1024 * gb
--You must have a folder named "helpfiles" inside your Ptokax scripts folder
--Put your rules.txt and other files in there
rules = "helpfiles/rules.txt"

function Main()
frmHub:RegBot( botname )
my_info_string = "$MyINFO $ALL "..botname.." "..bot_descr.."$ $"..bot_speed..strchar(1).."$"..bot_email.."$"..bot_share_size.."$"
end

function DataArrival(user, data)
if (strsub(data, 1, 1) == "<") then
data = strsub(data,1,strlen(data)-1)
local s,e,cmd = strfind(data,"%b<>%s+(%S+)")
if (cmd=="+rules") then
Help(user, rules)
return 1
end
end
end

function NewUserConnected(user)
user:SendData( my_info_string )
end

function OpConnected(user)
user:SendData( my_info_string )
end


function Help(user, UserFile)
    local filecontents = ""
local handle = openfile(UserFile, "r")
if (handle ~= nil) then
local line = read(handle)
while line do
        filecontents = filecontents..line.."\r\n"
line = read(handle)
end
closefile(handle)
      user:SendPM(botname, filecontents)
end
end
You can add many commands linking to as many help files, and they'll all show with the name of the bot once only, on the first line. Hope this helps ;)

And \n is for New line i think. Which kinda doubles with \r, i know. But there must be a reason ;)
Title:
Post by: pizzamonstret on 27 December, 2004, 02:16:37
Thanke you very much enema. It works fine..

I owe you one ;)