PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: abyss on 20 December, 2004, 23:05:59

Title: topic changer
Post by: abyss on 20 December, 2004, 23:05:59
hoi have somebody a script for change the topic auto,
i seek a script they change the topic auto every 5 min and where i can put in 10 different topics.

hoi ik zoek een script die de topic verandert automatisch in door mij opgeven topic iedere 5 min ik dacht aan bv 10 verschillende topics wie weet wat

abyss :D
Title:
Post by: Herodes on 20 December, 2004, 23:56:44
sry it is late I havent tested at all ... if some one wants to make some input or this isnt what you want pls post further ...

--- Topico by Herodes
--- changes/ the topics .. every x minutes ...

bot_name="Topico"
refresh = 10 -- time in minutes that the Hub's topic will be refreshed/changed ...
tTopics = {
[0] = "First Topic",
[1] = "Second Topic",
[2] = "Third Topic",
}

---do not edit ..
cur_pointer = 0

function Main()
SetTimer(refresh*60000)
StartTimer()
end

function OnTimer()
Sendtopic()
Next()
end

function Next()
if cur_pointer == getn(tTopics) then  cur_pointer = 0
else  cur_pointer = cur_pointer + 1 end
end

function Sendtopic()
SendToAll("$HubName "..frmHub:GetHubName().." - "..tTopics[cur_pointer])
SentToAll(bot_name, "The hub's topic changed to "..tTopics[cur_pointer])
end

function DataArrival(user, data)
if (user.iProfile == 2) and (strsub(data, 1,1) == "<") then
data = strsub(data, 1, strlen(data)-1)
s,e,cmd,args = strfind(data, "$b<>%s+(%S+)%s*(%S*)")
if cmd == "!newtopic" then
if args and strlen(args) > 0 then
tTopic[getn(tTopic)+1] = args
user:SendData(bot_name, " Added new temporary topic : "..args)
else
user:SendData(bot_name, "Syntax Error! Use: !newtopic ")
end
elseif cmd == "!nextopic" then
Next()
Sendtopic()
end
end
end
Title:
Post by: Madman on 21 December, 2004, 22:37:03
Great script =)
2 probs tho...
This line need  to be change
SentToAll(bot_name, "The hub's topic changed to "..tTopics[cur_pointer])
to this...
SendToAll(bot_name, "The hub's topic changed to : "..tTopics[cur_pointer])
Just a small spelling error ;)

And the commands, i cant get to work at all
Title:
Post by: kepp on 22 December, 2004, 00:30:30
Bored..
--- Topico by Herodes
--- changes the topic .. every x minutes ...
--- Modified by kepp a little

-- Bot Name
bot_name="Topico"

-- time in minutes that the Hub's topic will be refreshed/changed
refresh = 10

-- Set pattern, etc : sPattern = " -- [ ", will show, Hubname -- [ Topic
sPattern = " -- [ ";

SendTopicChange = 0

-- Set Topics
tTopics = {
[0] = "First Topic",
[1] = "Second Topic",
[2] = "Third Topic",
}

---------------------------------------------------------------------------------
-- Restricted Area ;)
---------------------------------------------------------------------------------
cur_pointer = 0

function Main()
SetTimer(refresh*60000)
StartTimer()
end

function OnTimer()
Sendtopic()
ShiftTopic()
end

function DataArrival(user,data)
   if (strsub(data,1,1) == "<") then
      data = strsub(data,1,-2)
      local s,e,cmd = strfind(data,"^%b<>%s+(%S+)")
      if (strsub(cmd,1,1) == "!") then
         if (cmd == "!newtopic") then
            if (user.bOperator) then
               s,e,arg = strfind(data,"^%b<>%s+%S+%s+(.+)")
               if arg and strlen(arg) > 2 then
                  tinsert(tTopics,arg)
                  user:SendData(bot_name,"Temp topic was sucessfully added to temp list!")
                  return 1
               else
                  user:SendData(bot_name,"Please enter a topic!")
                  return 1
               end
            end
         end
      end
   end
end

function Sendtopic()
   local sTopic = tTopics[cur_pointer]
   if (SendTopicChange == 1) then
      SendToAll(bot_name,"The hubs topic were automatically changed to : "..sTopic)
   end
   SendToAll("$HubName "..frmHub:GetHubName()..sPattern..sTopic.."|")
end

function ShiftTopic()
   if (cur_pointer == getn(tTopics)) then cur_pointer = 0 end
   cur_pointer = cur_pointer + 1;
end

Title:
Post by: Madman on 22 December, 2004, 02:10:50
So.. I feelt like scripting a little =)
--- Topico by Herodes
--- changes the topic .. every x minutes ...
--- Modified by kepp a little
--- Madman also messed with the script

-- Bot Name
bot_name = "Topico"

-- time in minutes that the Hub's topic will be refreshed/changed
refresh = 10

-- Set pattern, etc : sPattern = " -- [ ", will show, Hubname -- [ Topic
-- if also sPatternInv = " ]", will show Hubname -- [ Topic ]
sPattern = " -- [ ";
sPatternInv = " ]";

-- Set to 1 if you want to send sPattern's
SendPattern = 1

-- Set to 1 if you want everybody to know that the topic was changed
SendTopicChange = 1

-- Set Topics
tTopics = {
[0] = "First Topic",
[1] = "Second Topic",
[2] = "Third Topic",
}

---------------------------------------------------------------------------------
-- Restricted Area ;)
---------------------------------------------------------------------------------
cur_pointer = 0

function Main()
SetTimer(refresh*60000)
StartTimer()
end

function OnTimer()
Sendtopic()
ShiftTopic()
end

function DataArrival(user,data)
if (strsub(data,1,1) == "<") then
data = strsub(data,1,-2)
local s,e,cmd = strfind(data,"^%b<>%s+(%S+)")
if (strsub(cmd,1,1) == "!") then
if (cmd == "!newtopic") then
if (user.bOperator) then
s,e,arg = strfind(data,"^%b<>%s+%S+%s+(.+)")
if arg and strlen(arg) > 2 then
tinsert(tTopics,arg)
user:SendData(bot_name,"Temp topic was sucessfully added to temp list!")
return 1
else
user:SendData(bot_name,"Please enter a topic!")
return 1
end
end
end
end
end
end

function Sendtopic()
local sTopic = tTopics[cur_pointer]
if SendPattern == 1 then
if (SendTopicChange == 1) then
SendToAll(bot_name,"The hubs topic were automatically changed to: "..sPattern..sTopic..sPatternInv)
end
SendToAll("$HubName "..frmHub:GetHubName().." - "..sPattern..sTopic..sPatternInv.."|")
elseif SendPattern == 0 then
if (SendTopicChange == 1) then
SendToAll(bot_name,"The hubs topic were automatically changed to: "..sTopic)
end
SendToAll("$HubName "..frmHub:GetHubName().." - "..sTopic.."|")
end
end

function ShiftTopic()
if (cur_pointer == getn(tTopics)) then cur_pointer = 0 end
cur_pointer = cur_pointer + 1;
end
Title:
Post by: kepp on 22 December, 2004, 14:49:58
Nice work madman!!

--- changes the topic .. every x minutes ...
--- Modified by kepp a little
--- Madman also messed with the script
--- Now gets uploaded to Public Hub List aswell ( kepp )
--- Added commands to stop / start the cycle ( kepp )
--- Changed the Pattern

-- Bot Name
bot_name = "Topico"

-- Set your hubname here
sHubname = "Sweden[Music-Heaven]"

-- time in minutes that the Hub's topic will be refreshed/changed
refresh = 10

-- Set pattern, [TOPIC] represent the topic :)
sPattern = " -- [ [TOPIC] ] --";

-- Set to 1 if you want to send sPattern
SendPattern = 1

-- Set to 1 if you want everybody to know that the topic was changed
SendTopicChange = 1

-- Automatically start topic cycle when scripts starts / restarts
AutoStart = 1

-- Set Topics
tTopics = {
   [0] = "First Topic",
   [1] = "Second Topic",
   [2] = "Third Topic",
}

---------------------------------------------------------------------------------
-- Restricted Area ;)
---------------------------------------------------------------------------------
cur_pointer = 0

function Main()
   if (AutoStart == 1) then
      SetTimer(refresh*60000)
      StartTimer()
   end
   frmHub:SetHubName(sHubname)
   SendToAll("$HubName "..sHubname.."|")
end

function OnTimer()
   Sendtopic()
   ShiftTopic()
end

function DataArrival(user,data)
   if (strsub(data,1,1) == "<") then
      data = strsub(data,1,-2)
      local s,e,cmd = strfind(data,"^%b<>%s+(%S+)")
      if (strsub(cmd,1,1) == "!") then
         if (cmd == "!newtopic") then
            if (user.bOperator) then
               s,e,arg = strfind(data,"^%b<>%s+%S+%s+(.+)")
               if arg and strlen(arg) > 2 then
                  tinsert(tTopics,arg)
                  user:SendData(bot_name,"Temp topic was sucessfully added to temp list!")
                  return 1
               else
                  user:SendData(bot_name,"Please enter a topic!")
                  return 1
               end
            end
         elseif (cmd == "!stopcycle") then
            if (user.bOperator) then
               StopTimer()
               SendToAll("$HubName "..sHubname.."|")
               frmHub:SetHubName(sHubname)
               user:SendData(bot_name,"The topic cycle has now stoped and hubname is back to default!")
               return 1
            end
         elseif (cmd == "!startcycle") then
            if (user.bOperator) then
               SetTimer(refresh*60000)
               StartTimer()
               user:SendData(bot_name,"The topic cycle is running!")
               return 1
            end
         end
      end
   end
end

function Sendtopic()
   if (SendPattern == 1) then
      sTopic = gsub(sPattern,"%[TOPIC]",tTopics[cur_pointer])
      SendToAll("$HubName "..sHubname..sTopic.."|")
      frmHub:SetHubName(sHubname..sTopic.."|")
      if (SendTopicChange == 1) then
         SendToAll(bot_name,"The hubs topic were automatically changed to: "..sTopic)
      end
   elseif (SendPattern == 0) then
      sTopic = tTopics[cur_pointer]
      SendToAll("$HubName "..frmHub:GetHubName().." - "..sTopic.."|")
      frmHub:SetHubName(sHubname.." - "..sTopic.."|")
      if (SendTopicChange == 1) then
         SendToAll(bot_name,"The hubs topic were automatically changed to: "..sTopic)
      end
   end
end

function ShiftTopic()
   if (cur_pointer == getn(tTopics)) then cur_pointer = 0 end
   cur_pointer = cur_pointer + 1;
end

Keep going :)
Title:
Post by: abyss on 22 December, 2004, 20:20:00
k thank to all for this script  :]  :]  :]
Title:
Post by: abyss on 22 December, 2004, 20:43:41
hy gives this  error

Syntax error: function arguments expected;
  last token read: `=' at line 13 in file

i can not find the error  X(

abyss
Title:
Post by: kepp on 23 December, 2004, 20:48:19
--- Topico by Herodes
--- changes the topic .. every x minutes ...
--- Modified by kepp a little
--- Madman also messed with the script
--- Now gets uploaded to Public Hub List aswell ( kepp )
--- Added commands to stop / start the cycle ( kepp )
--- Changed the Pattern

-- Bot Name
bot_name = "Topico"

-- Set your hubname here
sHubname = "Sweden[Music-Heaven]"

-- time in minutes that the Hub's topic will be refreshed/changed
refresh = 10

-- Set pattern, [TOPIC] represent the topic :)
sPattern = " -- [ [TOPIC] ] --"

-- Set to 1 if you want to send sPattern
SendPattern = 1

-- Set to 1 if you want everybody to know that the topic was changed
SendTopicChange = 1

-- Automatically start topic cycle when scripts starts / restarts
AutoStart = 1

-- Set Topics
tTopics = {
   [0] = "First Topic",
   [1] = "Second Topic",
   [2] = "Third Topic",
}

---------------------------------------------------------------------------------
-- Restricted Area ;)
---------------------------------------------------------------------------------
cur_pointer = 0

function Main()
   if (AutoStart == 1) then
      SetTimer(refresh*60000)
      StartTimer()
   end
   frmHub:SetHubName(sHubname)
   SendToAll("$HubName "..sHubname.."|")
end

function OnTimer()
   Sendtopic()
   ShiftTopic()
end

function DataArrival(user,data)
   if (strsub(data,1,1) == "<") then
      data = strsub(data,1,-2)
      local s,e,cmd = strfind(data,"^%b<>%s+(%S+)")
      if (strsub(cmd,1,1) == "!") then
         if (cmd == "!newtopic") then
            if (user.bOperator) then
               s,e,arg = strfind(data,"^%b<>%s+%S+%s+(.+)")
               if arg and strlen(arg) > 2 then
                  tinsert(tTopics,arg)
                  user:SendData(bot_name,"Temp topic was sucessfully added to temp list!")
                  return 1
               else
                  user:SendData(bot_name,"Please enter a topic!")
                  return 1
               end
            end
         elseif (cmd == "!stopcycle") then
            if (user.bOperator) then
               StopTimer()
               SendToAll("$HubName "..sHubname.."|")
               frmHub:SetHubName(sHubname)
               user:SendData(bot_name,"The topic cycle has now stoped and hubname is back to default!")
               return 1
            end
         elseif (cmd == "!startcycle") then
            if (user.bOperator) then
               SetTimer(refresh*60000)
               StartTimer()
               user:SendData(bot_name,"The topic cycle is running!")
               return 1
            end
         end
      end
   end
end

function Sendtopic()
   if (SendPattern == 1) then
      sTopic = gsub(sPattern,"%[TOPIC]",tTopics[cur_pointer])
      SendToAll("$HubName "..sHubname..sTopic.."|")
      frmHub:SetHubName(sHubname..sTopic)
      if (SendTopicChange == 1) then
         SendToAll(bot_name,"The hubs topic were automatically changed to: "..sTopic)
      end
   elseif (SendPattern == 0) then
      sTopic = tTopics[cur_pointer]
      SendToAll("$HubName "..frmHub:GetHubName().." - "..sTopic.."|")
      frmHub:SetHubName(sHubname.." - "..sTopic)
      if (SendTopicChange == 1) then
         SendToAll(bot_name,"The hubs topic were automatically changed to: "..sTopic)
      end
   end
end

function ShiftTopic()
   if (cur_pointer == getn(tTopics)) then cur_pointer = 0 end
   cur_pointer = cur_pointer + 1;
end


The error you descrive must be in another script you are using.. But hey, i found another problem and is fixed!