PtokaX forum

Archive => Archived 4.0 boards => Finished Lua 4 scripts => Topic started by: BrokenBrick on 22 October, 2003, 01:06:20

Title: Help/Commands Script
Post by: BrokenBrick on 22 October, 2003, 01:06:20
This is a script that allows you to add a help file, commands listing, rules, or whatever the hell else you might want, set to a trigger in the main chat.  I use it because I have quite a few commands in my hub, and its a bit wordy to list them all in the join message.  Make sure that your file "BlahWhatever.txt" is in a sub-folder of your scripts folder called "txt" otherwise the script will not function. I didn't write this, but I can help with some questions I guess
____________________________________

cmd1 = "!Commands"
file1 = "Commands.txt"
bot1 = "Commander"

function DataArrival(curUser,data)
if (strsub(data, 1, 1) == "<") then
data = strsub(data,1,strlen(data)-1)
if (strfind(strlower(data), strlower(cmd1))) then
OpenFile(curUser, file1, bot1)
return 1
end
end
end

function OpenFile(curUser, File, bot)
local msgfromtxt ="\r\n"
readfrom("txt/"..File)
while 1 do
local line = read()
if (line == nil) then
break
else
msgfromtxt = msgfromtxt.." "..line.."\r\n"
end
end
curUser:SendData(bot,msgfromtxt) readfrom()
end
Title:
Post by: RiPOFF on 13 December, 2003, 01:00:08
does this trigger if the command is in a senstence like: Hey dude type +help