PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: Millsy on 12 January, 2004, 00:07:52

Title: Please
Post by: Millsy on 12 January, 2004, 00:07:52
a simple script so that only ops can run +ophelp and +Ad ect ect if any 1 else types it it will say only ops can run this command

thanks
Millsy
Title:
Post by: plop on 12 January, 2004, 01:00:03
QuoteOriginally posted by Millsy
a simple script so that only ops can run +ophelp and +Ad ect ect if any 1 else types it it will say only ops can run this command

thanks
Millsy
jonny 5 needs more input. lol
i can gues what +ophelp does as i have a command like it in my bot.
but what does +ad do???
be as precise as posible on what your requested script must do, that can only make us help you better.
thx

plop
Title:
Post by: Millsy on 12 January, 2004, 20:47:33
what i would like is a stand alone script that i can put all the +commands my hub has in and say if there for ops, vips, users

thanks 4 the help
Millsy
Title:
Post by: plop on 12 January, 2004, 21:59:42
something like this maby??
it can show 2 text files, 1 for op/master level and 1 for all levels.
-- texter bot by plop
-- modified 2 show only 2 files, 1 for ops/masters, 1 for all.
-- thx 2 chilla for the faster routine for opening the files
-- shows text files from a folder named text.


Bot = "something"

FDFolder = "text"

cmd1 = "+ophelp"
file1 = "ophelp.txt"

cmd2 = "+ad"
file2 = "ad.txt"

function Main()
   frmHub:RegBot(Bot)
end

function DataArrival(user, data)
   data=strsub(data,1,strlen(data)-1)
   if( strsub(data, 1, 1) == "<" ) then
      s,e,cmd = strfind(data,"%b<>%s+(%S+)")
      if cmd == cmd2 then
         showtext(user, file2)
         return 1
      elseif cmd == cmd1 and user.iProfile <=1 then
         showtext(user, file1)
         return 1
      end
   elseif(strsub(data, 1, 4) == "$To:") then
      s,e,cmd = strfind(data,"$To:%s+%S+%s+From:%s+%S+%s+$%b<>%s+(%S+)")
      if cmd == cmd2 then
         showtext(user, file2)
         return 1
      elseif cmd == cmd1 and user.iProfile <=1 then
         showtext(user, file1)
         return 1
      end
   end
end

function showtext(user, file)
local handle = openfile(FDFolder.."/"..file..".txt", "r")
local contents = gsub(read(handle, "*a"),strchar(10), "\r\n")
closefile (handle)
user:SendPM(Bot, "\r\n"..contents.."\r\n|")
end

plop
Title:
Post by: Millsy on 12 January, 2004, 22:10:15
can u not just have a have a script where u put someting like this

+ophelp (op)(PM)
ophekp.txt

+help (user)(PM)
help.txt

+ad (master,op)(PM)
ad.txt

+masterhelp (master)(PM)
+masterhelp.txt

+viphelp (vip)(PM)
viphelp.txt

+hubinfo(Master)(main)
hubinfo.txt

and so on

and pm or in main chat so u can have +hubinfo that only ops can run but shows in main chat to every 1

Thanks
Millsy
Title:
Post by: plop on 13 January, 2004, 17:25:18
ok like this you mean.
-- texter bot by plop
-- modified 2 show only 6 files,
-- thx 2 chilla for the faster routine for opening the files
-- shows text files from a folder named text.


Bot = "something"

FDFolder = "text"

cmd1 = "+ophelp"
file1 = "ophelp.txt"

cmd2 = "+ad"
file2 = "ad.txt"

cmd3 = "+help"
file3 = "help.txt"

cmd4 = "+masterhelp"
file4 = "masterhelp.txt"

cmd5 = "+viphelp"
file5 = "viphelp.txt"

cmd6 = "+hubinfo"
file6 = "hubinfo.txt"


function Main()
   frmHub:RegBot(Bot)
end

function DataArrival(user, data)
   data=strsub(data,1,strlen(data)-1)
   if( strsub(data, 1, 1) == "<" ) then
      s,e,cmd = strfind(data,"%b<>%s+(%S+)")
      if cmd == cmd2 then
         showtext(user, file2)
         return 1
      elseif cmd == cmd1 and user.iProfile ==1 then
         showtext(user, file1)
         return 1
      elseif cmd == cmd3 and (user.iProfile ==3 or user.iProfile ==-1) then
         showtext(user, file3)
         return 1
      elseif cmd == cmd4 and user.iProfile ==0 then
         showtext(user, file4)
         return 1
      elseif cmd == cmd5 and user.iProfile ==2 then
         showtext(user, file5)
         return 1
      elseif cmd == cmd6 and user.iProfile ==0 then
         showtextmain(user, file6)
         return 1
      end
   elseif(strsub(data, 1, 4) == "$To:") then
      s,e,cmd = strfind(data,"$To:%s+%S+%s+From:%s+%S+%s+$%b<>%s+(%S+)")
      if cmd == cmd2 then
         showtext(user, file2)
         return 1
      elseif cmd == cmd1 and user.iProfile ==1 then
         showtext(user, file1)
         return 1
      elseif cmd == cmd3 and (user.iProfile ==3 or user.iProfile ==-1) then
         showtext(user, file3)
         return 1
      elseif cmd == cmd4 and user.iProfile ==0 then
         showtext(user, file4)
         return 1
      elseif cmd == cmd5 and user.iProfile ==2 then
         showtext(user, file5)
         return 1
      elseif cmd == cmd6 and user.iProfile ==0 then
         showtextmain(user, file6)
         return 1
      end
   end
end

function showtext(user, file)
local handle = openfile(FDFolder.."/"..file..".txt", "r")
local contents = gsub(read(handle, "*a"),strchar(10), "\r\n")
closefile (handle)
user:SendPM(Bot, "\r\n"..contents.."\r\n|")
end

function showtextmain(user, file)
local handle = openfile(FDFolder.."/"..file..".txt", "r")
local contents = gsub(read(handle, "*a"),strchar(10), "\r\n")
closefile (handle)
SendToAll(Bot, "\r\n"..contents.."\r\n|")
end
if you look closely you can see how you can add even more  files easely yourself.
you just have 2 add more cmd# and file#, copy paste the lines from dataarrival and set the level numbers you want 2 be able 2 use the command.

plop
Title:
Post by: c h i l l a on 13 January, 2004, 17:30:49
what about a table like


cmds = {

[tostring(cmd1)] = { file1,0 },

}

where 0 is the profile type and such.
Title:
Post by: plop on 13 January, 2004, 17:53:40
QuoteOriginally posted by c h i l l a
what about a table like


cmds = {

[tostring(cmd1)] = { file1,0 },

}

where 0 is the profile type and such.
could have done that, but this is easyer 2 understand if your new 2 lua.
have seen couple hub owners totaly loose there way on tables like that.
maby next time do, and have function Main() build the table for them.
would be even nicer 2 have a config file 2 handle it all.
cmdtrigger|filename|level
like that.
then it's a piece of cake 2 add things.

plop
Title:
Post by: Millsy on 13 January, 2004, 22:45:51
looks good ill give it a try

Thanks,
Millsy
Title:
Post by: Millsy on 15 February, 2004, 18:47:05
can someone one please make this script for me plz
////////////   C = Command
////////////   F = File
////////////   W = Who Can Run The Command
////////////   D = Where Its Displayed (PM Or Main Chat To Everyone)
////////////   AR = Auto Run On Entry To Hub
////////////   ARD = Where Auto Run Is Displayed (PM Or Main Chat Just To Them)
////////////   

this table is in this order
c
f
w
d
ar
ard

1.Ads   
   +ad1      -   ad1.txt      -   Ops / Master   -   Main Chat      -   Off   -   Off
   +ad2      -   ad2.txt      -   Ops / Master   -   Main Chat      -   Off   -   Off
   +ad3      -   ad3.txt      -   Ops / Master   -   Main Chat      -   Off   -   Off
   +ad4      -   ad4.txt      -   Ops / Master   -   Main Chat      -   Off   -   Off
   +ad5      -   ad5.txt      -   Ops / Master   -   Main Chat      -   Off   -   Off

2.Rules
   +rules      -   rules.txt      -   Anyone      -   PM      -   Off   -   Off
   +mrules      -   rules.txt      -   Ops / Masters   -   Main Chat      -   Off   -   Off
   +oprules      -   oprules.txt   -   Ops / Masters   -   PM      -   Off   -   Off

3.Help
   +help      -   help.txt      -   Anyone      -   PM      -   Off   -   Off
   +mhelp      -   help.txt      -   Ops / Masters   -   Main Chat      -   Off   -   Off
   +ophelp      -   ophelp.txt      -   Ops / Masters   -   PM      -   Off   -   Off
   +masterhelp   -   masterhelp.txt   -   Masters      -   PM      -   Off   -   Off

4.Other
   +opnotes      -   opnotes.txt   -   Ops / Masters   -   PM      -   Off   -   Off
   +hubinfo      -   hubinfo.txt   -   Anyone      -   PM      -   Off   -   Off
   +mhubinfo   -   hubinfo.txt   -   Ops / Masters   -   Main Chat      -   Off   -   Off
   +ops      -   ops.txt      -   Anyone      -   PM      -   Off   -   Off
   +mops      -   ops.txt      -   Ops / Masters   -   Main Chat      -   Off   -   Off
   +popup      -   popup.txt      -   Masters      -   Main Chat      -   On   -   PM
   +hubstats   -   hubstats.txt   -   Masters      -   Main Chat      -   On   -   Main Chat


   ///////////////////////////////////////////////////////////////////////////////////////////////////                     Notes                    ///////////////////////////////////////////////////////////////////////////////////////////////////
            
      If Someone Types A Command There Not Allowd To Run They Get "Only (Who Ever) Can Run This Command"
      
      For Commands To Work With Both + And !
      
      To Generate A Text File That Looks Like (See Up) And A Command Like +allcommands That Only Masters Can Run
      
      
                     !!!!!     Think This Will Happen Anyway     !!!!!
      
      Master Must Be Able To Run All Commands
      
      Command Not To Be Shown In Main Chat When Run
      
      Not To Run When Talking To Someone "Please Read The Rules By Typing +Rules"
      
      If A Op Or Master Runs A Command To Show In Main Chat It Display The File From (Bot Name) Not The Op Or Master Who Runs It
      
   ///////////////////////////////////////////////////////////////////////////////////////////////////                      End                     ///////////////////////////////////////////////////////////////////////////////////////////////////