I am getting this error
Quotelua:142: attempt to call field `BeginConnect' (a nil value)
in this script
--============================================================
--========= Network hub pinger redirect Manager ==============
--============= By ??????Hawk?????? 25-05-04 =================
-- Applied for PXWSA and latest PX by bastya_elvtars,
-- since the original author wants you to download HIS software to get this funtionality,
-- rather than converting the script.
-- This script (or portions of it) may not be compiled neither embedded into compiled bots, or distributed with them,
-- feel free to change though.
-- Get PXWSA lib at http://thewildplace.dk/lua/wsa
-- Create a folder named libs inside your scripts folder and put pxwsa.dll into there
-- Enjoy! :-)
--============================================================
--=====This Script is designed to be run on its own hub ======
--======= Use another Ptokax hub on a different port =========
--============================================================
--========== +rdon = enable / +rdoff = disable ===============
--================== Editable settings =======================
sBot = "Network-Redirector-" --// Bot name
DefaultHub = "DefaultHub.no-ip.org:411" --// Default redirect hub Addy:Port
RedirectsEnabled = true --// true/false Auto start
RedirRegsAsWell=true --// redirect regs/vips as well? true/false
mins = 1 --// Ping Next Hub after # mins
--// Hubs In network
--// you can add / remove as many as you want
--// but keep the same layout
--// {"hub","port"},
Hub_Adress = {
{"hub1.no-ip.org","411"},
{"hub2.sytes.net","4111"},
{"hub-3.no-ip.org","419"},
}
--========= Mess With The Below at your own Peril ===========
status=0
libinit = loadlib(frmHub:GetPtokaXLocation().."/scripts/libs/pxwsa.dll", "_libinit")
assert(libinit,"Cannot load the WSA library!")
libinit()
Onlinehubs = {}
HubCounter = 1
cnt = 1
function Main()
WSA.Init()
SetTimer(1000 * 60 * mins)
if RedirectsEnabled == true then
StartTimer()
end
end
function NewUserConnected(curUser)
if not user.bRegistered or RedirRegsAsWell then
if (RedirectsEnabled == false) then
frmHub:SetRedirectAddress(DefaultHub)
end
curUser:Redirect(frmHub:GetRedirectAddress())
end
end
function ChatArrival(user, data)
local cmdtbl={["+rdon"]=1,["+rdoff"]=1}
local data=string.sub(data,1,string.len(data)-1)
local s,e,cmd = string.find(data,"%b<>%s+(%S+)")
if cmdtbl[cmd] then
if user.bOperator then
if cmd=="+rdon" then
SendToOps(sBot," Redirects enabled ")
StartTimer()
RedirectsEnabled = true
elseif cmd=="+rdoff" then
SendToOps(sBot," redirects disabled ")
StopTimer()
RedirectsEnabled = false
end
else
user:SendData(sBot,"Not your business. :-P")
end
return 1
end
end
function OnTimer()
if cnt > table.getn(Hub_Adress) then
cnt=1
end
displayhub()
end
--============================================================
--===================! ! ! PING ! ! ! =======================
function OnWsaConnected ( errorCode, errorStr, sock )
local status
if errorCode then
status=1
else
status=2
end
WSA.Close(sock)
if status == 1 then
if Active == false then
SendToOps(sBot,CurrentChecking.." Hub is still Offline")
elseif Active == true then
SendToOps(sBot,CurrentChecking.." Hub Has Gone Offline")
Onlinehubs[Position] = nil
end
elseif status==2 then
if Active == false then
SendToOps(sBot,CurrentChecking.." Has Come Online")
Onlinehubs[ActiveHubCount] = CurrentChecking
elseif Active == true then
SendToOps(sBot,CurrentChecking.." Hub is still online")
end
end
cnt = cnt + 1
if (table.getn(Onlinehubs) == 0) then
frmHub:SetRedirectAddress(DefaultHub)
else
frmHub:SetRedirectAddress(Onlinehubs[HubCounter])
end
if HubCounter >= table.getn(Onlinehubs) then
HubCounter = 1
else
HubCounter = HubCounter + 1
end
CurrentOnlineHubs()
end
function displayhub()
local _,_,sock=WSA.NewSocket()
CurrentChecking = Hub_Adress[cnt][1]..":"..Hub_Adress[cnt][2]
Active = false
ActiveHubCount = table.getn(Onlinehubs) + 1
for index, value in ipairs(Onlinehubs) do
if value == CurrentChecking then
Active = true
Position = index
break
end
end
WSA.BeginConnect(sock,Hub_Adress[cnt][1],Hub_Adress[cnt][2])
end
--============================================================
--===================! ! ! PONG ! ! ! =======================
function CurrentOnlineHubs()
local names = "\r\n\r\n-------------Curent Online Hubs----------------\r\n\r\n\t"
for index, value in ipairs(Onlinehubs) do
names = names.." "..value.."\r\n\t"
end
names = names.."\r\n\r\nCurently Redirecting to "..frmHub:GetRedirectAddress().."\r\n\r\n"
SendToOps(sBot,names)
end
function OnExit() WSA.Dispose(); end
--===================== End Of Script ========================
Does not yet work with the new PXWSA. Expect the fix next week.
Any luck getting this to work. I need it badly or one like it.
I will start working on it immediately.
Should work...
--============================================================
--========= Network hub pinger redirect Manager 2.1 ==============
--============= By ¨?ś??ť°?ş??˘Hawk??˘?ş°??ť?ś¨ 25-05-04 =================
-- Applied for PXWSA and latest PX by bastya_elvtars,
-- since the original author wants you to download HIS software to get this funtionality,
-- rather than converting the script.
-- This script (or portions of it) may not be compiled neither embedded into compiled bots, or distributed with them,
-- feel free to change though.
-- Get PXWSA lib at http://thewildplace.dk/lua/wsa
-- Create a folder named libs inside your scripts folder and put pxwsa.dll into there
-- Enjoy! :-)
--============================================================
--=====This Script is designed to be run on its own hub ======
--======= Use another Ptokax hub on a different port =========
--============================================================
--========== +rdon = enable / +rdoff = disable ===============
-- 2.1: applied to the new PXWSA by bastya_elvtars
--================== Editable settings =======================
sBot = "Network-Redirector-" --// Bot name
DefaultHub = "DefaultHub.no-ip.org:411" --// Default redirect hub Addy:Port
RedirectsEnabled = true --// true/false Auto start
RedirRegsAsWell=true --// redirect regs/vips as well? true/false
mins = 1 --// Ping Next Hub after # mins
--// Hubs In network
--// you can add / remove as many as you want
--// but keep the same layout
--// {"hub","port"},
Hub_Adress = {
{"goldenangel.no-ip.org","411"},
{"sanitarium.selfip.com","411"},
{"hub-3.no-ip.org","419"},
}
--========= Mess With The Below at your own Peril ===========
status=0
libinit = loadlib(frmHub:GetPtokaXLocation().."/scripts/libs/pxwsa.dll", "_libinit")
assert(libinit,"Cannot load the WSA library!")
libinit()
_M=0
_A=false
Onlinehubs = {}
HubCounter = 1
cnt = 1
function Main()
WSA.Init()
SetTimer(1000)
if RedirectsEnabled == true then
StartTimer()
end
end
function NewUserConnected(curUser)
if not user.bRegistered or RedirRegsAsWell then
if (RedirectsEnabled == false) then
frmHub:SetRedirectAddress(DefaultHub)
end
curUser:Redirect(frmHub:GetRedirectAddress())
end
end
function ChatArrival(user, data)
if user.bOperator then
local data=string.sub(data,1,string.len(data)-1)
local _,_,cmd = string.find(data,"%b<>%s+(%S+)")
if cmd=="+rdon" then
SendToOps(sBot," Redirects enabled ")
StartTimer()
RedirectsEnabled = true
return 1
elseif cmd=="+rdoff" then
SendToOps(sBot," redirects disabled ")
StopTimer()
RedirectsEnabled = false
return 1
end
else
user:SendData(sBot,"Not your business. :-P")
end
end
function OnTimer()
if _A then ConnectToHost(Hub_Adress[cnt][1],Hub_Adress[cnt][2]) end
_M=_M+1
if _M== 60 * mins then
_M=0
if cnt > table.getn(Hub_Adress) then
cnt=1
end
displayhub()
end
end
--============================================================
--===================! ! ! PING ! ! ! =======================
function ConnectToHost(addy,port)
local status
local err1,err2=WSA.Connect(sock,addy,port)
if err1 then
if err1~=10035 and err1~=10056 then
_A=false
status=1; WSA.Close(sock)
elseif err1==10056 then
_A=false
status=2; WSA.Close(sock)
elseif err1==10035 then
_A=true
return
end
else
_A=false
status=2; WSA.Close(sock)
end
Populate(status)
end
function Populate(status)
if status == 1 then
if Active == false then
SendToOps(sBot,CurrentChecking.." Hub is still Offline")
elseif Active == true then
SendToOps(sBot,CurrentChecking.." Hub Has Gone Offline")
Onlinehubs[Position] = nil
end
elseif status==2 then
if Active == false then
SendToOps(sBot,CurrentChecking.." Has Come Online")
Onlinehubs[ActiveHubCount] = CurrentChecking
elseif Active == true then
SendToOps(sBot,CurrentChecking.." Hub is still online")
end
end
cnt = cnt + 1
if (table.getn(Onlinehubs) == 0) then
frmHub:SetRedirectAddress(DefaultHub)
else
frmHub:SetRedirectAddress(Onlinehubs[HubCounter])
end
if HubCounter >= table.getn(Onlinehubs) then
HubCounter = 1
else
HubCounter = HubCounter + 1
end
CurrentOnlineHubs()
end
function displayhub()
_,_,sock=WSA.NewSocket()
CurrentChecking = Hub_Adress[cnt][1]..":"..Hub_Adress[cnt][2]
Active = false
ActiveHubCount = table.getn(Onlinehubs) + 1
for index, value in ipairs(Onlinehubs) do
if value == CurrentChecking then
Active = true
Position = index
break
end
end
ConnectToHost(Hub_Adress[cnt][1],Hub_Adress[cnt][2])
end
--============================================================
--===================! ! ! PONG ! ! ! =======================
function CurrentOnlineHubs()
local names = "\r\n\r\n-------------Curent Online Hubs----------------\r\n\r\n\t"
for index, value in ipairs(Onlinehubs) do
names = names.." "..value.."\r\n\t"
end
names = names.."\r\n\r\nCurently Redirecting to "..frmHub:GetRedirectAddress().."\r\n\r\n"
SendToOps(sBot,names)
end
function OnExit() WSA.Dispose(); end
--===================== End Of Script ========================
Any feedback?
ok i got wrong lib or something.....lol maybe i downloaded the worng things cause its not working. has the extension fix been released and which ptokax should i use?...man i got to much on my desktop
Use the latest one on www.thewildplace.dk please.
Got it working
Decided to give this script ago, to be able to use the latest ptokax on redirect hub :) however I'm getting this error, and some user dont get redirected: [13:21] Syntax ...Anna\Skrivbord\0.3.5.1.lua5.0.2\scripts\redirect.lua:64: attempt to index global `user' (a nil value)
also I would like to know if there is a possibility to make hubs immune from online checks? My hub thats on the same computer and behind a router cant be seen on addy (I know crappy router that wont let me use dns addies to my own comp :D )
Quote from: Anna on 03 September, 2006, 13:24:25
Decided to give this script ago, to be able to use the latest ptokax on redirect hub :) however I'm getting this error, and some user dont get redirected: [13:21] Syntax ...Anna\Skrivbord\0.3.5.1.lua5.0.2\scripts\redirect.lua:64: attempt to index global `user' (a nil value)
Replace:
if not user.bRegistered or RedirRegsAsWell then ->
if not curUser.bRegistered or RedirRegsAsWell thenQuotealso I would like to know if there is a possibility to make hubs immune from online checks? My hub thats on the same computer and behind a router cant be seen on addy (I know crappy router that wont let me use dns addies to my own comp :D )
How about entering the internal IP and port? :-P
Surely I can not have my internal IP as a redirect addy in the script and get other users to my hub through that :)
I need it to see me as online and still use the correct addy when redirecting :D if thats not possible, i'm stuck with the redirect script I have (not even close to being similar to this, but its compiled so I can not even try converting it) and with using the old ptokax for redirecting
Quote from: Anna on 03 September, 2006, 17:04:04
Surely I can not have my internal IP as a redirect addy in the script and get other users to my hub through that :)
Ooops, forgot.
Quote from: Anna on 03 September, 2006, 17:04:04
I need it to see me as online and still use the correct addy when redirecting :D if thats not possible, i'm stuck with the redirect script I have (not even close to being similar to this, but its compiled so I can not even try converting it) and with using the old ptokax for redirecting
Well, you should open C:\Windows\System32\Drivers\etc\hosts and add your hub's internal addy along with the DNS. This file is the very first one that Windows uses for DNS lookups. For others, the DNS of your hub will resolve to your external address, obviously.
Quote from: bastya_elvtars on 03 September, 2006, 20:30:44
Well, you should open C:\Windows\System32\Drivers\etc\hosts and add your hub's internal addy along with the DNS. This file is the very first one that Windows uses for DNS lookups. For others, the DNS of your hub will resolve to your external address, obviously.
Thank you for that info :) will test that, I know for sure it solved another of my annoyances with that router... being able to in a simple way get to my webserver without using localhost :D
:) all works fine except one thing... when script been running a whlie, some hubs appear more then once in currently online hublist :/ after having it running for about 12 hrs, one hub is listed 3 times and another 2 times...
Dear bastya_elvtars
Som feedback >> he did not work here.
I have had change the following and the lua works perfect.
at line 60
--------------------------------------------------------------
function NewUserConnected(curUser)
if not user.bRegistered or RedirRegsAsWell then
if (RedirectsEnabled == false) then
frmHub:SetRedirectAddress(DefaultHub)
end
curUser:Redirect(frmHub:GetRedirectAddress())
end
end
--------------------------------------------------------------
Change it in (see below) and the lua works perfect. ;)
--------------------------------------------------------------
NewUserConnected = function(user) --function NewUserConnected(curUser)
if not user.bRegistered or RedirRegsAsWell then
if (RedirectsEnabled == false) then
frmHub:SetRedirectAddress(DefaultHub)
end
user:Redirect(frmHub:GetRedirectAddress())
end
end
--------------------------------------------------------------
Yust a Suggestion greetings Respectfully,
[NL]Daddy-Bear? :)
Anybody fancy updating this to lua 5.1.1 ? :)
I would have a go, but am quite busy with coursework at the moment. ???
Quote from: Pothead on 26 September, 2006, 21:00:36
Anybody fancy updating this to lua 5.1.1 ? :)
I would have a go, but am quite busy with coursework at the moment. ???
As soon as we get a socket lib that is really working, sure thing.
I use d2af (which uses WSA), and i've not had any trouble with it, not working. Unless this script requires a different (non-working) part of it. ?
WSA does not run on most recent Px versions IIRC.
long time has passed.
is this now useable with lastest ptokax?
if yes can some plzz covert this script to lua 5.1
You can try this on latest PtokaX Version (0.3.6.0)
You will need the pxwsa_l51.dll in your ptokax root folder (where ptokax.exe is) because the new libs want it that way.
--============================================================
--========= Network hub pinger redirect Manager 2.1 ==============
--============= By ¨?s??t°?s???Hawk????s°??t?s¨ 25-05-04 =================
-- Applied for PXWSA and latest PX by bastya_elvtars,
-- since the original author wants you to download HIS software to get this funtionality,
-- rather than converting the script.
-- This script (or portions of it) may not be compiled neither embedded into compiled bots, or distributed with them,
-- feel free to change though.
-- Get PXWSA lib at http://thewildplace.dk/lua/wsa
-- Create a folder named libs inside your scripts folder and put pxwsa.dll into there
-- Enjoy! :-)
--============================================================
--=====This Script is designed to be run on its own hub ======
--======= Use another Ptokax hub on a different port =========
--============================================================
--========== +rdon = enable / +rdoff = disable ===============
-- 2.1: applied to the new PXWSA by bastya_elvtars
-- 2.2: touched by Psycho_Chihuahua to reflect new Usage of Lua 5.1 Libs
--================== Editable settings =======================
sBot = "Network-Redirector-" --// Bot name
DefaultHub = "DefaultHub.no-ip.org:411" --// Default redirect hub Addy:Port
RedirectsEnabled = true --// true/false Auto start
RedirRegsAsWell=true --// redirect regs/vips as well? true/false
mins = 1 --// Ping Next Hub after # mins
--// Hubs In network
--// you can add / remove as many as you want
--// but keep the same layout
--// {"hub","port"},
Hub_Adress = {
{"hub-1.no-ip.org","411"},
{"hub-2.no-ip.org","411"},
{"hub-3.no-ip.org","411"},
}
--========= Mess With The Below at your own Peril ===========
status=0
libinit = package.loadlib(frmHub:GetPtokaXLocation().."/pxwsa_l51.dll", "_libinit") -- touched by Psycho_Chihuahua (new 5.1 Libs belong in PtokaX Root Folder)
assert(libinit,"Cannot load the WSA library! Please make sure it is in the PtokaX Root Folder (thats where PtokaX.exe is)!")
libinit()
_M=0
_A=false
Onlinehubs = {}
HubCounter = 1
cnt = 1
function Main()
WSA.Init()
SetTimer(1000)
if RedirectsEnabled == true then
StartTimer()
end
end
function NewUserConnected(curUser)
if not curUser.bRegistered or RedirRegsAsWell then
if (RedirectsEnabled == false) then
frmHub:SetRedirectAddress(DefaultHub)
end
curUser:Redirect(frmHub:GetRedirectAddress())
end
end
function ChatArrival(User, data)
if User.bOperator then
local data=string.sub(data,1,string.len(data)-1)
local _,_,cmd = string.find(data,"%b<>%s+(%S+)")
if cmd=="+rdon" then
SendToOps(sBot," Redirects enabled ")
StartTimer()
RedirectsEnabled = true
return 1
elseif cmd=="+rdoff" then
SendToOps(sBot," redirects disabled ")
StopTimer()
RedirectsEnabled = false
return 1
end
else
User:SendData(sBot,"Not your business. :-P")
end
end
function OnTimer()
if _A then ConnectToHost(Hub_Adress[cnt][1],Hub_Adress[cnt][2]) end
_M=_M+1
if _M== 60 * mins then
_M=0
if cnt > table.getn(Hub_Adress) then
cnt=1
end
displayhub()
end
end
--============================================================
--===================! ! ! PING ! ! ! =======================
function ConnectToHost(addy,port)
local status
local err1,err2=WSA.Connect(sock,addy,port)
if err1 then
if err1~=10035 and err1~=10056 then
_A=false
status=1; WSA.Close(sock)
elseif err1==10056 then
_A=false
status=2; WSA.Close(sock)
elseif err1==10035 then
_A=true
return
end
else
_A=false
status=2; WSA.Close(sock)
end
Populate(status)
end
function Populate(status)
if status == 1 then
if Active == false then
SendToOps(sBot,CurrentChecking.." Hub is still Offline")
elseif Active == true then
SendToOps(sBot,CurrentChecking.." Hub Has Gone Offline")
Onlinehubs[Position] = nil
end
elseif status==2 then
if Active == false then
SendToOps(sBot,CurrentChecking.." Has Come Online")
Onlinehubs[ActiveHubCount] = CurrentChecking
elseif Active == true then
SendToOps(sBot,CurrentChecking.." Hub is still online")
end
end
cnt = cnt + 1
if (table.getn(Onlinehubs) == 0) then
frmHub:SetRedirectAddress(DefaultHub)
else
frmHub:SetRedirectAddress(Onlinehubs[HubCounter])
end
if HubCounter >= table.getn(Onlinehubs) then
HubCounter = 1
else
HubCounter = HubCounter + 1
end
CurrentOnlineHubs()
end
function displayhub()
_,_,sock=WSA.NewSocket()
CurrentChecking = Hub_Adress[cnt][1]..":"..Hub_Adress[cnt][2]
Active = false
ActiveHubCount = table.getn(Onlinehubs) + 1
for index, value in ipairs(Onlinehubs) do
if value == CurrentChecking then
Active = true
Position = index
break
end
end
ConnectToHost(Hub_Adress[cnt][1],Hub_Adress[cnt][2])
end
--============================================================
--===================! ! ! PONG ! ! ! =======================
function CurrentOnlineHubs()
local names = "\r\n\r\n-------------Curent Online Hubs----------------\r\n\r\n\t"
for index, value in ipairs(Onlinehubs) do
names = names.." "..value.."\r\n\t"
end
names = names.."\r\n\r\nCurently Redirecting to "..frmHub:GetRedirectAddress().."\r\n\r\n"
SendToOps(sBot,names)
end
function OnExit() WSA.Dispose(); end
--===================== End Of Script ========================
**fixed :58: attempt to index global 'user' (a nil value) - should work now**
script starts and then on login to hub i get
[20:23] Syntax G:\[My Hub]\scripts\redirect_manager.lua:58: attempt to index global 'user' (a nil value)
i got the bug working fine now
just had to change at line 58: user to curUser
yeah thanks for info, found and fixed in my last post now too
PC, care to post to my forum as well? I was unaware that pxwsa is still working, and thanks for letiing me know.
i can post it to your forum as well yeah no problem. And your welcome for me "upgrading" this script, i did it as practice and found out it still works ;)