PtokaX forum

Archive => Archived 4.0 boards => Finished Lua 4 scripts => Topic started by: plop on 29 April, 2004, 22:43:38

Title: Code Board
Post by: plop on 29 April, 2004, 22:43:38
i made this script for my own hub so posting codes doesn't mess up the chat.
but a couple ppl allready asked for it so lets make it avail for everybody.
simple but effective.
-- code board by plop
-- made for my own hub to seperate chat from code

Bot = "Code_Board"

function Main()
   frmHub:RegBot(Bot)
end

function DataArrival(user, data)
   if(strsub(data, 1, 4) == "$To:") then
      local s,e,whoTo = strfind(data,"$To:%s+(%S+)")
      if whoTo == Bot then
         data=strsub(data,1,strlen(data)-1)
         local s,e,text = strfind(data, "%$%b<>(.*)")
         if text ~= "" then
            local line = "\r\nCode by: "..user.sName.."\r\n--------------------------------------------------------------------------------------------------------------------------------\r\n"
            line = line..text.."\r\n--------------------------------------------------------------------------------------------------------------------------------\r\n"
            SendPmToAll(Bot, line.."|")
         end
      end
   end
end
plop
Title:
Post by: bastya_elvtars on 30 May, 2004, 19:09:52
Can it b done that it ignores away messages? I use it for important info purposes ---> having full of away messages kinda annoying :)
Title:
Post by: [NL]trucker on 01 June, 2004, 09:32:51
Plop

could you make it also so that it doesnt show that what you have typed 2x?

now it shows that what you,ve typed above the lines and it shows the same message between the lines.

and yes i know the only one who sees 2x the messages is the one who typed it but it is annoying.

and taking up space.
Title:
Post by: plop on 01 June, 2004, 18:01:00
both requests added.
but truckers request has a bad side effect, takes a bit more resources.
the result is good tho and thats what mathers.
-- code board V2 by plop
-- made for my own hub to seperate chat from code
-- doesn't repeat to the sender anymore
-- added away filter

Bot = "Code_Board"
tUsers = {}

function Main()
   frmHub:RegBot(Bot)
end

function DataArrival(user, data)
   if tUsers[user.sName] == nil then
      tUsers[user.sName] = 1
   end
   if(strsub(data, 1, 4) == "$To:") then
      local s,e,whoTo = strfind(data,"$To:%s+(%S+)")
      if whoTo == Bot then
         data=strsub(data,1,strlen(data)-1)
         local s,e,text = strfind(data, "%$%b<>(.*)")
         if text ~= "" then
            local s,e,awayvip = strfind(text, "(%b<>)%s*$")
            if awayvip ~= nil then
               s,e,awayvip = strfind(awayvip, "(DC)")
            end
            if awayvip == nil then----
               local curUser
               local line = "\r\nCode by: "..user.sName.."\r\n"..date().."\r\n--------------------------------------------------------------------------------------------------------------------------------\r\n"
               line = line..text.."\r\n--------------------------------------------------------------------------------------------------------------------------------\r\n|"
               for a,b in tUsers do
                  curUser = GetItemByName(a)
                  if curUser and (a ~= user.sName) then
                     curUser:SendPM(Bot, line)
                  else
                     tUsers[a] = nil
                  end
               end
            end
         end
      end
   end
end

function OpConnected(user)
   if tUsers[user.sName] == nil then
      tUsers[user.sName] = 1
   end
end

NewUserConnected = OpConnected

function OpDisconnected(user)
   if tUsers[user.sName] then
      tUsers[user.sName] = nil
   end
end

UserDisconnected = OpDisconnected
plop
Title:
Post by: [NL]trucker on 01 June, 2004, 19:16:09
thnx plop for quick reply.