PtokaX forum

Archive => Archived 5.1 boards => Help with scripts => Topic started by: Alexinno on 07 November, 2006, 08:11:16

Title: need help with userinfo lua 5.1
Post by: Alexinno on 07 November, 2006, 08:11:16
I need help with this script

--###------------------------------------------------------###--
--       Standalone Userinfo Database
--       Created by NightLitch (2005)
--###------------------------------------------------------###--
tSet = {}
tSet.BotName = "-Database-"
tSet.Weeks = 4
--###------------------------------------------------------###--
sMyINFO = {}
sTIME = {}
sIP = {}

tFunc = {}
tFunc.LoadFile = function(filename,table)
local file,err = io.open(filename, "r")
if err then tFunc.SaveFile(filename, table) return 1 end
for line in pairs(file:lines()) do
local s,e,nick,value = string.find(line, "(%S+)%|(.*)")
if nick and value ~= "" then
table[nick] = value
end
end
file:close()
end
tFunc.SaveFile = function(filename,table)
local file,err = io.open(filename, "w")
for nick, value in pairs(table) do
file:write(nick.."|"..value.."\n")
end
file:close()
end
tFunc.Add = function(nick,value,table)
table[nick] = value
end
tFunc.Remove = function(nick,value,table)
table[nick] = nil
end
tFunc.GetTime = function()
local T = {}
for a,b in pairs(os.date("*t")) do T[a] = b end
local time = os.time({year = T.year,month = T.month,day = (T.day+(tSet.Weeks*7)),hour = T.hour,min = T.min,sec = T.sec,isdst = T.isdst})
return time
end
tFunc.Cleaner = function()
local t,c = 0,0
for sNick,sTime in pairs(sTIME) do
t = t + 1
if os.time() > tonumber(sTime) then
c = c + 1
sTIME[sNick] = nil
sMyINFO[sNick] = nil
sIP[sNick] = nil
end
end
OnExit()
return "*** "..c.." / "..t.." users have been deleted from database ***"
end
tFunc.List = function()
local line = "\r\n"
line = line .. "\r\n -----###-----------------------------------------------------------------------------------------------------------------------------------------------------------------###-----"
line = line .. "\r\n                    # Current Clean List #       "
line = line .. "\r\n -----###-----------------------------------------------------------------------------------------------------------------------------------------------------------------###-----"
for sNick,sTime in pairs(sTIME) do
if os.time() > tonumber(sTime) then
line = line .. "\r\n\t "..sNick.." is last seen "..os.date("%A %d %B %Y (%H:%M:%S)", tonumber(sTime))
end
end
line = line .. "\r\n -----###-----------------------------------------------------------------------------------------------------------------------------------------------------------------###-----"
return line
end
tFunc.Online = function(nick)
if GetItemByName(nick) then return "Online" else return "Offline" end
end
tFunc.Find = function(value)
if string.find(value, "%d+%.%d+%.%d+%.%d+") then
local line = "*** Users found on IP: "..value..": \r\n\r\n"
for nick,ip in pairs(sIP) do
if ip == value then
line = line .. "\t "..nick.."  ("..tFunc.Online(nick)..")\r\n"
end
end
return line
else
local tUser = GetItemByName(value)
if tUser then
return tUser
else
for nick,ip in pairs(sIP) do
if string.lower(value) == string.lower(nick) then
return {sName = nick, sIP = sIP[nick], sMyInfoString = sMyINFO[nick]}
end
end
end
end
return
end
tFunc.SplitMyInfoString = function(MyINFO,table)
    local _,_,Descr,Speed,Mail,Share = string.find(MyINFO, "%$MyINFO %$ALL %S+ (.*)%$ %$(.*)%$(%S*)%$%s*(%-*%d*)%$%|$")
    local _,_,Tag = string.find(Descr, "(%b<>)$")
    Tag = Tag or ""
    Descr = string.sub(Descr, 1,string.len(Descr) - string.len(Tag))
    Speed = string.sub(Speed, 1,string.len(Speed) - 1)
    table["sDescription"] = Descr table["sTag"] = Tag table["sConnection"] = Speed table["sEmail"] = Mail table["iShareSize"] = tFunc.ShareUnit(tonumber(Share))
if Tag == "" then return table end
local Limiter = {["B"] = "(%d+)",["L"] = "(%d+)",["F"] = "%d+%/(%d+)"}
local Mode = {["A"] = "Active",["P"] = "Passive", ["5"] = "Socket"}
local TagString, TagTable = Tag, {}
TagString = string.sub(TagString,1,string.len(TagString)-1)
TagString = TagString..","
string.gsub( TagString, "(.):([^,]+),", function( letter, value ) if letter == "O" then return "" end if Limiter[letter] then _,_,value = string.find(value, Limiter[letter]) end TagTable[letter] = value end)
local _,_,sClient = string.find(TagString, "^(<%S+)%s+")
hubs = 0
if tonumber(TagTable["H"]) == nil then string.gsub(TagTable["H"], "(%d+)", function (num) hubs = hubs +tonumber(num) end) else hubs = tonumber(TagTable["H"]) end
table["sClient"] = sClient
table["sClientVersion"] = TagTable["V"]
table["sMode"] = Mode[TagTable["M"]]
table["iBlimit"] = TagTable["B"] or TagTable["L"] or TagTable["F"] or "unlimited"
table["iSlots"] = TagTable["S"]
table["iHubs"] = hubs
return table
end
tFunc.ShareUnit = function(intSize)
if tonumber(intSize) ~= 0 then
local tUnits = { "Bytes", "KB", "MB", "GB", "TB" }
intSize = tonumber(intSize);
local sUnits;
for index = 1, table.maxn(tUnits)do
if(intSize < 1024) then
sUnits = tUnits[index];
break;
else
intSize = intSize / 1024;
end
end
return string.format("%0.1f %s",intSize, sUnits);
else
return "0 Bytes"
end
end

function NewUserConnected(sUser)
tFunc.Add(sUser.sName,sUser.sIP, sIP)
tFunc.Add(sUser.sName,sUser.sMyInfoString, sMyINFO)
tFunc.Add(sUser.sName,tFunc.GetTime(), sTIME)
end

function UserDisconnected(sUser)
tFunc.Add(sUser.sName,sUser.sIP, sIP)
tFunc.Add(sUser.sName,sUser.sMyInfoString, sMyINFO)
tFunc.Add(sUser.sName,tFunc.GetTime(), sTIME)
end

OpConnected = NewUserConnected
OpDisconnected = UserDisconnected

function Main()
tFunc.LoadFile("sMyINFO.dat", sMyINFO)
tFunc.LoadFile("sIP.dat", sIP)
tFunc.LoadFile("sTIME.dat", sTIME)
end

function OnExit()
tFunc.SaveFile("sMyINFO.dat", sMyINFO)
tFunc.SaveFile("sIP.dat", sIP)
tFunc.SaveFile("sTIME.dat", sTIME)
end

function ChatArrival(sUser,sData)
local _,_,Cmd,Arg = string.find(sData, "%b<>%s*(%S+)%s*(.*)%|")
if Cmd == "!cleanlist" and sUser.bOperator then
sUser:SendData(tSet.BotName, tFunc.List() )
return 1
elseif Cmd == "!clean" and sUser.bOperator then
local msg = tFunc.Cleaner()
SendToAll(tSet.BotName, msg)
elseif Cmd == "!getinfo" and sUser.bOperator then
local s,e,value = string.find(Arg, "(%S+)")
if value == nil then sUser:SendData(tSet.BotName, "*** Syntax: !getinfo ") return 1 end
local usr = tFunc.Find(value)
if usr == nil then sUser:SendData(tSet.BotName, "*** Nothing found on "..value) return 1
elseif type(usr) == "string" then sUser:SendData(tSet.BotName, usr) return 1
elseif type(usr) == "table" then
usr = tFunc.SplitMyInfoString(usr.sMyInfoString,usr)
local line = ""
line = line .. "\r\n -----###-----------------------------------------------------------------------------------------------------------------------------------------------------------------###-----"
line = line .. "\r\n                    # Information on: "..value.." #       "
line = line .. "\r\n -----###-----------------------------------------------------------------------------------------------------------------------------------------------------------------###-----"
line = line .. "\r\n                              Nickname: "..usr.sName
line = line .. "\r\n                              IP: "..usr.sIP
line = line .. "\r\n                              Client: "..usr.sClient.." v."..usr.sClientVersion
line = line .. "\r\n                              Share: "..usr.iShareSize
line = line .. "\r\n                              Mode: "..usr.sMode
line = line .. "\r\n                              Slots: "..usr.iSlots
line = line .. "\r\n                              Hubs: "..usr.iHubs
line = line .. "\r\n                              Bandwidth: "..usr.iBlimit
line = line .. "\r\n                              Description: "..usr.sDescription
line = line .. "\r\n                              Tag: "..usr.sTag
line = line .. "\r\n                              Connection Speed: "..usr.sConnection
line = line .. "\r\n                              Email: "..usr.sEmail
line = line .. "\r\n                              Status: "..tFunc.Online(usr.sName)
line = line .. "\r\n                              Last Login: "..os.date("%A %d %B %Y (%H:%M:%S)", tonumber(sTIME[usr.sName]) )
line = line .. "\r\n -----###-----------------------------------------------------------------------------------------------------------------------------------------------------------------###-----"
sUser:SendData(tSet.BotName, line)
return 1
end
end
end


scripts\userinfo_5.1.lua:18: bad argument #1 to 'pairs' (table expected, got function)

Title: Re: need help with userinfo lua 5.1
Post by: 6Marilyn6Manson6 on 07 November, 2006, 08:29:28
Use this version:

--       Standalone Userinfo Database
--       Created by NightLitch (2005)
------
tSet = {}
tSet.BotName = "-Database-"
tSet.Weeks = 4
sMyINFO = {}
sTIME = {}
sIP = {}
tFunc = {}

function Main()
tFunc.LoadFile("sMyINFO.dat", sMyINFO)
tFunc.LoadFile("sIP.dat", sIP)
tFunc.LoadFile("sTIME.dat", sTIME)
end

function ChatArrival(sUser,sData)
local _,_,Cmd,Arg = string.find(sData, "%b<>%s*(%S+)%s*(.*)%|")
if Cmd == "!cleanlist" and sUser.bOperator then
sUser:SendData(tSet.BotName, tFunc.List() )
return 1
elseif Cmd == "!clean" and sUser.bOperator then
local msg = tFunc.Cleaner()
SendToAll(tSet.BotName, msg)
elseif Cmd == "!getinfo" and sUser.bOperator then
local s,e,value = string.find(Arg, "(%S+)")
if value == nil then sUser:SendData(tSet.BotName, "*** Syntax: !getinfo ") return 1 end
local usr = tFunc.Find(value)
if usr == nil then sUser:SendData(tSet.BotName, "*** Nothing found on "..value) return 1
elseif type(usr) == "string" then sUser:SendData(tSet.BotName, usr) return 1
elseif type(usr) == "table" then
usr = tFunc.SplitMyInfoString(usr.sMyInfoString,usr)
local line = ""
line = line .. "\r\n

-----###-----------------------------------------------------------------------------------------------------------------------------------------------------------------###-----"
line = line .. "\r\n                    # Information on: "..value.." #       "
line = line .. "\r\n

-----###-----------------------------------------------------------------------------------------------------------------------------------------------------------------###-----"
line = line .. "\r\n                              Nickname: "..usr.sName
line = line .. "\r\n                              IP: "..usr.sIP
line = line .. "\r\n                              Client: "..usr.sClient.." v."..usr.sClientVersion
line = line .. "\r\n                              Share: "..usr.iShareSize
line = line .. "\r\n                              Mode: "..usr.sMode
line = line .. "\r\n                              Slots: "..usr.iSlots
line = line .. "\r\n                              Hubs: "..usr.iHubs
line = line .. "\r\n                              Bandwidth: "..usr.iBlimit
line = line .. "\r\n                              Description: "..usr.sDescription
line = line .. "\r\n                              Tag: "..usr.sTag
line = line .. "\r\n                              Connection Speed: "..usr.sConnection
line = line .. "\r\n                              Email: "..usr.sEmail
line = line .. "\r\n                              Status: "..tFunc.Online(usr.sName)
line = line .. "\r\n                              Last Login: "..os.date("%A %d %B %Y (%H:%M:%S)", tonumber(sTIME[usr.sName]) )
line = line .. "\r\n

-----###-----------------------------------------------------------------------------------------------------------------------------------------------------------------###-----"
sUser:SendData(tSet.BotName, line)
return 1
end
end
end

function OnExit()
tFunc.SaveFile("sMyINFO.dat", sMyINFO)
tFunc.SaveFile("sIP.dat", sIP)
tFunc.SaveFile("sTIME.dat", sTIME)
end

function NewUserConnected(sUser)
tFunc.Add(sUser.sName,sUser.sIP, sIP)
tFunc.Add(sUser.sName,sUser.sMyInfoString, sMyINFO)
tFunc.Add(sUser.sName,tFunc.GetTime(), sTIME)
end

function UserDisconnected(sUser)
tFunc.Add(sUser.sName,sUser.sIP, sIP)
tFunc.Add(sUser.sName,sUser.sMyInfoString, sMyINFO)
tFunc.Add(sUser.sName,tFunc.GetTime(), sTIME)
end

tFunc.Online = function(nick)
if GetItemByName(nick) then return "Online" else return "Offline" end
end

tFunc.GetTime = function()
local T = {}
for a,b in ipairs(os.date("*t")) do T[a] = b end
local time = os.time({year = T.year,month = T.month,day = (T.day+(tSet.Weeks*7)),hour = T.hour,min = T.min,sec = T.sec,isdst = T.isdst})
return time
end

tFunc.ShareUnit = function(intSize)
if tonumber(intSize) ~= 0 then
local tUnits = { "Bytes", "KB", "MB", "GB", "TB" }
intSize = tonumber(intSize);
local sUnits;
for index = 1, table.maxn(tUnits)do
if(intSize < 1024) then
sUnits = tUnits[index];
break;
else
intSize = intSize / 1024;
end
end
return string.format("%0.1f %s",intSize, sUnits);
else
return "0 Bytes"
end
end

tFunc.Add = function(nick,value,table)
table[nick] = value
end

tFunc.Remove = function(nick,value,table)
table[nick] = nil
end

tFunc.Cleaner = function()
local t,c = 0,0
for sNick,sTime in ipairs(sTIME) do
t = t + 1
if os.time() > tonumber(sTime) then
c = c + 1
sTIME[sNick] = nil
sMyINFO[sNick] = nil
sIP[sNick] = nil
end
end
OnExit()
return "*** "..c.." / "..t.." users have been deleted from database ***"
end

tFunc.List = function()
local line = "\r\n"
line = line .. "\r\n -----###-----------------------------------------------------------------------------------------------------------------------------------------------------------------###-----"
line = line .. "\r\n                    # Current Clean List #       "
line = line .. "\r\n -----###-----------------------------------------------------------------------------------------------------------------------------------------------------------------###-----"
for sNick,sTime in ipairs(sTIME) do
if os.time() > tonumber(sTime) then
line = line .. "\r\n\t "..sNick.." is last seen "..os.date("%A %d %B %Y (%H:%M:%S)", tonumber(sTime))
end
end
line = line .. "\r\n -----###-----------------------------------------------------------------------------------------------------------------------------------------------------------------###-----"
return line
end

tFunc.Find = function(value)
if string.find(value, "%d+%.%d+%.%d+%.%d+") then
local line = "*** Users found on IP: "..value..": \r\n\r\n"
for nick,ip in ipairs(sIP) do
if ip == value then
line = line .. "\t "..nick.."  ("..tFunc.Online(nick)..")\r\n"
end
end
return line
else
local tUser = GetItemByName(value)
if tUser then
return tUser
else
for nick,ip in ipairs(sIP) do
if string.lower(value) == string.lower(nick) then
return {sName = nick, sIP = sIP[nick], sMyInfoString = sMyINFO[nick]}
end
end
end
end
return
end

tFunc.SplitMyInfoString = function(MyINFO,table)
    local _,_,Descr,Speed,Mail,Share = string.find(MyINFO, "%$MyINFO %$ALL %S+ (.*)%$ %$(.*)%$(%S*)%$%s*(%-*%d*)%$%|$")
    local _,_,Tag = string.find(Descr, "(%b<>)$")
    Tag = Tag or ""
    Descr = string.sub(Descr, 1,string.len(Descr) - string.len(Tag))
    Speed = string.sub(Speed, 1,string.len(Speed) - 1)
    table["sDescription"] = Descr table["sTag"] = Tag table["sConnection"] = Speed table["sEmail"] = Mail table["iShareSize"] = tFunc.ShareUnit(tonumber(Share))
if Tag == "" then return table end
local Limiter = {["B"] = "(%d+)",["L"] = "(%d+)",["F"] = "%d+%/(%d+)"}
local Mode = {["A"] = "Active",["P"] = "Passive", ["5"] = "Socket"}
local TagString, TagTable = Tag, {}
TagString = string.sub(TagString,1,string.len(TagString)-1)
TagString = TagString..","
string.gsub( TagString, "(.):([^,]+),", function( letter, value ) if letter == "O" then return "" end if Limiter[letter] then _,_,value = string.find(value, Limiter[letter]) end

TagTable[letter] = value end)
local _,_,sClient = string.find(TagString, "^(<%S+)%s+")
hubs = 0
if tonumber(TagTable["H"]) == nil then string.gsub(TagTable["H"], "(%d+)", function (num) hubs = hubs +tonumber(num) end) else hubs = tonumber(TagTable["H"])

end
table["sClient"] = sClient
table["sClientVersion"] = TagTable["V"]
table["sMode"] = Mode[TagTable["M"]]
table["iBlimit"] = TagTable["B"] or TagTable["L"] or TagTable["F"] or "unlimited"
table["iSlots"] = TagTable["S"]
table["iHubs"] = hubs
return table
end

tFunc.LoadFile = function(filename,table)
local file,err = io.open(filename, "r")
if err then tFunc.SaveFile(filename, table) return 1 end
for line in file:lines() do
local s,e,nick,value = string.find(line, "(%S+)%|(.*)")
if nick and value ~= "" then
table[nick] = value
end
end
file:close()
end
tFunc.SaveFile = function(filename,table)
local file,err = io.open(filename, "w")
for nick, value in ipairs(table) do
file:write(nick.."|"..value.."\n")
end
file:close()
end
--###------------------------------------------------------###--
OpConnected = NewUserConnected
OpDisconnected = UserDisconnected


And check and put this 3 files in script directory:   sMyINFO.dat   sIP.dat   sTIME.dat
Title: Re: need help with userinfo lua 5.1
Post by: Alexinno on 07 November, 2006, 12:22:06
thnx 6M6M but this version too comes up with the same bug

scripts\userinfo_5.1.lua:17: bad argument #1 to 'ipairs' (table expected, got function)



Title: Re: need help with userinfo lua 5.1
Post by: 6Marilyn6Manson6 on 07 November, 2006, 12:31:36
Try now post update. Done now :P
Title: Re: need help with userinfo lua 5.1
Post by: speedX on 07 November, 2006, 15:18:19
I am getting the following error:

Quote
[19:45] Syntax ...s\0.3.5.1\PtokaX DC Hub 0.3.5.1\scripts\userinfo.lua:197: bad argument #1 to 'ipairs' (table expected, got function)
Title: Re: need help with userinfo lua 5.1
Post by: Alexinno on 07 November, 2006, 18:03:21
me too :(
Title: Re: need help with userinfo lua 5.1
Post by: jiten on 07 November, 2006, 18:56:04
Check your tFunc.LoadFile function, and replace:

for line in ipairs(file:lines()) do

with:

for line in file:lines() do

That should do it.
Title: Re: need help with userinfo lua 5.1
Post by: chao on 07 November, 2006, 19:55:18
Is it possible to show !getinfo for offline users also?? I mean is it possible to make a database where the users info will be saved every time they login??
Title: Re: need help with userinfo lua 5.1
Post by: 6Marilyn6Manson6 on 08 November, 2006, 08:49:30
Quote from: jiten on 07 November, 2006, 18:56:04
Check your tFunc.LoadFile function, and replace:

for line in ipairs(file:lines()) do

with:

for line in file:lines() do

That should do it.

Post update. Thanmks jiten for fixed my distraction:D
Title: Re: need help with userinfo lua 5.1
Post by: speedX on 08 November, 2006, 13:49:05
Hey MM, your script showing the following error:
Quote
[18:16] Syntax ...shil\PtokaX & Scripts\0.3.5.1\PtokaX DC Hub 0.3.5.1\scripts\userinfo.lua:35: unfinished string near '"
Title: Re: need help with userinfo lua 5.1
Post by: Thor on 08 November, 2006, 14:06:48
Change:
Code (lua) Select
line = line .. "\r\n
To:
Code (lua) Select
line = line .. "\r\n"
In lines 35. 39. and 56.
Title: Re: need help with userinfo lua 5.1
Post by: NightLitch on 08 November, 2006, 14:19:24

--       Standalone Userinfo Database
--       Created by NightLitch (2005)
------
tSet = {}
tSet.BotName = "-Database-"
tSet.Weeks = 4
sMyINFO = {}
sTIME = {}
sIP = {}
tFunc = {}

function Main()
tFunc.LoadFile("sMyINFO.dat", sMyINFO)
tFunc.LoadFile("sIP.dat", sIP)
tFunc.LoadFile("sTIME.dat", sTIME)
end

function ChatArrival(sUser,sData)
local _,_,Cmd,Arg = string.find(sData, "%b<>%s*(%S+)%s*(.*)%|")
if Cmd == "!cleanlist" and sUser.bOperator then
sUser:SendData(tSet.BotName, tFunc.List() )
return 1
elseif Cmd == "!clean" and sUser.bOperator then
local msg = tFunc.Cleaner()
SendToAll(tSet.BotName, msg)
elseif Cmd == "!getinfo" and sUser.bOperator then
local s,e,value = string.find(Arg, "(%S+)")
if value == nil then sUser:SendData(tSet.BotName, "*** Syntax: !getinfo ") return 1 end
local usr = tFunc.Find(value)
if usr == nil then sUser:SendData(tSet.BotName, "*** Nothing found on "..value) return 1
elseif type(usr) == "string" then sUser:SendData(tSet.BotName, usr) return 1
elseif type(usr) == "table" then
usr = tFunc.SplitMyInfoString(usr.sMyInfoString,usr)
local line = ""
line = line .. "\r\n "

-----###-----------------------------------------------------------------------------------------------------------------------------------------------------------------###-----"
line = line .. "\r\n                    # Information on: "..value.." #       "
line = line .. "\r\n "

-----###-----------------------------------------------------------------------------------------------------------------------------------------------------------------###-----"
line = line .. "\r\n                              Nickname: "..usr.sName
line = line .. "\r\n                              IP: "..usr.sIP
line = line .. "\r\n                              Client: "..usr.sClient.." v."..usr.sClientVersion
line = line .. "\r\n                              Share: "..usr.iShareSize
line = line .. "\r\n                              Mode: "..usr.sMode
line = line .. "\r\n                              Slots: "..usr.iSlots
line = line .. "\r\n                              Hubs: "..usr.iHubs
line = line .. "\r\n                              Bandwidth: "..usr.iBlimit
line = line .. "\r\n                              Description: "..usr.sDescription
line = line .. "\r\n                              Tag: "..usr.sTag
line = line .. "\r\n                              Connection Speed: "..usr.sConnection
line = line .. "\r\n                              Email: "..usr.sEmail
line = line .. "\r\n                              Status: "..tFunc.Online(usr.sName)
line = line .. "\r\n                              Last Login: "..os.date("%A %d %B %Y (%H:%M:%S)", tonumber(sTIME[usr.sName]) )
line = line .. "\r\n "

-----###-----------------------------------------------------------------------------------------------------------------------------------------------------------------###-----"
sUser:SendData(tSet.BotName, line)
return 1
end
end
end

function OnExit()
tFunc.SaveFile("sMyINFO.dat", sMyINFO)
tFunc.SaveFile("sIP.dat", sIP)
tFunc.SaveFile("sTIME.dat", sTIME)
end

function NewUserConnected(sUser)
tFunc.Add(sUser.sName,sUser.sIP, sIP)
tFunc.Add(sUser.sName,sUser.sMyInfoString, sMyINFO)
tFunc.Add(sUser.sName,tFunc.GetTime(), sTIME)
end

function UserDisconnected(sUser)
tFunc.Add(sUser.sName,sUser.sIP, sIP)
tFunc.Add(sUser.sName,sUser.sMyInfoString, sMyINFO)
tFunc.Add(sUser.sName,tFunc.GetTime(), sTIME)
end

tFunc.Online = function(nick)
if GetItemByName(nick) then return "Online" else return "Offline" end
end

tFunc.GetTime = function()
local T = {}
for a,b in ipairs(os.date("*t")) do T[a] = b end
local time = os.time({year = T.year,month = T.month,day = (T.day+(tSet.Weeks*7)),hour = T.hour,min = T.min,sec = T.sec,isdst = T.isdst})
return time
end

tFunc.ShareUnit = function(intSize)
if tonumber(intSize) ~= 0 then
local tUnits = { "Bytes", "KB", "MB", "GB", "TB" }
intSize = tonumber(intSize);
local sUnits;
for index = 1, table.maxn(tUnits)do
if(intSize < 1024) then
sUnits = tUnits[index];
break;
else
intSize = intSize / 1024;
end
end
return string.format("%0.1f %s",intSize, sUnits);
else
return "0 Bytes"
end
end

tFunc.Add = function(nick,value,table)
table[nick] = value
end

tFunc.Remove = function(nick,value,table)
table[nick] = nil
end

tFunc.Cleaner = function()
local t,c = 0,0
for sNick,sTime in ipairs(sTIME) do
t = t + 1
if os.time() > tonumber(sTime) then
c = c + 1
sTIME[sNick] = nil
sMyINFO[sNick] = nil
sIP[sNick] = nil
end
end
OnExit()
return "*** "..c.." / "..t.." users have been deleted from database ***"
end

tFunc.List = function()
local line = "\r\n"
line = line .. "\r\n -----###-----------------------------------------------------------------------------------------------------------------------------------------------------------------###-----"
line = line .. "\r\n                    # Current Clean List #       "
line = line .. "\r\n -----###-----------------------------------------------------------------------------------------------------------------------------------------------------------------###-----"
for sNick,sTime in ipairs(sTIME) do
if os.time() > tonumber(sTime) then
line = line .. "\r\n\t "..sNick.." is last seen "..os.date("%A %d %B %Y (%H:%M:%S)", tonumber(sTime))
end
end
line = line .. "\r\n -----###-----------------------------------------------------------------------------------------------------------------------------------------------------------------###-----"
return line
end

tFunc.Find = function(value)
if string.find(value, "%d+%.%d+%.%d+%.%d+") then
local line = "*** Users found on IP: "..value..": \r\n\r\n"
for nick,ip in ipairs(sIP) do
if ip == value then
line = line .. "\t "..nick.."  ("..tFunc.Online(nick)..")\r\n"
end
end
return line
else
local tUser = GetItemByName(value)
if tUser then
return tUser
else
for nick,ip in ipairs(sIP) do
if string.lower(value) == string.lower(nick) then
return {sName = nick, sIP = sIP[nick], sMyInfoString = sMyINFO[nick]}
end
end
end
end
return
end

tFunc.SplitMyInfoString = function(MyINFO,table)
    local _,_,Descr,Speed,Mail,Share = string.find(MyINFO, "%$MyINFO %$ALL %S+ (.*)%$ %$(.*)%$(%S*)%$%s*(%-*%d*)%$%|$")
    local _,_,Tag = string.find(Descr, "(%b<>)$")
    Tag = Tag or ""
    Descr = string.sub(Descr, 1,string.len(Descr) - string.len(Tag))
    Speed = string.sub(Speed, 1,string.len(Speed) - 1)
    table["sDescription"] = Descr table["sTag"] = Tag table["sConnection"] = Speed table["sEmail"] = Mail table["iShareSize"] = tFunc.ShareUnit(tonumber(Share))
if Tag == "" then return table end
local Limiter = {["B"] = "(%d+)",["L"] = "(%d+)",["F"] = "%d+%/(%d+)"}
local Mode = {["A"] = "Active",["P"] = "Passive", ["5"] = "Socket"}
local TagString, TagTable = Tag, {}
TagString = string.sub(TagString,1,string.len(TagString)-1)
TagString = TagString..","
string.gsub( TagString, "(.):([^,]+),", function( letter, value ) if letter == "O" then return "" end if Limiter[letter] then _,_,value = string.find(value, Limiter[letter]) end

TagTable[letter] = value end)
local _,_,sClient = string.find(TagString, "^(<%S+)%s+")
hubs = 0
if tonumber(TagTable["H"]) == nil then string.gsub(TagTable["H"], "(%d+)", function (num) hubs = hubs +tonumber(num) end) else hubs = tonumber(TagTable["H"])

end
table["sClient"] = sClient
table["sClientVersion"] = TagTable["V"]
table["sMode"] = Mode[TagTable["M"]]
table["iBlimit"] = TagTable["B"] or TagTable["L"] or TagTable["F"] or "unlimited"
table["iSlots"] = TagTable["S"]
table["iHubs"] = hubs
return table
end

tFunc.LoadFile = function(filename,table)
local file,err = io.open(filename, "r")
if err then tFunc.SaveFile(filename, table) return 1 end
for line in file:lines() do
local s,e,nick,value = string.find(line, "(%S+)%|(.*)")
if nick and value ~= "" then
table[nick] = value
end
end
file:close()
end
tFunc.SaveFile = function(filename,table)
local file,err = io.open(filename, "w")
for nick, value in ipairs(table) do
file:write(nick.."|"..value.."\n")
end
file:close()
end
--###------------------------------------------------------###--
OpConnected = NewUserConnected
OpDisconnected = UserDisconnected


Hopefully this one works then
Title: Re: need help with userinfo lua 5.1
Post by: speedX on 08 November, 2006, 14:33:28
Yes it works, but after some time it shows the following error, donno y

Quote
[19:00] Syntax ...s\0.3.5.1\PtokaX DC Hub 0.3.5.1\scripts\userinfo.lua:90: attempt to perform arithmetic on field 'day' (a nil value)
Title: Re: need help with userinfo lua 5.1
Post by: Toobster?? on 08 November, 2006, 17:38:01
6Marilyn6Manson6 it might be a nice idea in future when you butcher other peoples scripts and post them full of bugs to include -

-- Script butchered by 6Marilyn6Manson6

That way the original script writer wont get the blame for your errors  ::)

Another good idea might be to TEST scripts before posting  ::)

Other than that, keep up the good work 6Marilyn6Manson6  :P
Title: Re: need help with userinfo lua 5.1
Post by: 6Marilyn6Manson6 on 09 November, 2006, 08:37:13
Im sorry but I can't tested my modded in script, I see error and fixed it :D
Title: Re: need help with userinfo lua 5.1
Post by: speedX on 09 November, 2006, 15:29:54
Quote from: chao on 07 November, 2006, 19:55:18
Is it possible to show !getinfo for offline users also?? I mean is it possible to make a database where the users info will be saved every time they login??

Would this be possible, even I am interested.....
Title: Re: need help with userinfo lua 5.1
Post by: Alexinno on 14 November, 2006, 15:41:47
So enybody can help fix this error ?
19:00] Syntax ...s\0.3.5.1\PtokaX DC Hub 0.3.5.1\scripts\userinfo.lua:90: attempt to perform arithmetic on field 'day' (a nil value)
Posted on: 09 November 2006, 17:07:46
so ... nobody can make this script to work ? :(