PtokaX forum

Archive => Archived 5.0 boards => Request for scripts => Topic started by: Penguin on 18 June, 2005, 17:32:07

Title: Request for script !topkickers (!topreggers)
Post by: Penguin on 18 June, 2005, 17:32:07
Hi guys,

I'm after a script that will keep a record of who is regging (kicking) users & how many.
 
I want a script like Robocop's !tophubbers & !topkickers so that it will display how many OPs have regged (kicked) new users. Also maybe an option so it'll display top reggers (kickers) per week & per month.

Thanx in advance,
               Penguin

P.S.
I did try search before this post, but I find only one old LUA4 script.
Thank you very much in advance for help with make the script!
Title:
Post by: Dessamator on 18 June, 2005, 22:50:57
so basically u want 2 script, top regger and top kicker?
Title:
Post by: Penguin on 18 June, 2005, 23:13:40
QuoteOriginally posted by Dessamator
so basically u want 2 script, top regger and top kicker?

Yep  :)
Title:
Post by: Madman on 18 June, 2005, 23:47:15
-- TopRegger Script
-- Made by Madman
-- Requested by ph34r

-- Converted to lua 5
-- Striped TopKickers from MadSecurity
-- Made the topkicker more flexible
-- And now also logs more stuff

Bot = frmHub:GetHubBotName()
RegFile = "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
}
KickFile = "TopKickers.txt" -- The file for topkickers

function Main()
LoadFromFile(RegFile)
LoadFromFile(KickFile)
end

function ChatArrival(curUser, data)
local data = string.sub(data,1, -2)
local s,e,cmd = string.find(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" ..string.rep("-",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 = string.find(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"] = os.date("%Y-%m-%d - %X")
tTopReg[curUser.sName]["Count"] = 1
SaveToFile(RegFile, tTopReg, "tTopReg")
else
tTopReg[curUser.sName]["RegNick"] = Nick
tTopReg[curUser.sName]["LastReg"] = os.date("%Y-%m-%d - %X")
tTopReg[curUser.sName]["Count"] = tTopReg[curUser.sName]["Count"] + 1
SaveToFile(RegFile, tTopReg, "tTopReg")
end
end
end,
["topkickers"] = function(curUser, data)
if curUser.bOperator then
Msg = "\r\nCurrent Top Kicking Ops\r\n\r\nOperator\tDate & Time\t\tCount\tKicked\r\n" ..string.rep("-",90).. "\r\n\r\n"
for Nick,_ in tTopKickers do
Msg = Msg..Nick.."\t"
for _,Info in tTopKickers[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") return 1
end,
}
if tCmds[cmd] then
return tCmds[cmd](curUser, data)
end
end
end

function KickArrival(curUser, data)
_,_,nick = string.find(data, "%S+%s+(%S+)|")
vUser = GetItemByName(nick)
if tTopKickers[curUser.sName] == nil then
tTopKickers[curUser.sName] = {}
tTopKickers[curUser.sName]["KickNick"] = {}
tTopKickers[curUser.sName]["LastKick"] = {}
tTopKickers[curUser.sName]["Count"] = {}
tTopKickers[curUser.sName]["KickNick"] = vUser.sName
tTopKickers[curUser.sName]["LastKick"] = os.date("%Y-%m-%d - %X")
tTopKickers[curUser.sName]["Count"] = 1
SaveToFile(KickFile, tTopKickers, "tTopKickers")
else
tTopKickers[curUser.sName]["KickNick"] = vUser.sName
tTopKickers[curUser.sName]["LastKick"] = os.date("%Y-%m-%d - %X")
tTopKickers[curUser.sName]["Count"] = tTopKickers[curUser.sName]["Count"] + 1
SaveToFile(KickFile, tTopKickers, "tTopKickers")
end
end

-- Serialize by nErBoS
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 string.format("[%q]",key) or string.format("[%d]",key);
if(type(value) == "table") then
sTmp = sTmp..Serialize(value, sKey, sTab.."\t");
else
local sValue = (type(value) == "string") and string.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)
local handle = io.open(file,"w+")
handle:write(Serialize(table, tablename))
handle:flush()
handle:close()
end

function LoadFromFile(RegFile)
local f = io.open(RegFile)
if f then
local r = f:read("*a")
f:flush()
f:close()
local func,err = loadstring(r)
if func then x,err = pcall(func) end
end
end
Slightly tested...

Add this to these files

TopReggers.txt
tTopReg = {
}
TopKickers.txt
tTopKickers = {
}
Title:
Post by: Krysalis on 20 June, 2005, 19:09:19
Syntax ...or\Desktop\0.3.3.0.b17.05.nt.rls\scripts\topkick.lua:97: attempt to index global `tTopKickers' (a nil value)
Syntax ...or\Desktop\0.3.3.0.b17.05.nt.rls\scripts\topkick.lua:76: attempt to call a nil value
Syntax ...or\Desktop\0.3.3.0.b17.05.nt.rls\scripts\topkick.lua:76: attempt to call a nil value
Syntax ....3.0.b17.05.nt.rls\scripts\Trivia-Ex-V.0.68.lua5.lua:1391: attempt to call method `SendToPlayers' (a nil value)
Syntax ...or\Desktop\0.3.3.0.b17.05.nt.rls\scripts\topkick.lua:56: attempt to index global `tTopReg' (a nil value)
Syntax ...or\Desktop\0.3.3.0.b17.05.nt.rls\scripts\topkick.lua:56: attempt to index global `tTopReg' (a nil value)
Syntax ...or\Desktop\0.3.3.0.b17.05.nt.rls\scripts\topkick.lua:56: attempt to index global `tTopReg' (a nil value)
Syntax ...or\Desktop\0.3.3.0.b17.05.nt.rls\scripts\topkick.lua:56: attempt to index global `tTopReg' (a nil value)

How can i fix this?
Title:
Post by: Dessamator on 20 June, 2005, 20:21:51
QuoteOriginally posted by madman
Add this to these files

TopReggers.txt
tTopReg = {
}
TopKickers.txt
tTopKickers = {
}

did u do that?

P.S. That script is in lua 4, it wont work with lua 5
Title:
Post by: Krysalis on 20 June, 2005, 20:36:51
thx dessamator

I make this files. but it seems i need the real LUA5 version. Can anyone translate it or me?
Title:
Post by: jiten on 20 June, 2005, 20:46:54
QuoteOriginally posted by Krysalis
thx dessamator

I make this files. but it seems i need the real LUA5 version. Can anyone translate it or me?
That script is already in Lua 5 m8 ;)
Title:
Post by: Madman on 20 June, 2005, 20:51:19
QuoteOriginally posted by Krysalis
thx dessamator

I make this files. but it seems i need the real LUA5 version. Can anyone translate it or me?

It is in lua 5....
Title:
Post by: Dessamator on 20 June, 2005, 21:02:49
QuoteOriginally posted by madman
QuoteOriginally posted by Krysalis
thx dessamator

I make this files. but it seems i need the real LUA5 version. Can anyone translate it or me?

It is in lua 5....

ooops, my error, its already in lua 5 , but u are obviously missing something, that error should only appear when a table is missing !
Title:
Post by: Krysalis on 20 June, 2005, 21:27:18
i saw it in the header, anyway^^ I have these syntax errors. I create these 2 txt files and save the text in there.  the 2 txt file i createt in Scripts/txt.
right?

greets
Title:
Post by: Dessamator on 20 June, 2005, 21:37:15
QuoteOriginally posted by Krysalis
i saw it in the header, anyway^^ I have these syntax errors. I create these 2 txt files and save the text in there.  the 2 txt file i createt in Scripts/txt.
right?

greets

Wrong, It should be in the scripts folder !
Title:
Post by: Krysalis on 20 June, 2005, 22:34:55
thx, now it seems to run fine;-)

Greets
Title:
Post by: Dessamator on 20 June, 2005, 23:05:35
ur welcome !
Title:
Post by: jiten on 21 June, 2005, 20:58:27
Here (http://board.univ-angers.fr/thread.php?threadid=4826&boardid=26&styleid=1&sid=f7fce4c6fe55fd70405c48e1085200d5&page=1#1) goes my attempt ;)

Best regards,

jiten