PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: ph34r on 18 June, 2005, 00:58:29

Title: Top Op - Ops Reg Stats
Post by: ph34r on 18 June, 2005, 00:58:29
Hey dudes. I had a quick look around the forum for the script im looking for but wasnt able to find it. Lemme explain what i need, then maybe if someone knows a link to it, they can tell me, or a very kind person could make it :)

Basically im looking for a script which works in the same way as RoboCop's Tophubbers and Topkickers list, but i need it for regged users, i need to know how many users each op is registering, so i can monitor how hard they are working.

Hope thats enough... oh yeh, it needs to be LUA 4, and for anyone whos gonna tell me that this sort of script already exists within another bigger script, i need it STANDALONE.

Thanks in advance for ANY help given.

ph34r.
Title:
Post by: Madman on 18 June, 2005, 14:50:43
do you want a seperate command for each profile i.e !regreg, !regvip or should it be !reg ?


This give me a change to learn file handling in lua 4 as well =)
Title:
Post by: ph34r on 18 June, 2005, 15:01:35
nooo its not to reg users, its to register how many OPs have been regging new users.

An Example

!topops

--shows-->

OP NAME                       Users Registered
-----------------------------------------------------
Operator1                               13
Operator2                               17
Operator3                               29
Operator4                                5
Operator5                               16

Like that, but maybe more things, like when they were active etc.
Title:
Post by: ph34r on 18 June, 2005, 16:04:27
that looks good Mutor, but i need it for +TopReggers not top kickers

thanks anyhow :)
Title:
Post by: Madman on 18 June, 2005, 20:11:51
-- TopRegger Script
-- Made by Madman
-- Requested by ph34r

Bot = frmHub:GetHubBotName()
Filename = "TopReggers.txt" -- The text to save things in
RegCmd = "addreguser" -- The command to used when regging user, no need to write ! or + before the command
AllowedToReg = { -- Set to 1 for thoose allowed to reg
[0] = 1,   -- Masters
[1] = 1,   -- Operators
[2] = 0,   -- Vips
[3] = 0,   -- Regs
}

function Main()
LoadFromFile(Filename)
end

function DataArrival(curUser, data)
if strsub(data, 1, 1) == "<" then
local data = strsub(data,1, -2)
local s,e,cmd = strfind(data, "%b<>%s[%!%+%?%#%+](%S+)")
if cmd then
local tCmds = {
["topreg"] =  function(curUser, data)
if curUser.bOperator then
Msg = "\r\nTop regging ops \r\n\r\nOpertor\tRegged\tCount\tDate & Time\r\n" ..strrep("-",80).. "\r\n\r\n"
for Nick,_ in tTopReg do
Msg = Msg..Nick.."\t"
for _,Info in tTopReg[Nick] do
Msg = Msg..Info.."\t"
end
Msg = Msg.."\r\n"
end
curUser:SendPM(Bot, Msg) return 1
end
curUser:SendData(Bot, "You are not allowed to use this command")
end,
[RegCmd] = function(curUser, data)
if AllowedToReg[curUser.iProfile] == 1 then
local s,e,Nick = strfind(data, "%b<>%s+%S+%s+(%S+)")
if tTopReg[curUser.sName] == nil then
tTopReg[curUser.sName] = {}
tTopReg[curUser.sName]["RegNick"] = {}
tTopReg[curUser.sName]["LastReg"] = {}
tTopReg[curUser.sName]["Count"] = {}
tTopReg[curUser.sName]["RegNick"] = Nick
tTopReg[curUser.sName]["LastReg"] = date("%Y-%m-%d - %X")
tTopReg[curUser.sName]["Count"] = 1
SaveToFile(Filename, tTopReg, "tTopReg")
else
tTopReg[curUser.sName]["RegNick"] = Nick
tTopReg[curUser.sName]["LastReg"] = date("%Y-%m-%d - %X")
tTopReg[curUser.sName]["Count"] = tTopReg[curUser.sName]["Count"] + 1
SaveToFile(Filename, tTopReg, "tTopReg")
end
end
end,
}
if tCmds[cmd] then
return tCmds[cmd](curUser, data)
end
end
end
end

function Serialize(tTable, sTableName, sTab)
assert(tTable, "tTable equals nil");
assert(sTableName, "sTableName equals nil");
assert(type(tTable) == "table", "tTable must be a table!");
assert(type(sTableName) == "string", "sTableName must be a string!");
sTab = sTab or "";
sTmp = ""
sTmp = sTmp..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
sTmp = sTmp..Serialize(value, sKey, sTab.."\t");
else
local sValue = (type(value) == "string") and format("%q",value) or tostring(value);
sTmp = sTmp..sTab.."\t"..sKey.." = "..sValue
end
sTmp = sTmp..",\n"
end
sTmp = sTmp..sTab.."}"
return sTmp
end

function SaveToFile(file , table , tablename)
writeto(file)
write(Serialize(table, tablename))
writeto()
end

function LoadFromFile(file)
if (readfrom(file) ~= nil) then
readfrom(file)
dostring(read("*all"))
readfrom()
end
end

Here we go...

In the TopReggers.txt you must add
tTopReg = {
}

Tested some... Seems to work okey.. =)
Title:
Post by: QuikThinker on 19 June, 2005, 15:00:45
Ok we need 3 mods 2 this script if possible.

1) There are 2 reg commands, NOT "addreguser" but "regreg" or "regvip".

2) We need levels to include Moderator and NetFounder.

3) When an OP uses command "!deluser" and deletes a user, mayb if a regging mistake is made, it'll delete that from the txt file to prevent un-neccessary additions.

Thanx in advance,
Quik.
Title:
Post by: Madman on 19 June, 2005, 17:15:50
QuoteOriginally posted by QuikThinker
Ok we need 3 mods 2 this script if possible.

1) There are 2 reg commands, NOT "addreguser" but "regreg" or "regvip".

2) We need levels to include Moderator and NetFounder.

3) When an OP uses command "!deluser" and deletes a user, mayb if a regging mistake is made, it'll delete that from the txt file to prevent un-neccessary additions.

Thanx in advance,
Quik.

1 shouldnt be to hard....
2 is easy...
3 i dont understand exatly...
You want when a op delets the user he just regged, it should remove that nick from the txt?
If so.. I'm not sure i can do it...
Well.. i can remove the nick.. but that will create a nil error...
So instead to the latest nick the op regged, what should it say instead?
It might work... ;)

You want it lua 4 or in lua 5?
Title:
Post by: ph34r on 19 June, 2005, 17:41:35
Lua 4 please.

Basically on the counter, say an OP regs 5 people for example, the txt file will display

Opname      5 users registered

but then if he deletes one user, it should say

Opname       4 users registered

is that possible?
Title:
Post by: Madman on 19 June, 2005, 22:19:17
QuoteOriginally posted by ph34r
Lua 4 please.

Basically on the counter, say an OP regs 5 people for example, the txt file will display

Opname      5 users registered

but then if he deletes one user, it should say

Opname       4 users registered

is that possible?

Yes that possible... but not tonight.. Got a headace...
If i got time tomorrow i will fix it =)
Title:
Post by: Madman on 20 June, 2005, 12:16:38
-- TopRegger Script
-- Made by Madman
-- Requested by ph34r
-- Added stuff for delregging
-- Added so user is remove from table if count == 0

Bot = frmHub:GetHubBotName()
Filename = "TopReggers.txt" -- The text to save things in
RegCmd = "addreguser" -- The command to used when regging user, no need to write ! or + before the command
DelRegCmd = "delreguser" -- The command to delete userss
AllowedToReg = { -- Set to 1 for thoose allowed to reg
[0] = 1,   -- Masters
[1] = 1,   -- Operators
[2] = 0,   -- Vips
[3] = 0,   -- Regs
}

function Main()
LoadFromFile(Filename)
end

function DataArrival(curUser, data)
if strsub(data, 1, 1) == "<" then
local data = strsub(data,1, -2)
local s,e,cmd = strfind(data, "%b<>%s[%!%+%?%#%+](%S+)")
if cmd then
local tCmds = {
["topreg"] =  function(curUser, data)
if curUser.bOperator then
Msg = "\r\nTop regging ops \r\n\r\nOpertor\tRegged\tCount\tDate & Time\r\n" ..strrep("-",80).. "\r\n\r\n"
for Nick,_ in tTopReg do
Msg = Msg..Nick.."\t"
for _,Info in tTopReg[Nick] do
Msg = Msg..Info.."\t"
end
Msg = Msg.."\r\n"
end
curUser:SendPM(Bot, Msg) return 1
end
curUser:SendData(Bot, "You are not allowed to use this command")
end,
[RegCmd] = function(curUser, data)
if AllowedToReg[curUser.iProfile] == 1 then
local s,e,Nick = strfind(data, "%b<>%s+%S+%s+(%S+)")
if tTopReg[curUser.sName] == nil then
tTopReg[curUser.sName] = {}
tTopReg[curUser.sName]["RegNick"] = {}
tTopReg[curUser.sName]["LastReg"] = {}
tTopReg[curUser.sName]["Count"] = {}
tTopReg[curUser.sName]["RegNick"] = Nick
tTopReg[curUser.sName]["LastReg"] = date("%Y-%m-%d - %X")
tTopReg[curUser.sName]["Count"] = 1
SaveToFile(Filename, tTopReg, "tTopReg")
else
tTopReg[curUser.sName]["RegNick"] = Nick
tTopReg[curUser.sName]["LastReg"] = date("%Y-%m-%d - %X")
tTopReg[curUser.sName]["Count"] = tTopReg[curUser.sName]["Count"] + 1
SaveToFile(Filename, tTopReg, "tTopReg")
end
end
end,
[DelRegCmd] = function(curUser, data)
if AllowedToReg[curUser.iProfile] == 1 and tTopReg[curUser.sName] then
local s,e,Nick = strfind(data, "%b<>%s+%S+%s+(%S+)")
tTopReg[curUser.sName]["RegNick"] = Nick
tTopReg[curUser.sName]["LastReg"] = date("%Y-%m-%d - %X")
tTopReg[curUser.sName]["Count"] = tTopReg[curUser.sName]["Count"] - 1
if tTopReg[curUser.sName]["Count"] <= 0 then
tTopReg[curUser.sName] = nil
end
SaveToFile(Filename, tTopReg, "tTopReg")
end
end,
}
if tCmds[cmd] then
return tCmds[cmd](curUser, data)
end
end
end
end

function Serialize(tTable, sTableName, sTab)
assert(tTable, "tTable equals nil");
assert(sTableName, "sTableName equals nil");
assert(type(tTable) == "table", "tTable must be a table!");
assert(type(sTableName) == "string", "sTableName must be a string!");
sTab = sTab or "";
sTmp = ""
sTmp = sTmp..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
sTmp = sTmp..Serialize(value, sKey, sTab.."\t");
else
local sValue = (type(value) == "string") and format("%q",value) or tostring(value);
sTmp = sTmp..sTab.."\t"..sKey.." = "..sValue
end
sTmp = sTmp..",\n"
end
sTmp = sTmp..sTab.."}"
return sTmp
end

function SaveToFile(file , table , tablename)
writeto(file)
write(Serialize(table, tablename))
writeto()
end

function LoadFromFile(file)
if (readfrom(file) ~= nil) then
readfrom(file)
dostring(read("*all"))
readfrom()
end
end

This should do the trick..
I made it last night... My headace disapered =)
Was going to post last night... but my isp went down..
Just got back online...

as for QuickThinker....
Still waiting on your replay m8... =)
The stuff you want  shouldnt take long 2 do..
Just need 2 know if you want lua 4 or lua 5
Title:
Post by: ph34r on 21 June, 2005, 18:54:25
lol we're from the same hub mate. we're requesting the script for the same hub  :D
Title:
Post by: Madman on 21 June, 2005, 19:30:40
QuoteOriginally posted by ph34r
lol we're from the same hub mate. we're requesting the script for the same hub  :D

lol, that would been good to know from the start... lol
i'll make Quicks request as soon i'm done reading all new posts on the board =)

*Edit*

Okey... That should be it...

-- TopRegger Script
-- Made by Madman
-- Requested by ph34r
-- Added stuff for delregging
-- Added so user is remove from table if count == 0
-- Version 2
-- Added 2 reg commands, one 4 reg one for vip
-- Added Moderator and Netfounder profiles

Bot = frmHub:GetHubBotName()
Filename = "TopReggers.txt" -- The text to save things in
RegReg = "regreg" -- The command to used when regging user, no need to write ! or + before the command
RegVip = "regvip" -- The command for regging vips
DelRegCmd = "deluser" -- The command to delete userss
AllowedToReg = { -- Set to 1 for thoose allowed to reg
[0] = 1, -- Masters
[1] = 1, -- Operators
[2] = 0, -- Vips
[3] = 0, -- Regs
[4] = 0, -- Moderator
[5] = 0, -- Netfounder
}

function Main()
LoadFromFile(Filename)
end

function DataArrival(curUser, data)
if strsub(data, 1, 1) == "<" then
local data = strsub(data,1, -2)
local s,e,cmd = strfind(data, "%b<>%s[%!%+%?%#%+](%S+)")
if cmd then
tCmds = {
["topreg"] = function(curUser, data)
if curUser.bOperator then
Msg = "\r\nTop regging ops \r\n\r\nOpertor\tRegged\tCount\tDate & Time\r\n" ..strrep("-",80).. "\r\n\r\n"
for Nick,_ in tTopReg do
Msg = Msg..Nick.."\t"
for _,Info in tTopReg[Nick] do
Msg = Msg..Info.."\t"
end
Msg = Msg.."\r\n"
end
curUser:SendPM(Bot, Msg) return 1
end
curUser:SendData(Bot, "You are not allowed to use this command")
end,
[RegReg] = function(curUser, data)
if AllowedToReg[curUser.iProfile] == 1 then
local s,e,Nick = strfind(data, "%b<>%s+%S+%s+(%S+)")
if tTopReg[curUser.sName] == nil then
tTopReg[curUser.sName] = {}
tTopReg[curUser.sName]["RegNick"] = {}
tTopReg[curUser.sName]["LastReg"] = {}
tTopReg[curUser.sName]["Count"] = {}
tTopReg[curUser.sName]["RegNick"] = Nick
tTopReg[curUser.sName]["LastReg"] = date("%Y-%m-%d - %X")
tTopReg[curUser.sName]["Count"] = 1
SaveToFile(Filename, tTopReg, "tTopReg")
else
tTopReg[curUser.sName]["RegNick"] = Nick
tTopReg[curUser.sName]["LastReg"] = date("%Y-%m-%d - %X")
tTopReg[curUser.sName]["Count"] = tTopReg[curUser.sName]["Count"] + 1
SaveToFile(Filename, tTopReg, "tTopReg")
end
end
end,
[RegVip] = function(curUser, data)
tCmds[RegReg](curUser, data)
end,
[DelRegCmd] = function(curUser, data)
if AllowedToReg[curUser.iProfile] == 1 and tTopReg[curUser.sName] then
local s,e,Nick = strfind(data, "%b<>%s+%S+%s+(%S+)")
tTopReg[curUser.sName]["RegNick"] = Nick
tTopReg[curUser.sName]["LastReg"] = date("%Y-%m-%d - %X")
tTopReg[curUser.sName]["Count"] = tTopReg[curUser.sName]["Count"] - 1
if tTopReg[curUser.sName]["Count"] <= 0 then
tTopReg[curUser.sName] = nil
end
SaveToFile(Filename, tTopReg, "tTopReg")
end
end,
}
if tCmds[cmd] then
return tCmds[cmd](curUser, data)
end
end
end
end

function Serialize(tTable, sTableName, sTab)
assert(tTable, "tTable equals nil");
assert(sTableName, "sTableName equals nil");
assert(type(tTable) == "table", "tTable must be a table!");
assert(type(sTableName) == "string", "sTableName must be a string!");
sTab = sTab or "";
sTmp = ""
sTmp = sTmp..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
sTmp = sTmp..Serialize(value, sKey, sTab.."\t");
else
local sValue = (type(value) == "string") and format("%q",value) or tostring(value);
sTmp = sTmp..sTab.."\t"..sKey.." = "..sValue
end
sTmp = sTmp..",\n"
end
sTmp = sTmp..sTab.."}"
return sTmp
end

function SaveToFile(file , table , tablename)
writeto(file)
write(Serialize(table, tablename))
writeto()
end

function LoadFromFile(file)
if (readfrom(file) ~= nil) then
readfrom(file)
dostring(read("*all"))
readfrom()
end
end
Title:
Post by: jiten on 21 June, 2005, 20:57:56
Have a look at this (http://board.univ-angers.fr/thread.php?threadid=4826&boardid=26&styleid=1&sid=f7fce4c6fe55fd70405c48e1085200d5&page=1#1) one.

Cheers