PtokaX forum

Archive => Archived 5.1 boards => Request for scripts => Topic started by: BrotherBear on 11 February, 2007, 21:21:06

Title: Number of regusers
Post by: BrotherBear on 11 February, 2007, 21:21:06
Is there anyone who could make a script with this function:

frmHub:GetRegisteredUsers()

I would like to use it with Rightclick and sorted in Profiles?

Like this:


Profile      Nr of Users

Reg      243
VIP      26
OP      9
Masters      2
etc...

Total registered Users in The Hub: 280

Or know about a script that does this?

Title: Re: Number of regusers
Post by: bastya_elvtars on 11 February, 2007, 21:57:48
Sure thing! :)

-- RegStats by bastya_elvtars
-- requested by BrotherBear
-- shows registered users' numbers by profile

command="getregs" -- the desired command, WITHOUT prefix, the prefixes set in PtokaX will be used

----------------------------------------------------------------------------
Bot=frmHub:GetHubBotName()

function Main()
  prf="[%"..table.concat(frmHub:GetPrefixes(),"%").."]"
end

function ChatArrival (user, data)
  local cmd=data:sub(1,-2):match("%b<>%s+"..prf.."(%S+)")
  if cmd==command then
    local stats={}
    for _,usr in ipairs(frmHub:GetRegisteredUsers()) do
      local profname=GetProfileName(usr.iProfile)
      stats[profname]=stats[profname] or 0
      stats[profname]=stats[profname]+1
    end
    local c=0
    local msg="\r\n"..("-"):rep(45).."\r\nNumber of registered users by profile:\r\n"..("="):rep(25)
    for profname,number in pairs(stats) do
      c=c+number
      msg=msg.."\r\n"..profname..":\t"..number
    end
    msg=msg.."\r\n"..("="):rep(25).."\r\nTotal: "..c
    user:SendPM(Bot,msg)
    return 1
  end
end

function NewUserConnected(user) user:SendData("$UserCommand 1 3 Get # of registered users$<%[mynick]> !"..command.."&#124;") end; OpConnected=NewUserConnected
Title: Re: Number of regusers
Post by: BrotherBear on 11 February, 2007, 22:07:27
LoooL, your are on fire today bastya_elvtars

Sorry for Posting in wrong Forum :(

Thanks for this script it is just what I was looking for!

One thing tough, the total is a little wrong here :)

---------------------------------------------
Number of registered users by profile:
=========================
SVIP:   11
VIP:   99
KVIP:   7
Master:   8
Reg:   428
Moderator:   5
Netfounder:   2
Operator:   19
=========================
Total: 8

Could you fix this, pleeeaaase :) ?
Title: Re: Number of regusers
Post by: BrotherBear on 11 February, 2007, 22:15:44
Are you serious Mutor :) ?

Your script part above, where do I past it?

Under

function Main()
  prf="[%"..table.concat(frmHub:GetPrefixes(),"%").."]"

Or what ?
Title: Re: Number of regusers
Post by: bastya_elvtars on 11 February, 2007, 22:20:03
If you use my script, there is no need for that.
And yes, I already noticed the error and it's already fixed above.

Quote from: Mutor on 11 February, 2007, 22:12:07
Whats to fix?
That's Hungarian math  :P
he-he
Title: Re: Number of regusers
Post by: bastya_elvtars on 11 February, 2007, 22:25:17
Quote from: Mutor on 11 February, 2007, 22:23:06
Are YOU serious? You don't know how to call a function?

No, he is an end-user, you know. :P
Title: Re: Number of regusers
Post by: BrotherBear on 11 February, 2007, 22:31:46
Oh is it so easy to learn this stuff ;)

Title: Re: Number of regusers
Post by: BrotherBear on 11 February, 2007, 22:40:58
Yes I did try, but get errors

Have been trying to make MY OWN script all evening, but whitout success :(

I am trying, believe me!!!

As you say, I have been modding code before.

But sometimes it is great to have Forum like this to get some help.
Title: Re: Number of regusers
Post by: bastya_elvtars on 11 February, 2007, 22:48:53
Uhm, could you please post some feedback whether my sctipt works?
Title: Re: Number of regusers
Post by: BrotherBear on 11 February, 2007, 22:59:59
Yes bastya_elvtars it works great :)

Thanks again
As I am from Sweden I have sometimes difficult to understand English
and right know I am really tired :(

Sorry if I didn't try enough, I'll try harder next time :)