Hi,
I'm writing a script in Lua4 that allows to download for selected ips:
This is the content of my Ranges.txt file:
127.0.0.1|127.0.0.1
10.0.0.0|10.255.255.255
81.211.62.0|81.211.62.255
172.16.0.0|172.31.255.255
192.168.0.0|192.168.255.255
194.154.83.0|194.154.83.255
213.33.170.0|213.33.170.255
213.85.12.0|213.85.12.255
213.85.47.0|213.85.47.255
And here is the script:
--//Some code grabbed from RangeBlaster by Phatty
Ranges = {}
BlockTriggs = {
["$Rev"] = 1,
["$Con"] = 2,
}
function Main()
frmHub:EnableFullData(1)
LoadIps()
end
function LoadIps()
local tmp = 0
local handle = openfile("txt/Ranges.txt","r")
line = read(handle)
while line do
tmp = tmp + 1
local s,e,ipr1,ipr2 = strfind(line,"(%S+)|(%S+)")
if ipr2 == nil then
end
Ranges[ipr1] = ipr2
line = read(handle)
end
end
function Allowed(userip)
local s,e,range1,range2,range3,range4 = strfind(userip,"(%d+).(%d+).(%d+).(%d+)")
for i,p in Ranges do
local s,e,ipa1,ipb1,ipc1,ipd1 = strfind(i, "(%d*).(%d*).(%d*).(%d*)")
local s,e,ipa2,ipb2,ipc2,ipd2 = strfind(p, "(%d*).(%d*).(%d*).(%d*)")
if range1 == ipa1 then
if range1 < ipa1 or range1 > ipa2 then
else
if range2 < ipb1 or range2 > ipb2 then
else
if range3 < ipc1 or range3 > ipc2 then
else
if range4 < ipd1 or range4 > ipd2 then
else
collectgarbage()
flush()
return 1
end
end
end
end
end
end
end
function DataArrival(user,data)
if strsub(data,1,1) == "$" then
local str1 = strsub(data,1,4)
if BlockTriggs[str1] then
if BlockTriggs[str1] == 1 then
local _,_,conNick = strfind(data,"(%S+)|$")
local usr = GetItemByName(conNick)
if (Allowed(usr.sIP) == nil) then
return 1
end
elseif BlockTriggs[str1] == 2 then
local _,_,conNick = strfind(strsub(data,14,strlen(data)),"^(%S+)")
local usr = GetItemByName(conNick)
if (Allowed(usr.sIP) == nil) then
return 1
end
end
end
end
end
I don't know why, but PtokaX 0.330 15.18 debug gives me an error:
Syntax error: attempt to index local `usr' (a nil value)
stack traceback:
1: function `DataArrival' at line 77 [file `...iles\UltraFIRE server\scripts\downl_blocker.lua']
HELP ME PLZ!!! I DON'T UNDERSTAND AN ERROR. X(
Please help! :(
Respectfully,
NemeziS
try changinglocal usr = GetItemByName(conNick)
intolocal user = GetItemByName(conNick)
I exually don't know, but try it :)
It didn't help. Now the script laggggs a lot! It allows to download some times for users who are not in Ranges.txt. Could someone try to write this script himself? Plizzzzzzzzz :)
It's very important.
Respectfully,
NemeziS