PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: Themaster on 05 January, 2005, 20:40:36

Title: Need a Nick/ip
Post by: Themaster on 05 January, 2005, 20:40:36
Need a script that do some log of connected user like

+getnick -- The nick name and ip and the connected on / off time
+showall -- Show's all name and ip..
and last i do have a clear function...and i want it to clear on a week example !

i Do Realy need it  ;(
Title:
Post by: Themaster on 06 January, 2005, 17:29:14
Help...i can't get it to save to fil
There are no Error on it


UserInfo = {}
Log = "UserLog.dat"

function Main()
   LoadFromFile(Log)
end

function OnExit()
   SaveToFile(MyInfoFile , UserInfo , "UserLog")
end

function SaveUserInfo()
   SaveToFile(MyInfoFile , UserInfo , "UserLog")
end

function NewUserConnected(user,data)
   local tLogins = 1
   local tmp = UserInfo[user.sName]
   if tmp then
      tLogins = tmp["LOGINS"]+1
   end
   UserInfo[user.sName] = {["IP"]=user.sIP,["PROFILE"]=user.iProfile,["TIME"]=GetTime,["MYINFO"]=user.sMyInfoString,["ONLINE"]="YES",["LOGINS"]=tLogins}
end

function UserDisconnected(user,data)
   local tmp = UserInfo[user.sName]
if tmp then
UserInfo[user.sName] = {["IP"]=user.sIP,["PROFILE"]=user.iProfile,["TIME"]=GetTime,["MYINFO"]=user.sMyInfoString,["ONLINE"]="NO",["LOGINS"]=tmp["LOGINS"]}
end
end

OpConnected = NewUserConnected
OpDisConnected = UserDisconnected

function Serialize(tTable, sTableName, sTab)
assert(tTable, "tTable equals nil");
assert(sTableName, "sTableName equals nil");
assert(type(tTable) == "table", "tTable must be a table!");
assert(type(sTableName) == "string", "sTableName must be a string!");
sTab = sTab or "";
sTmp = ""
sTmp = sTmp..sTab..sTableName.." = {\n"
for key, value in tTable do
local sKey = (type(key) == "string") and format("[%q]",key) or format("[%d]",key);
if(type(value) == "table") then
sTmp = sTmp..Serialize(value, sKey, sTab.."\t");
else
local sValue = (type(value) == "string") and format("%q",value) or tostring(value);
sTmp = sTmp..sTab.."\t"..sKey.." = "..sValue
end
sTmp = sTmp..",\n"
end
sTmp = sTmp..sTab.."}"
return sTmp
end

function SaveToFile(file , table , tablename)
writeto(file)
write(Serialize(table, tablename))
writeto()
end

function LoadFromFile(file)
if (readfrom(file) ~= nil) then
readfrom(file)
dostring(read("*all"))
readfrom()
end
end
Title:
Post by: bastya_elvtars on 06 January, 2005, 22:15:09
convert table to string as you would define it, otherwise won't work.
Title:
Post by: Themaster on 07 January, 2005, 08:09:39
i can't get it to work wright :s please help me on it
Title:
Post by: blackwings on 07 January, 2005, 09:33:52
well, here is a IP/Nick logger that saves the Nick + IP of users. Themaster, you can now just add the comands(+ what they should do) and a function that loads from file.

--//IP/Nick Logger - Made by blackwings


Bot = "ipNick-Logger"

--------------------------------------------------------------------------------------------------
function DataArrival(user,data)
if (strsub(data, 1, 8) == "$Version") then
msg = "["..date("%T").."] - <"..user.sName.."><"..user.sIP..">"
StoreLog(user.sName, msg)
end
end
--------------------------------------------------------------------------------------------------
function StoreLog(nick, msg)
   local sDate = gsub(date("%x"), "%D", "-")
   appendto("IPNickLogger/"..sDate.."-ipNick.log")
   write(msg.."\n")
   writeto()
   msg = nil
end
--------------------------------------------------------------------------------------------------
Title:
Post by: Themaster on 07 January, 2005, 09:57:39
hmmm i can't get any thing work's ;(
Title:
Post by: Themaster on 07 January, 2005, 16:26:14
i can't get it wright have try to do it....: ?(  Don't no have to do it any more....plz..help me on it
Title:
Post by: Themaster on 08 January, 2005, 18:26:13
i try to make this now...But it want do anything please help on it

UserInfo = {}

sOffline = "UserLog.lst"

function NewUserConnected(user,data)
   LogInfo(user)
end

LogInfo = function(user)
dofile(sOffline)
   UserInfo[""..strlower(user.sName)..""] = {["IP"]=user.sIP,["PROFILE"]=user.iProfile,["MYINFO"]=user.sMyInfoString,["Seen"]=date("%m/%d/%y"),}
   Save_File(sOffline, UserInfo , "UserInfo")
return 1
end

function UserInfo()
   writeto("Blade/lst/sOffline.lst")
   for a,b in sOffline do
      write(a.."\n")
   end
   writeto()
end

function LoadUserLog()
   readfrom("Blade/lst/sOffline.lst")
   while 1 do
      local line = read()
      if line == nil then
         readfrom()
         break
      end
      UserLog[line] = 1
   end
end


i'm stuck on it i can't get it right :s I'm Realy lost...please help
Title:
Post by: Themaster on 09 January, 2005, 13:53:03
i realy need some help on that script Nothin work on it HELP ME!!!!!!
Title:
Post by: Themaster on 09 January, 2005, 17:03:50
Can't Get it functionel PLEASE help me out
Title:
Post by: Themaster on 09 January, 2005, 17:15:50
K...No have some thing's 2 say :s
Title:
Post by: Themaster on 09 January, 2005, 17:31:42
k...Never mind :s