Yup, just as the Topic say.... i made a script that send a messeage in the Main Chat the Topic has been changed by
Why? Well beacuse i wanted the user to know that we changed the Topic :p
--//Made by Madman
Bot = "-=Destruction=-"
--// This function is fired at the serving start
function Main()
frmHub:RegBot(Bot)
end
--// This function is fired when a new data arrives
function DataArrival(curUser,data)
if strsub(data, 1, 1) == "<" then
data=strsub(data,1,strlen(data)-1)
s,e,cmd = strfind(data,"%b<>%s+(%S+)")
if GetProfileName(curUser.iProfile) == "Operator" then
if cmd == "!topic" then
SendToAll(Bot, "The Topic has been changed by "..curUser.sName.." ")
end
else if GetProfileName(curUser.iProfile) == "Master" then
if cmd == "!topic" then
SendToAll(Bot, "The Topic has been changed by "..curUser.sName.." ")
end
end
end
end
end
hi, how about upon !topic off , the topic has been cleared by
why not use
if cmd == "!topic" and curUser.bOperator then
that saves you a command :o)
keep it up ;o)
impressive, thanks.
--//Topic Change Notification Bot Made By Madman
--//Rewriten And Updated
--//Based On A Script From Phatty
--//Also Thanks To enema For The The Help
--//Thanks To bastya_elvtars For The Save Function
--//Skipped dofile, It Gives Error On Script Restart
Bot = "TopicBot"
function DataArrival(curUser, data)
if (strsub(data,1,1) == "<") then
data=strsub(data,1,strlen(data)-1)
s,e,cmd = strfind(data, "%b<>%s+(%S+)")
if cmd == "!showtopic" then ReadTopic(curUser) end
if curUser.bOperator then
local s,e,cmd,Topic = strfind(data,"%b<>%s+(%S+)%s+(.+)")
if cmd == "!topic" then
if Topic == "off" then
SendToAll(Bot, curUser.sName.." deleted the topic")
else
SendToAll(Bot, curUser.sName.." changed the topic to: "..Topic)
Topic2Save = Topic
SaveTopic()
end
end
end
end
end
function SaveTopic()
writeto("Topic.ini")
if Topic2Save then
write("The Topic is: "..Topic2Save)
else
write("Could not find the Topic")
end
writeto()
end
function ReadTopic(curUser)
readfrom("Topic.ini")
local line = read("*a")
curUser:SendData(Bot, line)
readfrom()
end
It was a while since i made that script... but anyway..
I got some time over and i finnaly made an update...
Rember this is only for 330....
TD X dont have a !topic command
function SaveTopic()
writeto("Topic.ini")
if Topic2Save then
write("topic= "..Topic2Save)
else
write("topic=nil")
end
writeto()
end
this will save a lua file and can be safely dofiled. :)
--//Topic Change Notification Bot Made By Madman
--//Rewriten And Updated
--//Based On A Script From Phatty
--//Also Thanks To enema For The The Help
--//Thanks To bastya_elvtars For The Save Function
--//Skipped dofile, It Gives Error On Script Restart
--//Added Custom File..
Bot = "TopicBot"
File = "Topic.ini"
function DataArrival(curUser, data)
if (strsub(data,1,1) == "<") then
data=strsub(data,1,strlen(data)-1)
s,e,cmd = strfind(data, "%b<>%s+(%S+)")
if cmd == "!showtopic" then ReadTopic(curUser) end
if curUser.bOperator then
local s,e,cmd,Topic = strfind(data,"%b<>%s+(%S+)%s+(.+)")
if cmd == "!topic" then --//The Command PtokaX Uses
if Topic == "off" then --//So It Wont Send Changed Teext When Turning It Of
SendToAll(Bot, curUser.sName.." deleted the topic") --//Send If Cmd == !topic off
else
SendToAll(Bot, curUser.sName.." changed the topic to: "..Topic)
Topic2Save = Topic --//"Convert" For SaveTopic()
SaveTopic()
end
end
end
end
end
function SaveTopic()
writeto(File) --//Save The File
if Topic2Save then
write("The Topic is: "..Topic2Save) --//How To Save It
else
write("Could not find the Topic") --//Couldnt Find Topic2Save
end
writeto()
end
function ReadTopic(curUser)
readfrom(File) --//Read The file
local line = read("*a") --//Read Whats In File
curUser:SendData(Bot, line) --//Send It To User
readfrom()
end
Update..
To Bastya
I know if i write "topic= "..Topic2Save it can be dofiled...
but when i use the !showtopic command
it will say something like
Topic="-=Topic=-"
witch i dont want it to say... it sholdnt say Topic=
Thats why i skipped the dofile...
beacuse if i saved it like i do now it gave me an error on script restart...
if you cal a dofile on it, no need 4 readtopic
basically my routine saves it as a lua file, which is executed by dofile().
No need 4 ReadTopic?
But how then are the users suppose to view the topic?
They type !showtopic and they will see the Topic in main...
I dont really see how a dofile can do that?
my save saves topic as a lua-syntaxed file... dofile just executes it, its only needed when ya shut down the hub.