I hope someone can help me, searched my ass off but didn't find any good stand-alone script for this problem.
I run a public hub with regged users. I want to see a list of currently unregistered nicks in a PM or mainchat. Only OP's or admin's can see or trigger this.
That way it's easy to see which users still must be checked for a good share or something.. 8)
Thank you!
Hi,
I don't believe if that is possible.
Best regards, nErBoS
Hey, hope this helps.
sBot = "show[Unregs]"
LOGGusr = {}
function Main()
frmHub:RegBot(sBot)
end
function NewUserConnected(user)
if user.iProfile == -1 then
if LOGGusr[user.sName] == nil then
LOGGusr[user.sName] = 1
end
end
end
function UserDisconnected(user)
if user.iProfile == -1 then
LOGGusr[user.sName] = nil
end
end
function DataArrival(user, data)
if strsub(data,1,1)=="<" then
data=strsub(data,1,strlen(data)-1)
s,e,cmd = strfind(data,"%b<>%s+(%S+)")
if user.bOperator then
if (cmd=="+showregs") then
for i,v in LOGGusr do
user:SendPM(sBot,i) return 1
end
end
end
end
end
It seems to work! Very, very nice kepp! :))
Hmmn... it showed 1 user that's not regged.. after that it showed another user that was not regged.
But then there came more unregged users in to the hub after that user but they were not shown by the script.
I do not get it. ?(
Did you restartscripts?
as soon as you restartscripts everyone must reconnect... else, it won't show up... Only those users who's entering the hub after scriptrestart will be shown
Yeah I did, but it still the same problem.
It only show's the last unregged user that joined. I need a list of all current users that are present. I think that's the problem.
And ofcourse only those who have joined after starting the script. So they have to be online at that moment.
Do you understand what I want?
It will show all users after a while if you leave the scriptrestart button alone ;)
The problem is, there is no other way to get then name of all unregistered users that are curently active...
Enjoy
Of course I will leave it alone :D
Still it's not working as it should be.
Example:
[00:48] *** Joins: Tatone
[00:48] *** Joins: [Telia]Cameltoe
[00:49] *** Joins: [Cable]Canopus
All three are unregged.
But the script only show's:
[00:49] Tatone
Hmmn.. ?(
sBot = "show[Unregs]"
LOGGusr = {}
function Main()
frmHub:RegBot(sBot)
end
function NewUserConnected(user)
if user.iProfile == -1 then
if LOGGusr[user.sName] == nil then
LOGGusr[user.sName] = 1
end
end
end
function UserDisconnected(user)
if user.iProfile == -1 then
LOGGusr[user.sName] = nil
end
end
function DataArrival(user, data)
if strsub(data,1,1)=="<" then
data=strsub(data,1,strlen(data)-1)
s,e,cmd = strfind(data,"%b<>%s+(%S+)")
if user.bOperator then
if (cmd=="+showregs") then
for i,v in LOGGusr do
user:SendPM(sBot,i)
end
end
end
end
end
Here you go... tested and works for me :)
Thanks, had to look very carefully for that change :]
I will look, test, sleep and look again :D
Thanks again!
No problem, lol!!
Seems to work just fine now! :))
could be a #1 at the Lua Script Award's 2004! :tongue:
Reminder:
When restarting script the LOGGusr table will be emty...
/NL
Yes indeed. You can better restart the entire hub then instead, because all users will reconnect then and everything will work fine again.
Here is a modified version that write's to a file:
--[ LogBot ]--
-- Originally by: Kepp
-- Modified by: NightLitch
sBot = "show[Unregs]"
LogFile = "UserLog.txt"
LOGGusr = {}
function Main()
frmHub:RegBot(sBot)
if frmHub:GetUsersCount() == 0 then
local f = openfile(LogFile, "w")
if f == nil or f=="" then
write(f, " ")
closefile(f)
else
write(f, " ")
closefile(f)
end
else
LoadFromFile (LogFile)
end
end
function NewUserConnected(user)
if user.iProfile == -1 then
if LOGGusr[user.sName] == nil then
LOGGusr[user.sName] = 1
SaveToFile(LOGGusr , "LOGGusr", LogFile)
end
end
end
function UserDisconnected(user)
if user.iProfile == -1 then
LOGGusr[user.sName] = nil
SaveToFile(LOGGusr , "LOGGusr", LogFile)
end
end
function DataArrival(user, data)
if strsub(data,1,1)=="<" then
data=strsub(data,1,strlen(data)-1)
s,e,cmd = strfind(data,"%b<>%s+(%S+)")
if user.bOperator then
if (cmd=="+showregs") then
for i,v in LOGGusr do
user:SendPM(sBot,i)
end
end
end
end
end
function Serialize(tTable, sTableName, hFile, sTab)
assert(tTable, "tTable equals nil");
assert(sTableName, "sTableName equals nil");
assert(hFile, "hFile equals nil");
assert(type(tTable) == "table", "tTable must be a table!");
assert(type(sTableName) == "string", "sTableName must be a string!");
sTab = sTab or "";
write(hFile, 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
Serialize(value, sKey, hFile, sTab.."\t");
else
local sValue = (type(value) == "string") and format("%q",value) or tostring(value);
write(hFile, sTab.."\t"..sKey.." = "..sValue);
end
write(hFile, ",\n");
end
write(hFile, sTab.."}");
end
function SaveToFile(table , tablename, file)
local hFile = openfile(file, "w");
Serialize(table, tablename, hFile);
closefile(hFile);
end
function LoadFromFile (file)
assert(readfrom(file),file.." is not found.Generating new "..file..". All is fine. Don't panic.")
dostring(read("*all"))
readfrom()
end
/NL
ok, would you like to explain a bit further, what the serializatio of the tables do? What's the point... seems every script use it lately
QuoteOriginally posted by kepp
ok, would you like to explain a bit further, what the serializatio of the tables do? What's the point... seems every script use it lately
Well that is just a main serialize I got from Wombat, a slight change but not noticeable.
That will order the table and then write to file.
that is the best serialize I have tried, especially if you use outer & inner table:
outer = { inner = {values}, } And don't want "many" functions. I don't know who made it from the start maybe Wombat, as I mention I got it from him.
/NL
Seems to work ok, thnx!
Btw.. a better command is +showunregs ;)
And now off to bed again.. :D