PtokaX forum

Archive => Archived 5.0 boards => Help with scripts => Topic started by: Jelf on 22 March, 2005, 13:06:21

Title: Help Converting Please
Post by: Jelf on 22 March, 2005, 13:06:21
Hi all, been trying to convert a script and am stuck with this part,
It returns the error
Quoteattempt to call method `CheckIP' (a nil value)
Script cut just for help purpose..
["geoipinfo"] = function(curUser,data)
local _,_,sip = string.find(data,"^%b<>%s+%+%S+%s+(%d+%.%d+%.%d+%.%d+)")
if sip then
-- Check GeoIP
local ip1,ip2,ipcountry,ipcountrycode = "N/A","N/A","N/A","N/A"
local ret = GeoIPRange:CheckIP(sip)
if ret then
ip1 = DeComputeIP(ret[1])
ip2 = DeComputeIP(ret[2])
ipcountry = ret[3]["C"]
ipcountrycode = ret[3]["CC"]
end
SendToUser(curUser,"IP: "..sip..", From: "..ipcountry.." ("..ipcountrycode.."), Range: "..ip1.."-"..ip2,SecuLite.Bot)
else
SendToUser(curUser,"Syntax: "..SecuLite.Prefix.."geoipinfo ",SecuLite.Bot)
end
end,
}
function CheckIP(self,ip)
local cip = ComputeIP(ip)
local iStart,iEnd,iMid = 1,self:Getn(),0
while (iStart <= iEnd) do
iMid = math.floor((iStart+iEnd)/2)
local table = self:GetIndex(iMid)
if (table[1] <= cip) and (table[2] >= cip) then
return table
elseif (table[1] > cip) then
iEnd = iMid - 1
elseif (table[1] < cip) then
iStart = iMid + 1
end
end
end

I know that GeoIPRange is loaded so it must be something to do with how its trying to read the table
Any help appreciated, thanks