PtokaX forum

Archive => Archived 5.0 boards => Request for scripts => Topic started by: ruler on 16 June, 2005, 18:34:46

Title: [LUA 5]on server stop, saving user info
Post by: ruler on 16 June, 2005, 18:34:46
hi
just a quick question to anyone that might know!
when you click [stop server] all the users in the hub just disconnect and server stops but i want the hub to save the nicks of all the users who are in the hub to a text file when the hub stops. does anyone know how or if this can be done?
thanks
Title:
Post by: Dessamator on 16 June, 2005, 20:12:25
oooh, i see u want to learn how to do so, ok here are some hints:

1. When then hub is closed or script restarted the OnExit function automatically kicks in !

2. You have to use a loop to pass through the users in the user list or online users and then add each username(nick)  to a variable.

3. Write the variable to a file .

and voila,
Title:
Post by: ruler on 16 June, 2005, 20:45:30
ok i understand how to do no.1 and no.3 but im not too sure how to do no.2? any tips?
Title:
Post by: Dessamator on 16 June, 2005, 22:53:26
--No 3. is simple look in the api aka Scripting-Interface.txt for clues , basically u need to find the table of logged users, collect each userName and store it in a variable !

P.S variable is something like temp="dd"

the variable is "temp"
Title:
Post by: Dessamator on 16 June, 2005, 23:08:27
lol, mutor he was trying to do on his own, ur
spoon-feeding him  !
Title:
Post by: Dessamator on 16 June, 2005, 23:29:19
oooh, ok hehe, seems im wrong again, its just that spoon feeding newbies, just makes them lazy, and ask simple question, while they could learn easily !
Title:
Post by: ruler on 16 June, 2005, 23:36:38
possum  hehe, ive not heard that one for some time  :D
anyway thanks for the help, btw Mutor that bit of code does look familar. i remember doing something like that in the old ' Inspector ' script.
Dessamator its not spoon-feeding at all, i DID post in the ' Request for scripts ' section  ;)
i am basically just trying to design a last seen script and with a built in auto dereg user if they havent logged in for a long period of a given time.
once i get it working properly i will recode it again and again until the code is smaller and better. aint LUA fun  :D
Title:
Post by: Dessamator on 17 June, 2005, 00:14:54
yep i forgot what section of the forum we were in, either way since this is the case

for the number 2 hint i meant something like this :

function OnExit()
local temp ="logged users\r\n"
        for _,nick in frmHub:GetOnlineUsers() do
                  temp=temp..nick.."\r\n"
        end
-- write temp to a file
end
Title:
Post by: ruler on 17 June, 2005, 00:43:46
nice bit of code and so to obmit the unreg users from that i could use...

code:--------------------------------------------------------------------------------
function OnExit()
local temp ="logged users\r\n"
   for _,nick in frmHub:GetOnlineUsers() do
      if nick.iProfile ~= -1 then
      temp=temp..nick.."\r\n"
      end
   end
-- write temp to a file
end
--------------------------------------------------------------------------------
Hmm i might just give that a go :)  thanks
Title:
Post by: Dessamator on 17 June, 2005, 09:31:20
ur welcome
Title:
Post by: ruler on 17 June, 2005, 14:44:02
just tested your version of that script you posted and i get errors...

local ' nick ' a table value

cant see the error msg cos it flashes quick and disapears but its there
Title:
Post by: Dessamator on 17 June, 2005, 15:32:31
indeed, there should b an error, forgot something :

function OnExit()

local temp ="logged users\r\n"
        for _,nick in frmHub:GetOnlineUsers() do
                  temp=temp..nick[COLOR=blue].sName[/COLOR] .."\r\n"
        end
-- write temp to a file
end


add the part in blue, and it should work, that happens because the table has objects and not "normal" items.