PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: Ubikk on 17 January, 2005, 21:28:23

Title: !deop function + combining scripts
Post by: Ubikk on 17 January, 2005, 21:28:23
Hey guys.
First of all I need a script with !deop command.
PtokaX is really weird. It has an !op command, but not an !deop one. Anyway, I really need this command, because on my hub I have lots of temporary ops and I would to remove their op acces without kick them or making them reconnect.

Second of all I would really need to know how to combine little scripts into bigger ones.
Here are some of my scripts. They're very little and I would apreciata if someone would teach me how to combine them

QuoteBot = "robotzel"
counter = 1

function DataArrival(user, data)
   if ( strsub(data, 1, 1) == "<" ) then
      if curname then
         if curname == user.sName then
            counter = counter + 1
            if counter >= 12 then
               SendToAll(Bot, user.sName..", vorbesti singur(a) ? :)")
               counter = 1
            end
         else
            curname = user.sName
            counter = 1
         end
      else
         curname = user.sName
         counter = 1
      end
   end
end








---------------------------------------------------


Here is the second script:





function DataArrival(user, data)
   data=strsub(data,1,strlen(data)-1)
   s,e,cmd,arg = strfind(data,"%b<>%s+(%S+)%s+(%S+)")
   if (cmd=="!kiss") then
      if not (arg==nil) then
         local tmp = GetItemByName(arg)
         if (tmp==nil) then
            SendToAll(""..user.sName.." tries to kiss   "..arg..", but he/she smakes them in the head!")
         end
         if not (tmp==nil) then
            SendToAll("***"..user.sName.." kisses "..arg.." and they start blushing :)")
         end
         return 1
      end
   end
end




---------------------------------------------------


The 3rd one:



botname="kiss"

function DataArrival(user, data)
   data=strsub(data,1,strlen(data)-1)
   s,e,cmd,arg = strfind(data,"%b<>%s+(%S+)%s+(%S+)")
   if (cmd=="!love") then
      if not (arg==nil) then
         local tmp = GetItemByName(arg)
         if (tmp==nil) then
            SendToAll(""..user.sName.." tries to make love but   "..arg..",  smakes them in the head!")
         end
         if not (tmp==nil) then
            SendToAll("***"..user.sName.." is making love to  "..arg.." and they are screeming!! :)")
         end
         return 1
      end
   end
end








------------------------------------------------


The 4th one:



botname="robotzel"

function DataArrival(user, data)
   data=strsub(data,1,strlen(data)-1)
   s,e,cmd,arg = strfind(data,"%b<>%s+(%S+)%s+(%S+)")
   if (cmd=="!slap") then
      if not (arg==nil) then
         local tmp = GetItemByName(arg)
         if (tmp==nil) then
            SendToAll("***"..user.sName.." slaps "..arg.." with love ... :)")
         end
         if not (tmp==nil) then
            SendToAll("***"..user.sName.." slaps "..arg.." a bit with a large trout")
         end
         return 1
      end
   end
end






------------------------------------------------------------------------



The 5th one:



--ScreenCleaner.lua 1.1 by yepyepyep4711 and Hawk
--!cls will wipe the main chat clean (does that remind you of something? ;) )
--the command will be added to the rightclick menu of the OPs (optional)



botname = "robotzel"

rightclick = 0 -- if anything else than 1 rightclick menu won't appear

function DataArrival (curUser, sData)
command=strsub(sData,1,strlen(sData)-1)
s,e,cmd = strfind(command,"%b<>%s+(%S+)")
   if curUser.bOperator then
      if cmd=="!cls" then
         temp = "\r\n"
         for i=1,200,1 do
            temp = temp.."\r\n"
         end
         SendToAll(botname, temp)
      end
   end
end



function OpConnected(curUser)
   if rightclick == 1 then
      curUser:SendData("$UserCommand 255 7")
      curUser:SendData("$UserCommand 0 3")
      curUser:SendData("$UserCommand 1 2 Clear Screen$<%[mynick]> !cls|")
   end
end




-----------------------------------------------------------

These are just few of my scripts. The thing is I would like to combine all of my scripts into 3-4 big ones :)
Is that possible? :D
Title:
Post by: Madman on 18 January, 2005, 09:36:47
hopefully i understood you right, and you wanted 2 join thoose 5 script in to 1

Here is a Little guide

Quote---- Combined
-- Start by making the 5th one into same scripting way..
-- curUser changed 2 user
-- sData changed 2 data
-- command=strsub(data,1,strlen(data)-1) changed to data=strsub(data,1,strlen(data)-1)
-- s,e,cmd = strfind(command,"%b<>%s+(%S+)") changed 2 s,e,cmd = strfind(data,"%b<>%s+(%S+)")

---- Combined2
-- Now lets remove all Unnessacery botnames
-- left is the Bot in the 1st script, to make it simple, let change that 2 botname

---- Combined3
-- Lets move all DataArrivals togheter
-- And rightclick = 1 we can put under botname = "robotzel" and counter = 1

---- Combined4
-- Lets put the 2 lines in teh 5th script we replaced 2 the first script
-- Now... Lets Join the DataArrivals togheter
-- Everyting between function DataArrival(user, data) and the last end in the script should be moved

---- Combined5
-- All left over DataArrivals can be deleted
-- remove all data=strsub(data,1,strlen(data)-1) eccept the first one
-- on every "s,e,cmd,arg = " line lets add local
-- meaning --> local s,e,cmd,arg =
-- move all "local s,e,cmd,arg = " to, under the " if cmd == "! " lines
-- Remove all "The 3rd one: " lines...
-- Start PX... And no Script error should be...

Click here to get the files i edited (http://destruction.myftp.org/filer/dc/Lua%20Board/Combined.rar)

Hope it helps..
Now i'm of 2 my school... =)

As for the !deop i have no idea how that works....