PtokaX forum

Development Section => LUA & PtokaX-Scripting-Interface => Topic started by: ruspant on 11 September, 2004, 03:20:07

Title: Lua & Ptokax logged user list
Post by: ruspant on 11 September, 2004, 03:20:07
I'm trying to get the entire logged user list inside a script which perform timed checks on users.
The problem is I can't find a function to get the entire list in one time.
If I use GetProfiles-GetProfileName-GetUsersByProfile i miss the unregged users.
The only solution I've found is pretty ugly..... I'm monitoring the $GetINFO string inside DataArrival to build a Nick table which I keep clean checking if users still exists every 3-4 mins. :(
Since this table is empty when the script starts, I've tried to send the command for getting the list once at start:
SendToAll("$GetNickList")
but nothing happens.....
Things start working when I (or another users) refresh the client user list .
Please, help me to find a better solution at this problem.
Regards
Title:
Post by: Herodes on 11 September, 2004, 12:12:58
Are you trying to get just the nicks ?
or you want to have their MyINFO available too ?
basically u should grab the MyINFO's and then put any of the information they provide in a table under the nick ...

when the user disconnects you should remove his part of the table so that the table conforms to the existing situation ..
Title:
Post by: ruspant on 11 September, 2004, 13:27:09
First, let me say I know very little about the protocol. I've written a little script to put any DataArrival back in pvt and start observing....

What i would like to do is that my script should build the logged nick table at his startup.
Then I can use connect/disconnect events to keep nick table updated.

Up to now it rebuilds the table each time any user is loggin in ... not so nice.

Is there any way to access logged user list on ptokax ?
Title:
Post by: Herodes on 11 September, 2004, 13:54:18
Unfortunately at present there is not a way to access the userlist through script.
But you can use the DataArrival to built a table ..
It would be nice to see the script so we/I can comment advice on something :)
Title:
Post by: plop on 11 September, 2004, 16:02:31
check my micro_chatroom series for some hints 2 do it without a timer.

plop
Title:
Post by: ruspant on 11 September, 2004, 17:45:02
Ok plop, it's nice to use the NewUserConnected and OpConnected functions to keep the logged nick table updated.

But if I stop my script and restart it at any time, the table will be empty and start building again for the new connections only.

What I'm trying to do is a sort of "GetUserConnectedAtThisTime" function which is not affected by script restarting.

I think it's quite amazing that a so basic function isn't yet exported by ptokax to lua.... hoping for future release but meanwhile I'm still in trouble....  :(
Title:
Post by: plop on 11 September, 2004, 22:46:06
piece from micro_chatroom v3.
function DataArrival(user, data)
   if tUsers[user.iProfile] == nil then
      tUsers[user.iProfile] = {}
   end
   if tUsers[user.iProfile][user.sName] == nil then
      tUsers[user.iProfile][user.sName] = 1
   end
thats why i also check on dataarival.
that solves the restart problem.
but indeed it won't give a instand update.

plop
Title:
Post by: ruspant on 14 September, 2004, 22:59:13
thx plop
I've missed it the first time ! ^__^
Yes, it's not immediate but it's a quite fast way to build up the table

ruspant
Title:
Post by: HaArD on 16 September, 2004, 15:01:17
ruspant,

Keep asking for it...  I have also wondered why such a simple, straightforward, thing as a list of active Nicks in the hub cannot be supplied to the scripting interface in a constantly updated state.

I can tell you for sure that as of .330 b15.30 it has not been added to the next version of PtokaX and there wasn't any plans to add it a few months ago. Maybe plop has more current info.....

As for the reset problem... try saving the table to a file whenever you add/remove a user. In Main, load the table from the file, that way whenever you reset the script you'll keep the content of the table from before....