Author Topic: [SOLVED]Convert 2 lua 5.1 please  (Read 2375 times)

0 Members and 1 Guest are viewing this topic.

Offline nightshadow

  • Newbie
  • *
  • Posts: 8
  • Karma: +0/-0
[SOLVED]Convert 2 lua 5.1 please
« on: 08 April, 2006, 00:23:48 »
Code: [Select]
--//RangeBlaster v2.07 by Phatty
--//IP Keys written by John, and Phatty

Bot = "IPRangeBlock"
path = "RangeBlaster/Ranges.dat"
Ranges = {}
-------------------------
function Main()
frmHub:RegBot(Bot)
LoadIps()
end
-------------------------
function LoadIps()

local tmp = 0
local handle = io.open(path,"r")
line = handle:read()
while line do
tmp = tmp + 1
local s,e,ipr1,ipr2 = string.find(line,"(%S+)|(%S+)")
if ipr2 == nil then
SendToAll(Bot,"Error on line "..line)
end
local s,e,ipa1,ipb1,ipc1,ipd1 = string.find(ipr1, "(%d*).(%d*).(%d*).(%d*)")
local s,e,ipa2,ipb2,ipc2,ipd2 = string.find(ipr2, "(%d*).(%d*).(%d*).(%d*)")
si1 = CheckNumber(ipa1)..CheckNumber(ipb1)..CheckNumber(ipc1)..CheckNumber(ipd1)
si2 = CheckNumber(ipa2)..CheckNumber(ipb2)..CheckNumber(ipc2)..CheckNumber(ipd2)
Ranges[si1] = si2
line = handle:read()
end
SendToAll(Bot,"Successfully loaded "..tmp)
end
--------------------------
function Blocked(userip)

local s,e,range1,range2,range3,range4 = string.find(userip,"(%d+).(%d+).(%d+).(%d+)")
checker = CheckNumber(range1)..CheckNumber(range2)..CheckNumber(range3)..CheckNumber(range4)

--SendToAll(Bot,"IP-Test..."..checker)

for i,p in Ranges do
local s,e,xstart = string.find(i, "(%d*)")
local s,e,xend = string.find(p, "(%d*)")

if checker > xstart and checker < xend then
collectgarbage()
io.flush()
return 1
else
end
end
end
-------------------------
function CheckNumber(number)

numbera = tonumber(number)
if numbera < 10 then
numbera = "00"..number
elseif numbera < 100 then
numbera = "0"..number
else
numbera = number
end
return numbera
end
------------------------
function ValidateNickArrival(user)

if Blocked(user.sIP) == 1 then
user:SendData(Bot, "This hub is private, leave a message to [EMAIL]ip-tracer@sm3yfx.net[/EMAIL],and explain who you are, you will now be disconnected!")
user:SendData(Bot, "Disconnecting...")
SendPmToOps(Bot, user.sName.." - "..user.sIP.." has been blasted by "..Bot.."!")
SendToAll(Bot, user.sName.." - "..user.sIP.." has been blasted by "..Bot.."!")
user:Disconnect()
end
end


It gives me error on line:

Code: [Select]
for i,p in Ranges do
Greetz
NS
« Last Edit: 26 September, 2006, 10:30:49 by Herodes »

PtokaX forum

[SOLVED]Convert 2 lua 5.1 please
« on: 08 April, 2006, 00:23:48 »

Offline nightshadow

  • Newbie
  • *
  • Posts: 8
  • Karma: +0/-0
Re: Convert 2 lua 5.1 please
« Reply #1 on: 08 April, 2006, 01:25:01 »
Thank you Mutor. Works.
Just had talked a few minutes with DJ Bert and said the same. He had converted it for me, thanx anyway.

Greetz
NS

BTW
Does it matter if you write Main = function() or write function is Main() ?
I see some write the one and some others....

Offline DJ Bert

  • Triple Ace
  • **
  • Posts: 211
  • Karma: +6/-1
  • Guardian Scripter
Re: Convert 2 lua 5.1 please
« Reply #2 on: 08 April, 2006, 01:30:25 »
It doesn't matter I think. Just testing my Guardian since a few days. The function is always called.

PtokaX forum

Re: Convert 2 lua 5.1 please
« Reply #2 on: 08 April, 2006, 01:30:25 »