Author Topic: User Login Log Help me...  (Read 3041 times)

0 Members and 1 Guest are viewing this topic.

Offline NightLitch

  • Emperor
  • **
  • Posts: 1 455
  • Karma: +16/-0
User Login Log Help me...
« on: 13 November, 2003, 20:38:30 »
Hey Guy''s!

I have a problem solving a problem am out of idees
or should I say don't know what/how to do the function...  :))

This Is what I have done

Code: [Select]
----------------------------
--[ User Logger Function ]--
----------------------------
function DoUserLogger(curUser,data)
local nick = GetItemByName(curUser.sName)
if USERLOGGER[strlower(nick)] == nil or USERLOGGER[strlower(nick)] == "" then
SendToAll("NOT IN FILE, GETTING LOGGED")
USERLOGGER[strlower(curUser.sName)] = "online"
else
if strlower(nick) == USERLOGGER[strlower(nick)] then
SendToAll("LOGGED IN TABLE/FILE")
end
end
end

function LoggerControl(curUser,data)

-- Here I want To check if users are online or not when restarting the hubsoft
-- Cause the file won't get emty if restarting the hubsoft...
-- How Would I Do This.... Help... Me...

if GetItemByName(USERLOGGER) == 1 then

-- something or not

end
end

I want in Main() to check the file if user is logged in or not... or a better solusion how will I create a usefull
logger that will not emty the table if script being restarted..? (yes, log into a file BUT! how will the file get
erased if hub is shutdown or restarted??)

everyone understand my english... ?    ?(

Come With idees plz... or better solusions... :D

/NightLitch
//NL

PtokaX forum

User Login Log Help me...
« on: 13 November, 2003, 20:38:30 »

Offline pHaTTy

  • Forum Legend
  • ***
  • Posts: 1 916
  • Karma: +5/-1
(No subject)
« Reply #1 on: 13 November, 2003, 20:43:38 »
for erasing the file use a function like this

function OnExit()
openfile("Whereever/file.txt" "w")
Write(" ")
closefile()
end


sumit like that yep :)
Resistance is futile!

Offline NightLitch

  • Emperor
  • **
  • Posts: 1 455
  • Karma: +16/-0
(No subject)
« Reply #2 on: 13 November, 2003, 20:46:41 »
will that work???

have tried before...

but will try again... optimist as I am... heh

ThX

/NightLitch
//NL

Offline NightLitch

  • Emperor
  • **
  • Posts: 1 455
  • Karma: +16/-0
(No subject)
« Reply #3 on: 13 November, 2003, 21:21:30 »
How come when I use this function and stop the hub and start
it again the script's arent loaded????

something wrong in my function???


function OnExit()
   local f = openfile(LOGGERFILE, "w")
   write(f, " ")
   closefile(f)
end


/NightLitch
//NL

Offline NightLitch

  • Emperor
  • **
  • Posts: 1 455
  • Karma: +16/-0
(No subject)
« Reply #4 on: 13 November, 2003, 21:24:22 »
Ok got the funtion working


function OnExit()
   local f = openfile(LOGGERFILE, "w")
   if f == nil then
   else
   write(f, " ")
   closefile(f)
   end
end


But when starting the hub again the script are not loaded why???

/NightLitch
//NL

Offline NightLitch

  • Emperor
  • **
  • Posts: 1 455
  • Karma: +16/-0
(No subject)
« Reply #5 on: 13 November, 2003, 21:38:01 »
Reopened...


In the new hubsoft I get a problem when restarting the script...

The Log-File is getting erased when restarting script... not good.... why???

« Last Edit: 13 November, 2003, 21:53:59 by NightLitch »
//NL

Offline plop

  • Forum God
  • ****
  • Posts: 2 464
  • Karma: +37/-0
(No subject)
« Reply #6 on: 13 November, 2003, 23:14:43 »
remove(filename)
thats all you need 2 delete a file.

for closing you don't need 2 say wich file.
closefile()    is enough.

plop

* edit: not 2 sure but the way you try 2 close the file could cause it not 2 be closed an then you get an error on restart of the script because the file is in use.
not 2 sure do.
« Last Edit: 13 November, 2003, 23:17:01 by plop »
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

Offline NightLitch

  • Emperor
  • **
  • Posts: 1 455
  • Karma: +16/-0
(No subject)
« Reply #7 on: 13 November, 2003, 23:23:25 »
Think you missed my problem, When I restart The scripts
the OnExit () trigger as well, shouldn't it only trigger when hubsoft
getting closed or turned off...

My Online User Table(file) is being erased when restarting script....

And That is not the way I want it...

I use last script above...

/NightLitch
« Last Edit: 13 November, 2003, 23:23:56 by NightLitch »
//NL

Offline pHaTTy

  • Forum Legend
  • ***
  • Posts: 1 916
  • Karma: +5/-1
(No subject)
« Reply #8 on: 14 November, 2003, 00:03:56 »
Hmmm, maybe because OnExit has not been perfected, needs to be only on hubclose, but it seems to be on restart as well :/
Resistance is futile!

Offline plop

  • Forum God
  • ****
  • Posts: 2 464
  • Karma: +37/-0
(No subject)
« Reply #9 on: 14 November, 2003, 00:58:49 »
what i remember is that it was the idea 2 trigger it on a restart of the scripts and on a full hub restart.
that way you can save any temp files you want.
only making it trigger on a hub restart makes it in my eyes only work half.
what you can do in your case is save the online table 2 a 2de file, and on function main() check for the amount of users.
on a script restart that will be ~= 0 so you load the temp file.
if there are no users you build a new empty table.
i hope you get my idea and that i did get your idea, really sleepy @ the moment.

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

PtokaX forum

(No subject)
« Reply #9 on: 14 November, 2003, 00:58:49 »