PtokaX forum

Archive => Archived 5.0 boards => Request for scripts => Topic started by: ScriptMaster on 07 June, 2005, 00:55:26

Title: !showreg in alphabetical order?
Post by: ScriptMaster on 07 June, 2005, 00:55:26
Just wondering.. Is there a way to get the !showreg files to appear in alphabetical order? At the moment its like..

        ??????????????????????????????????
             ? Current Regged Reg's ?
   ??????????????????????????????????
     1.   [online]       Dave
     2.   [offline]   Norman
     3.   [offline]   Alex

I want it to be like...


        ??????????????????????????????????
             ? Current Regged Reg's ?
   ??????????????????????????????????
     1.   [online]       Alex
     2.   [offline]   Dave
     3.   [offline]   Norman

For all profiles aswell EG.

!showreg reg
!showreg vip
!showreg op
!showreg mod
!showreg master
!showreg founder

If any1 has any ideas, please let me know n il be very grateful =)

Title:
Post by: bastya_elvtars on 07 June, 2005, 02:07:26
This is an old bot I wrote in LUA4, available on plop's site. Hope this gives you some hints. :)

-- userlist by bastya_elvtars
-- shows a sorted userlist in PM divided into categories
-- ascii should be updated by somebody who has ascii design skills
-- will be deprecated in lua5 px ;)

-- sure u should edit these if needed

bot="userlist-bot"

command="userlist" -- no leading ! or other prefix plz - supports ! + #

level=2 -- levels are always the following, determining who CAN use the command:
        -- 5:only superops
        -- 4 ops & above
        -- 3 vips & above
        -- 2 registered users & above
        -- 1 anyone
        -- 0 disabled

-- not sure u should edit below without minimal lua knowledge.

users={}

users["reg"]={}
users["su"]={}
users["op"]={}
users["vip"]={}
users["guest"]={}


toins={
[1]=users["op"],
[2]=users["vip"],
[3]=users["reg"],
[0]=users["su"],
[-1]=users["guest"],
}

userlevels={[-1]=1,[0]=5,[1]=4,[2]=3,[3]=2}


function NewUserConnected(user)
if toins[user.iProfile] then
toins[user.iProfile][user.sName]=1
end
end

function Main()
frmHub:RegBot(bot)
end

function UserDisconnected(user)
if toins[user.iProfile] then
toins[user.iProfile][user.sName]=nil
end
end

function userlist()
return ("This Is The Current UserList:\r\n\r\n=======================\r\n=======================\r\nSuperops:\r\n--------------------------------------\r\n"..
makelistofaddedprofileintable(toins[0]).."--------------------------------------\r\n\r\nOps:\r\n--------------------------------------\r\n"..
makelistofaddedprofileintable(toins[1]).."--------------------------------------\r\n\r\nVIPs:\r\n--------------------------------------\r\n"..
makelistofaddedprofileintable(toins[2]).."--------------------------------------\r\n\r\nREGs:\r\n--------------------------------------\r\n"..
makelistofaddedprofileintable(toins[3]).."--------------------------------------\r\n\r\nGuests:\r\n--------------------------------------\r\n"..
makelistofaddedprofileintable(toins[-1]).."\r\n\r\n=======================\r\n=======================")
end

function makelistofaddedprofileintable(table)
local txt=""
local arr={}
for a,b in table do
tinsert(arr,a)
end
sort(arr)
for u=1,getn(arr) do
txt=txt..arr[u].."\r\n"
end
return txt
end

function DataArrival(user,data)
if userlevels[user.iProfile]>=level then
if strsub(data, 1, 4) == "$To:" then
data=strsub(data,1,strlen(data)-1)
-- is this meant for our bot?
local _,_,whoTo = strfind(data,"$To:%s+(%S+)")
if (whoTo == Bot) then
local _,_,cmd = strfind(data,"$To:%s+%S+%s+From:%s+%S+%s+$%b<>%s+[%!%+%#](%S+)")
if cmd==command  then
user:SendPM(bot,userlist())
end
elseif strsub(data, 1, 1) == "<" then
data=strsub(data,1,strlen(data)-1)
local _,_,cmd = strfind(data,"%b<>%s+[%!%+%#](%S+)")
if cmd==command  then
user:SendPM(bot,userlist())
end
end
end
end
end

OpConnected=NewUserConnected
OpDisconnected=UserDisconnected
Title:
Post by: ScriptMaster on 07 June, 2005, 02:09:10
Is there any chance of gettin that as a LUA 5?
Title:
Post by: Dessamator on 07 June, 2005, 09:34:14
hmmm, it seemes the virus of "alphabetizing" things is catching on, first user commands, now this i wonder whats next, :)

either way this is a simple script to convert !