PtokaX forum

Archive => Archived 5.0 boards => Help with scripts => Topic started by: MDFP on 27 July, 2005, 04:02:27

Title: Need Help!!!
Post by: MDFP on 27 July, 2005, 04:02:27
Hi people.

I have this script to read a text file to a PM.



sConf = {
   sBot = frmHub:GetHubBotName(),
   sFile1 = "trafego.txt",
}

function ChatArrival(user,data)
   local data = string.sub(data,1,-2)
   local s,e,cmd = string.find (data, "%b<>%s+[%!%?%+%#](%S+)" )
   if cmd then
      local tCmds =    {
         ["trafego"] =    function(user,data)
                  user:SendPM(sConf.sBot,ReadFile(sConf.sFile1))
               end,
      }
      if tCmds[cmd] then
         return tCmds[cmd](user,data), 1
      end
   end
end

function ReadFile(file)
   local fFile = io.open(file)
   if fFile then
      local message = ""
      for line in io.lines(file) do
         message = message..line.."\n"
      end
      fFile:close()
      return message
   else
      return file.." not found!"
   end
end




Could someone of "master-scripters" :) chande this to read the same file to Main chat?


Thanks.
Title:
Post by: imby on 27 July, 2005, 04:26:51
I'm afraid this doesn't require a master scripter :P I'm pretty dire at scripting, but changing:

user:SendPM(sConf.sBot,ReadFile(sConf.sFile1))
to

user:SendData(sConf.sBot,ReadFile(sConf.sFile1))
should work.
Title: Done by myself
Post by: MDFP on 27 July, 2005, 19:01:24
Thanks guys (IMBY)

I've read the script and have changed this

     function(user,data)
                  SendPM(sConf.sBot,ReadFile(sConf.sFile1))

to this

     function(user,data)
                  SendToAll(sConf.sBot,ReadFile(sConf.sFile1))



Thanks anyway.


Entire Script







-- Comando comandos amigos feito por Hahn?
-- Pedido por MDFP
-- Modificado por MDFP (Show on main)
-- Thanks to CONEJODELMAL
-- 22-07-2005



sConf = {
   sBot = frmHub:GetHubBotName(),
   sFile1 = "comandos.txt",
}
 
function ChatArrival(user,data)
   local data = string.sub(data,1,-2)
   local s,e,cmd = string.find (data, "%b<>%s+[%!%?%+%#](%S+)" )
   if cmd then
      local tCmds =    {
         ["cmds"] =    function(user,data)
                  SendToAll(sConf.sBot,ReadFile(sConf.sFile1))
               end,
      }
      if tCmds[cmd] then  
         return tCmds[cmd](user,data), 1
      end
   end
end
 
function ReadFile(file)
   local fFile = io.open(file)
   if fFile then
      local message = ""
      for line in io.lines(file) do
         message = message..line.."\n"
      end
      fFile:close()
      return message
   else
      return file.." not found!"
   end
end
Title:
Post by: imby on 27 July, 2005, 21:14:01
QuoteOriginally posted by MDFP
Thanks guys (IMBY)

I've read the script and have changed this

     function(user,data)
                  SendPM(sConf.sBot,ReadFile(sConf.sFile1))

to this

     function(user,data)
                  SendToAll(sConf.sBot,ReadFile(sConf.sFile1))



Thanks anyway.


Entire Script







-- Comando comandos amigos feito por Hahn?
-- Pedido por MDFP
-- Modificado por MDFP (Show on main)
-- Thanks to CONEJODELMAL
-- 22-07-2005



sConf = {
   sBot = frmHub:GetHubBotName(),
   sFile1 = "comandos.txt",
}
 
function ChatArrival(user,data)
   local data = string.sub(data,1,-2)
   local s,e,cmd = string.find (data, "%b<>%s+[%!%?%+%#](%S+)" )
   if cmd then
      local tCmds =    {
         ["cmds"] =    function(user,data)
                  SendToAll(sConf.sBot,ReadFile(sConf.sFile1))
               end,
      }
      if tCmds[cmd] then  
         return tCmds[cmd](user,data), 1
      end
   end
end
 
function ReadFile(file)
   local fFile = io.open(file)
   if fFile then
      local message = ""
      for line in io.lines(file) do
         message = message..line.."\n"
      end
      fFile:close()
      return message
   else
      return file.." not found!"
   end
end

Ah ok, mis-understood your request