[LUA 5]on server stop, saving user info
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

[LUA 5]on server stop, saving user info

Started by ruler, 16 June, 2005, 18:34:46

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ruler

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

The Direct Connect Global Banlist get protected.

Dessamator

#1
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,
Ignorance is Bliss.

ruler

ok i understand how to do no.1 and no.3 but im not too sure how to do no.2? any tips?

The Direct Connect Global Banlist get protected.

Dessamator

#3
--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"
Ignorance is Bliss.

Dessamator

lol, mutor he was trying to do on his own, ur
spoon-feeding him  !
Ignorance is Bliss.

Dessamator

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 !
Ignorance is Bliss.

ruler

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

The Direct Connect Global Banlist get protected.

Dessamator

#7
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
Ignorance is Bliss.

ruler

#8
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

The Direct Connect Global Banlist get protected.

Dessamator

Ignorance is Bliss.

ruler

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

The Direct Connect Global Banlist get protected.

Dessamator

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.
Ignorance is Bliss.

SMF spam blocked by CleanTalk