Author Topic: Need Help!!!  (Read 2101 times)

0 Members and 1 Guest are viewing this topic.

Offline MDFP

  • Junior Member
  • **
  • Posts: 13
  • Karma: +0/-0
Need Help!!!
« 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.

PtokaX forum

Need Help!!!
« on: 27 July, 2005, 04:02:27 »

imby

  • Guest
(No subject)
« Reply #1 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:

Code: [Select]
user:SendPM(sConf.sBot,ReadFile(sConf.sFile1))
to

Code: [Select]
user:SendData(sConf.sBot,ReadFile(sConf.sFile1))
should work.

Offline MDFP

  • Junior Member
  • **
  • Posts: 13
  • Karma: +0/-0
Done by myself
« Reply #2 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

imby

  • Guest
(No subject)
« Reply #3 on: 27 July, 2005, 21:14:01 »
Quote
Originally 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

PtokaX forum

(No subject)
« Reply #3 on: 27 July, 2005, 21:14:01 »