PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: Devastator on 13 January, 2004, 19:56:43

Title: Lookin 4 1 script where u can add n delete
Post by: Devastator on 13 January, 2004, 19:56:43
Hi,

i was lookin 4 a script where u can add n delete entries.

i want it so its like a timetable, i want it 2 b 4 radio timings. wondered if n e 1 could help

i wanted it summat like...


Date Time Who Length Rating (Done After Show)

<13-11-03> 1900 - 2100     DJ Blah Blah         2 Hours 6/10




also a command so it can be removed.......i jus want it as 1 seperate script if it can be done plz let me know!

thank u

Devastator
Title:
Post by: raz on 13 January, 2004, 21:50:02
u can use a read txt file script at the moment unless 1 of the scripterz make u 1. i think chilla is more experierenced in this type of stuff. it would be like the fresh stuff script.lol :D
Title:
Post by: Devastator on 13 January, 2004, 23:52:45
yea i know the fresh stuff script is like this but that script adds manee categories.

i would like it so its just one script where u can add delete and its set out as like a timetable and i want the command to be sumthing like +radio so it comes up in pm.

thanx a lot!

Devastator
Title:
Post by: plop on 14 January, 2004, 04:27:05
have you tryed freshstuff 30./3.2 ???
doesn't have the rathing but 3.2 is easy 2 mod so it only supports 1 catagory.

plop
Title:
Post by: plop on 19 January, 2004, 20:03:41
your modded version of freshstuff 3.3.
tell me if it suits your needs.
-- FreshStuff v.3.3
-- original idea/script by chilla
-- completely rewriten by plop
-- if you were running 3.0 then you gotta delete the old file
-- it's incompatible with this version
-- deleting now goes by id number

-- Name the commands to what U like
-- This command adds stuff, syntax : +addalbum TYPE/CATAGORY THESTUFF2ADD
cmd1 = "+addalbum"

-- This command shows the stuff, syntax : +albums with options new/game/warez/music/movie
cmd2 = "+albums"

-- This command deletes an entry, syntax : +delalbum THESTUFF2DELETE
cmd3 = "+delalbum"

-- This command shows the latest stuff, syntax : +newalbums
cmd4 = "+newalbums"

-- This command reloads the txt file. syntax : +reloadalbums
-- (this command is needed if you manualy edit the text file)
cmd5 = "+reloadalbums"

-- Show latest stuff on entry 1=yes, 0=no
ShowOnEntry = 0

-- Max stuff shown on newalbums/entry
MaxNew = 20

-- The file storing the stuff
file = "txt/AlbumsAll.txt"

-- Name of the bot
Bot = "post-it_memo"

-- you can add catagory's yourself ["trigger_name"]="catagory_name"
Types = {["movie"] = "Movies", ["music"]="Music", ["warez"]="Warez", ["game"]="Games"}

--------------------- don't change anything below here
AllStuff = {}
NewestStuff = {}

function Main()
   frmHub:RegBot(Bot)
   ReloadRel()
end

function NewUserConnected(user)
   if ShowOnEntry == 1 then
      user:SendPM(Bot, MsgNew.."|")
   end
end

function OpConnected(user)
   if ShowOnEntry == 1 then
      user:SendPM(Bot, MsgNew.."|")
   end
end

function DataArrival(user,data)
   if (strsub(data, 1, 1) == "<") then
      data = strsub(data,1,strlen(data)-1)
      s,e,cmd,type,tune = strfind(data, "%b<>%s+(%S+)%s*(%S*)%s*(.*)")
      if cmd == cmd2 then
         if type == "" then
            user:SendPM(Bot, MsgAll.."|")
         elseif type == "new" then
            user:SendPM(Bot, MsgNew.."|")
         elseif Types[type] then
            ShowRelType(type)
            user:SendPM(Bot, MsgType.."|")
         end
         return 1
      elseif cmd == cmd4 then
         user:SendPM(Bot, MsgNew.."|")
         return 1
      elseif user.bOperator then
         if cmd == cmd3 then
            if type ~= "" then
               DelRel(user, type)
            else
               user:SendData(Bot, "yea right, like i know what i got 2 delete when you don't tell me!|")
            end
            return 1
         elseif cmd == cmd1 then
            if tune ~= "" and Types[type] then
               AddRel(user, tune, type)
            elseif Types[type] == nil then
               user:SendData(Bot, "I need to know the catagory to add it to!|")
            else
               user:SendData(Bot, "yea right, like i know what you got 2 add when you don't tell me!|")
            end
            return 1
         elseif cmd == cmd5 then
            Reload()
            user:SendData(Bot, "Radio Times reloaded!|")
            return 1
         end
      end
   end
end

function OpenRel()
   AllStuff = nil
   NewestStuff = nil
   AllStuff = {}
   NewestStuff = {}
   Count = 0
   Count2 = 0
   readfrom(file)
   while 1 do
      local line = read()
      if ( line == nil ) then
         break
      else
         Count = Count +1
         AllStuff[Count]=line
      end
   end
   readfrom()
   if Count > MaxNew then
      local temp = Count - MaxNew + 1
      for i=temp, Count do
         Count2 = Count2 + 1
         NewestStuff[Count2]=AllStuff[i]
      end
   else
      for i=1, Count do
         Count2 = Count2 + 1
         NewestStuff[Count2]=AllStuff[i]
      end
   end
end

function ShowRel(table)
   Msg = "\r\n"
   if table == NewestStuff then
      if Count2 == 0 then
         MsgNew = "\r\n\r\n".." --------- The Latest Radio Times -------- \r\n\r\n  No Radio Times on the list yet\r\n\r\n --------- The Latest Radio Times -------- \r\n\r\n"
      else
         for i=1, Count2 do
            s,e,type,who,when,title=strfind(NewestStuff[i], "(.+)$(.+)$(.+)$(.+)")
            if title then
               Msg = Msg.."  "..when.." -- "..who.." -- "..type.." -- "..title.."\r\n"
            else
               Msg = Msg..NewestStuff[i].."\r\n"
            end
         end
         MsgNew = "\r\n\r\n".." --------- The Latest "..MaxNew.." Radio Times -------- "..Msg.."\r\n --------- The Latest "..MaxNew.."  Radio Times -------- \r\n\r\n"
      end
   else
      if Count == 0 then
         MsgAll = "\r\n\r\r\n".." --------- All The Radio Times -------- \r\n\r\n  No Radio Times on the list yet\r\n\r\n --------- All The Radio Times -------- \r\n\r\n"
      else
         MsgHelp = "  use "..cmd2.."          for a,b in Types do
            MsgHelp = MsgHelp.."/"..a
         end
         MsgHelp = MsgHelp.."> to see only the selected types"
         for i=1, Count do
            s,e,type,who,when,title=strfind(AllStuff[i], "(.+)$(.+)$(.+)$(.+)")
            if title then
               Msg = Msg.."  ID: "..i.." -- "..when.." -- "..who.." -- "..type.." -- "..title.."\r\n"
            else
               Msg = Msg..AllStuff[i].."\r\n"
            end
         end
         MsgAll = "\r\n\r\r\n".." --------- All The Radio Times -------- "..Msg.."\r\n --------- All The Radio Times -------- \r\n"..MsgHelp.."\r\n"
      end
   end
end

function ShowRelType(what)
   Msg = "\r\n"
   tmp = 0
   if Count == 0 then
      MsgType = "\r\n\r\n".." --------- All The "..Types[what].." -------- \r\n\r\n  No "..strlower(Types[what]).." yet\r\n\r\n --------- All The "..Types[what].." -------- \r\n\r\n"
   else
      for i=1, Count do
         s,e,type,who,when,title=strfind(AllStuff[i], "(.+)$(.+)$(.+)$(.+)")
         if type == what then
            tmp = tmp + 1
            Msg = Msg.."  "..when.." -- "..who.." -- "..title.."\r\n"
         end
      end
      if tmp == 0 then
         MsgType = "\r\n\r\n".." --------- All The "..Types[what].." -------- \r\n\r\n  No "..strlower(Types[what]).." yet\r\n\r\n --------- All The "..Types[what].." -------- \r\n\r\n"
      else
         MsgType= "\r\n\r\n".." --------- All The "..Types[what].." -------- \r\n"..Msg.."\r\n --------- All The "..Types[what].." -------- \r\n\r\n"
      end
   end
end

function AddRel(user, what, type)
   Count = Count + 1
   AllStuff[Count]=(type.."$"..user.sName.."$"..date("%x").."$"..what)
   user:SendData(Bot, what.." is added to the Radio Times as "..type.."|")
   SaveRel()
   ReloadRel()
end

function DelRel(user, what)
   if tonumber(what) then
      what = tonumber(what)
      if AllStuff[what] then
         local s,e,which=strfind(AllStuff[what], "([^%$]+)$")
         user:SendData(Bot, which.." is deleted from the Radio Times|")
         AllStuff[what]=nil
         SaveRel()
         ReloadRel()
      else
         user:SendData(Bot, what.." wasn't found in the Radio Times|")
      end
   else
      user:SendData(Bot, "I need the ID number to delete a Radio Time|")
   end
end

function SaveRel()
   writeto(file)
   for i=1,Count do
      if AllStuff[i] then
         write(AllStuff[i].."\n")
      end
   end
   writeto()
end

function ReloadRel()
   OpenRel()
   ShowRel(NewestStuff)
   ShowRel(AllStuff)
end
plop
Title:
Post by: Devastator on 19 January, 2004, 20:09:51
Thanx a lot m8........now these are the sorts of reason y plop should b mod......thanx a lot i will b tryin this out asap! =D

sum1 give us wat we want!

we want plop as mod!!!

and i am quite sure manee ppl would love 2 see this!

thanx a lot once agen m8....veri veri helpful!

Devastator
Title:
Post by: plop on 19 January, 2004, 20:22:30
QuoteOriginally posted by Devastator
Thanx a lot m8........now these are the sorts of reason y plop should b mod......thanx a lot i will b tryin this out asap! =D

sum1 give us wat we want!

we want plop as mod!!!

and i am quite sure manee ppl would love 2 see this!

thanx a lot once agen m8....veri veri helpful!

Devastator
yw and thx for the compliments.

dc is about sharing of not only files but also knowledge.
best compliment i can get is seeing ppl use my scripts and enjoying them.

plop