PtokaX forum

Archive => Archived 4.0 boards => Help with Lua 4 scripts => Topic started by: Bollebus on 04 August, 2004, 19:27:23

Title: I need help for this LUA script
Post by: Bollebus on 04 August, 2004, 19:27:23
HI

the script is perfeck but i vill not send it in main as this script do
i wont the script send a pm to everyone type !pm or
!mass  someone here who can lock at this and fix it ?

but i worthless to edit lua script so i need help there

im running Ptokac soft whit robocop 8

thankz

//Bolle

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

endEvery = 2   ----  time in hrs
textfile = "massmessage.txt"
bot = "Mass_Message"
hrs = 1000 * 60 * 60 * SendEvery


function Main()
   SetTimer(hrs)
   StartTimer()
end



function OnTimer()
   massMessageToAll()
end




function massMessageToAll()
local handle = openfile(textfile, "r")
   if (handle ~= nil) then
      local line = read(handle)
                  Temptimerfile = "\r\n"
      while line do
         Temptimerfile = Temptimerfile.."\r\n"..line
         line = read(handle)
      end
         SendPmToAll(bot, Temptimerfile)
      closefile(handle)
   end
end
Title:
Post by: D-J Valhala on 04 August, 2004, 20:04:18
you have +mass in Robocop mate... :D
Title:
Post by: Herodes on 04 August, 2004, 20:24:02
Bolle a clue would be to try changing SendPmToAll(bot, Temptimerfile) to smth like
  SendToAll(bot, Temptimerfile)
Try reading through the Scripting.txt in the docs folder of PtokaX. ...
Title:
Post by: Snooze on 04 August, 2004, 20:41:34
SendEvery = 2 ---- time in hrs
textfile = "massmessage.txt"
bot = "Mass_Message"
hrs = 1000 * 60 * 60 * SendEvery
Prefix = "+"
Trigger1 = "pm"

function Main()
SetTimer(hrs)
StartTimer()
frmHub:RegBot(bot)
end

function OnTimer()
massMessageToAll()

end

function DataArrival(user,data)
if strsub(data, 1, 1) == "<" or (strsub(data,1,5+strlen(Bot))=="$To: "..Bot) then
local data=strsub(data,1,strlen(data)-1)
s,e,cmd = strfind(data,"%b<>%s+(%S+)")
          if cmd == Prefix..Trigger1 then
  massMessageToAll()
return 1
end
end
end


function massMessageToAll()
local handle = openfile(textfile, "r")
if (handle ~= nil) then
local line = read(handle)
Temptimerfile = "\r\n"
while line do
Temptimerfile = Temptimerfile.."\r\n"..line
line = read(handle)
end
SendPmToAll(bot, Temptimerfile)
closefile(handle)
end
end

I hope this was what you had in mind..

Command is :

+pm

Will send the content of the massmessage.txt to all users in the hub + send it on the timer..

Best regards,

Snooze
Title:
Post by: Bollebus on 04 August, 2004, 20:59:07
Ptokax say =
Syntax Error bad argument #1 to'strlen' sting expected got nil

can u fix it i worthless to edit lua script

/Bolle

QuoteOriginally posted by Snooze
SendEvery = 2 ---- time in hrs
textfile = "massmessage.txt"
bot = "Mass_Message"
hrs = 1000 * 60 * 60 * SendEvery
Prefix = "+"
Trigger1 = "pm"

function Main()
SetTimer(hrs)
StartTimer()
frmHub:RegBot(bot)
end

function OnTimer()
massMessageToAll()

end

function DataArrival(user,data)
if strsub(data, 1, 1) == "<" or (strsub(data,1,5+strlen(Bot))=="$To: "..Bot) then
local data=strsub(data,1,strlen(data)-1)
s,e,cmd = strfind(data,"%b<>%s+(%S+)")
          if cmd == Prefix..Trigger1 then
  massMessageToAll()
return 1
end
end
end


function massMessageToAll()
local handle = openfile(textfile, "r")
if (handle ~= nil) then
local line = read(handle)
Temptimerfile = "\r\n"
while line do
Temptimerfile = Temptimerfile.."\r\n"..line
line = read(handle)
end
SendPmToAll(bot, Temptimerfile)
closefile(handle)
end
end

I hope this was what you had in mind..

Command is :

+pm

Will send the content of the massmessage.txt to all users in the hub + send it on the timer..

Best regards,

Snooze
Title:
Post by: Snooze on 04 August, 2004, 21:07:15
SendEvery = 2 ---- time in hrs
textfile = "massmessage.txt"
bot = "Mass_Message"
hrs = 1000 * 60 * 60 * SendEvery
Prefix = "+"
Trigger1 = "pm"

function Main()
SetTimer(hrs)
StartTimer()
frmHub:RegBot(bot)
end

function OnTimer()
massMessageToAll()
end

function DataArrival(user,data)
if strsub(data, 1, 1) == "<" or (strsub(data,1,5+strlen(bot))=="$To: "..bot) then
local data=strsub(data,1,strlen(data)-1)
s,e,cmd = strfind(data,"%b<>%s+(%S+)")
          if cmd == Prefix..Trigger1 then
  massMessageToAll()
return 1
end
end
end


function massMessageToAll()
local handle = openfile(textfile, "r")
if (handle ~= nil) then
local line = read(handle)
Temptimerfile = "\r\n"
while line do
Temptimerfile = Temptimerfile.."\r\n"..line
line = read(handle)
end
SendPmToAll(bot, Temptimerfile)
closefile(handle)
end
end

Sorry about that .. :)
Title:
Post by: Bollebus on 04 August, 2004, 21:11:56
No problem youre script its perfeckt   im so happy now :)

i realy realy will THANK U

//bolle

QuoteOriginally posted by Snooze
SendEvery = 2 ---- time in hrs
textfile = "massmessage.txt"
bot = "Mass_Message"
hrs = 1000 * 60 * 60 * SendEvery
Prefix = "+"
Trigger1 = "pm"

function Main()
SetTimer(hrs)
StartTimer()
frmHub:RegBot(bot)
end

function OnTimer()
massMessageToAll()
end

function DataArrival(user,data)
if strsub(data, 1, 1) == "<" or (strsub(data,1,5+strlen(bot))=="$To: "..bot) then
local data=strsub(data,1,strlen(data)-1)
s,e,cmd = strfind(data,"%b<>%s+(%S+)")
          if cmd == Prefix..Trigger1 then
  massMessageToAll()
return 1
end
end
end


function massMessageToAll()
local handle = openfile(textfile, "r")
if (handle ~= nil) then
local line = read(handle)
Temptimerfile = "\r\n"
while line do
Temptimerfile = Temptimerfile.."\r\n"..line
line = read(handle)
end
SendPmToAll(bot, Temptimerfile)
closefile(handle)
end
end

Sorry about that .. :)
Title:
Post by: Snooze on 04 August, 2004, 21:26:37
Im glad that it worked out as you wished..


Snooze
Title:
Post by: Bollebus on 04 August, 2004, 21:30:46
Yes

and u are good on lua script
i hope i can ask u more if i have problem whit lua y are so goood at that

anyway
a BIG Thankz

//bolle

QuoteOriginally posted by Snooze
Im glad that it worked out as you wished..


Snooze
Title:
Post by: Snooze on 04 August, 2004, 21:33:49
I'm still a newbie, but feel free to ask and I'll do my best