Could someone please help me convert this script to lua 5???????
-- A simple logon logger by piglja - 25/04/03
-- Updated and modifyed a bit by piglja - 28/04/03
-- A bug by piglja fixed by piglja;P - 28/04/03
-- An update that Ops are logged too and disconnect are logged by piglja - 28/04/03
file_logon = "logon.txt"
function NewUserConnected(user)
description,speed,email,share=MyInfoString(user.sMyInfoString)
local share2 = share / (1024*1024*1024)
ip = user.sIP
appendto(file_logon)
write("-->> "..user.sName..","..date("%d").."."..date("%m").."."..date("%y").." - "..date("%H")..":"..date("%M").." - with:"..speed.." IP "..ip..", e-mail "..email.." with "..share2.."Gb \r\n")
writeto()
end
function OpConnected(user)
description,speed,email,share=MyInfoString(user.sMyInfoString)
local share2 = share / (1024*1024*1024)
ip = user.sIP
appendto(file_logon)
write("-->> "..user.sName..","..date("%d").."."..date("%m").."."..date("%y").." - "..date("%H")..":"..date("%M").." - with:"..speed.." IP "..ip..", e-mail "..email.." with "..share2.."Gb \r\n")
writeto()
end
function UserDisconnected(user)
description,speed,email,share=MyInfoString(user.sMyInfoString)
local share2 = share / (1024*1024*1024)
ip = user.sIP
appendto(file_logon)
write("<<-- "..user.sName..","..date("%d").."."..date("%m").."."..date("%y").." - "..date("%H")..":"..date("%M").." - with:"..speed.." IP "..ip..", e-mail "..email.." with "..share2.."Gb \r\n")
writeto()
end
function OpDisconnected(user)
description,speed,email,share=MyInfoString(user.sMyInfoString)
local share2 = share / (1024*1024*1024)
ip = user.sIP
appendto(file_logon)
write("<<-- "..user.sName..","..date("%d").."."..date("%m").."."..date("%y").." - "..date("%H")..":"..date("%M").." - with:"..speed.." IP "..ip..", e-mail "..email.." with "..share2.."Gb \r\n")
writeto()
end
function MyInfoString(data)
s,e,description,speed,email,share = strfind(data, "$MyINFO $ALL ([^$]+)$ $([^$]*)$([^$]*)$([^$]+)")
if speed~=nil then
speed = strsub(speed,1,strlen(speed)-1)
end
return description,speed,email,share
end
all parts with ..date
need replacing with ..os.date
:)
Thank you, I did as you said, but there is nothing being written to logon.txt file
Also I am getting: logon_bot.lua:45: attempt to call global `strfind' (a nil value)
Now the script is changed to this:
Quote-- A simple logon logger by piglja - 25/04/03
-- Updated and modifyed a bit by piglja - 28/04/03
-- A bug by piglja fixed by piglja;P - 28/04/03
-- An update that Ops are logged too and disconnect are logged by piglja - 28/04/03
file_logon = "logon.txt"
function NewUserConnected(user)
description,speed,email,share=MyInfoString(user.sMyInfoString)
local share2 = share / (1024*1024*1024)
ip = user.sIP
appendto(file_logon)
write("-->> "..user.sName..","..os.date("%d").."."..os.date("%m").."."..os.date("%y").." - "..os.date("%H")..":"..os.date("%M").." - with:"..speed.." IP "..ip..", e-mail "..email.." with "..share2.."Gb \r\n")
writeto()
end
function OpConnected(user)
description,speed,email,share=MyInfoString(user.sMyInfoString)
local share2 = share / (1024*1024*1024)
ip = user.sIP
appendto(file_logon)
write("-->> "..user.sName..","..os.date("%d").."."..date("%m").."."..os.date("%y").." - "..os.date("%H")..":"..os.date("%M").." - with:"..speed.." IP "..ip..", e-mail "..email.." with "..share2.."Gb \r\n")
writeto()
end
function UserDisconnected(user)
description,speed,email,share=MyInfoString(user.sMyInfoString)
local share2 = share / (1024*1024*1024)
ip = user.sIP
appendto(file_logon)
write("<<-- "..user.sName..","..os.date("%d").."."..os.date("%m").."."..os.date("%y").." - "..os.date("%H")..":"..os.date("%M").." - with:"..speed.." IP "..ip..", e-mail "..email.." with "..share2.."Gb \r\n")
writeto()
end
function OpDisconnected(user)
description,speed,email,share=MyInfoString(user.sMyInfoString)
local share2 = share / (1024*1024*1024)
ip = user.sIP
appendto(file_logon)
write("<<-- "..user.sName..","..os.date("%d").."."..os.date("%m").."."..os.date("%y").." - "..os.date("%H")..":"..os.date("%M").." - with:"..speed.." IP "..ip..", e-mail "..email.." with "..share2.."Gb \r\n")
writeto()
end
function MyInfoString(data)
s,e,description,speed,email,share = strfind(data, "$MyINFO $ALL ([^$]+)$ $([^$]*)$([^$]*)$([^$]+)")
if speed~=nil then
speed = strsub(speed,1,strlen(speed)-1)
end
return description,speed,email,share
end
TIA
try
string.find
QuoteOriginally posted by YASHOV
Also I am getting: logon_bot.lua:45: attempt to call global `strfind' (a nil value)
All parts with
Quotestrfind
need replacing with -> string.find !!!
and all parts with
Quotestrsub
need replacing with -> string.sub !!!
:D :] ;)
Thank you very , I made the changes as you said, but there is still nothing being written to logon.txt file
Also I am now getting: logon_bot.lua:47: attempt to call global `strlen' (a nil value)
Now the script is changed to this:
Quote-- A simple logon logger by piglja - 25/04/03
-- Updated and modifyed a bit by piglja - 28/04/03
-- A bug by piglja fixed by piglja;P - 28/04/03
-- An update that Ops are logged too and disconnect are logged by piglja - 28/04/03
file_logon = "logon.txt"
function NewUserConnected(user)
description,speed,email,share=MyInfoString(user.sMyInfoString)
local share2 = share / (1024*1024*1024)
ip = user.sIP
appendto(file_logon)
write("-->> "..user.sName..","..os.date("%d").."."..os.date("%m").."."..os.date("%y").." - "..os.date("%H")..":"..os.date("%M").." - with:"..speed.." IP "..ip..", e-mail "..email.." with "..share2.."Gb \r\n")
writeto()
end
function OpConnected(user)
description,speed,email,share=MyInfoString(user.sMyInfoString)
local share2 = share / (1024*1024*1024)
ip = user.sIP
appendto(file_logon)
write("-->> "..user.sName..","..os.date("%d").."."..date("%m").."."..os.date("%y").." - "..os.date("%H")..":"..os.date("%M").." - with:"..speed.." IP "..ip..", e-mail "..email.." with "..share2.."Gb \r\n")
writeto()
end
function UserDisconnected(user)
description,speed,email,share=MyInfoString(user.sMyInfoString)
local share2 = share / (1024*1024*1024)
ip = user.sIP
appendto(file_logon)
write("<<-- "..user.sName..","..os.date("%d").."."..os.date("%m").."."..os.date("%y").." - "..os.date("%H")..":"..os.date("%M").." - with:"..speed.." IP "..ip..", e-mail "..email.." with "..share2.."Gb \r\n")
writeto()
end
function OpDisconnected(user)
description,speed,email,share=MyInfoString(user.sMyInfoString)
local share2 = share / (1024*1024*1024)
ip = user.sIP
appendto(file_logon)
write("<<-- "..user.sName..","..os.date("%d").."."..os.date("%m").."."..os.date("%y").." - "..os.date("%H")..":"..os.date("%M").." - with:"..speed.." IP "..ip..", e-mail "..email.." with "..share2.."Gb \r\n")
writeto()
end
function MyInfoString(data)
s,e,description,speed,email,share = string.find(data, "$MyINFO $ALL ([^$]+)$ $([^$]*)$([^$]*)$([^$]+)")
if speed~=nil then
speed = string.sub(speed,1,strlen(speed)-1)
end
return description,speed,email,share
end
Thank you
this can use some optimization
-- A simple logon logger by piglja - 25/04/03
-- Updated and modifyed a bit by piglja - 28/04/03
-- A bug by piglja fixed by piglja;P - 28/04/03
-- An update that Ops are logged too and disconnect are logged by piglja - 28/04/03
file_logon = "logon.txt"
function NewUserConnected(user)
description,speed,email,share=MyInfoString(user.sMyInfoString)
local share2 = share / (1024*1024*1024)
ip = user.sIP
fileHandle = io.open(file_logon,"a+")
fileHandle:write("-->> "..user.sName..","..os.date("%d").."."..os.date("%m").."."..os.date("%y").." - "..os.date("%H")..":"..os.date("%M").." - with:"..speed.." IP "..ip..", e-mail "..email.." with "..share2.."Gb \r\n")
fileHandle:flush()
fileHandle:close()
end
function OpConnected(user)
description,speed,email,share=MyInfoString(user.sMyInfoString)
local share2 = share / (1024*1024*1024)
ip = user.sIP
fileHandle = io.open(file_logon,"a+")
fileHandle:write("-->> "..user.sName..","..os.date("%d").."."..date("%m").."."..os.date("%y").." - "..os.date("%H")..":"..os.date("%M").." - with:"..speed.." IP "..ip..", e-mail "..email.." with "..share2.."Gb \r\n")
fileHandle:flush()
fileHandle:close()
end
function UserDisconnected(user)
description,speed,email,share=MyInfoString(user.sMyInfoString)
local share2 = share / (1024*1024*1024)
ip = user.sIP
fileHandle = io.open(file_logon,"a+")
fileHandle:write("<<-- "..user.sName..","..os.date("%d").."."..os.date("%m").."."..os.date("%y").." - "..os.date("%H")..":"..os.date("%M").." - with:"..speed.." IP "..ip..", e-mail "..email.." with "..share2.."Gb \r\n")
fileHandle:flush()
fileHandle:close()
end
function OpDisconnected(user)
description,speed,email,share=MyInfoString(user.sMyInfoString)
local share2 = share / (1024*1024*1024)
ip = user.sIP
fileHandle = io.open(file_logon,"a+")
fileHandle:write("<<-- "..user.sName..","..os.date("%d").."."..os.date("%m").."."..os.date("%y").." - "..os.date("%H")..":"..os.date("%M").." - with:"..speed.." IP "..ip..", e-mail "..email.." with "..share2.."Gb \r\n")
fileHandle:flush()
fileHandle:close()
end
function MyInfoString(data)
s,e,description,speed,email,share = string.find(data, "$MyINFO $ALL ([^$]+)$ $([^$]*)$([^$]*)$([^$]+)")
if speed~=nil then
speed = string.sub(speed,1,string.len(speed)-1)
end
return description,speed,email,share
end
Hi,
Check out plop 425 convertor there you all modifications that you have to make, or you can also check the LUA 5 manual that you can find in http://www.lua.org
Best regards, nErBoS