PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: QuikThinker on 23 August, 2004, 22:48:15

Title: !topreg script needed
Post by: QuikThinker on 23 August, 2004, 22:48:15
Hey guys,

I'm after a script that will keep a record of who is regging users & how many. Some of my OPs av become lazy fuckers n want a script like Robocop's !tophubbers & !topkickers so that it will display how many people have regged new users. Also maybe an option so it'll display top reggers per week & per month.

Thanx in advance,
Quik.
Title:
Post by: nErBoS on 23 August, 2004, 22:49:51
Hi,

Yes it can be made, can you give us the syntax of your reg command ??

Best regards, nErBoS
Title:
Post by: QuikThinker on 23 August, 2004, 23:10:05
It's jus !reguser or !regvip that we use. lol if that's any help watsoeva?
Title:
Post by: nErBoS on 23 August, 2004, 23:28:57
Hi,

OK, but what is the syntax ??

!reguser
!regvip

is it this one ??

Best regards, nErBoS
Title:
Post by: QuikThinker on 23 August, 2004, 23:37:15
Yep sorry  :rolleyes:
Title:
Post by: nErBoS on 24 August, 2004, 00:58:53
Hi,

The script should be first in the Script List then the script that have the commands, to catch then first. Here you go...

--## Top Regger
--## Requested by QuikThinker
--## Made by nErBoS
--## Commands:
--## !topreg -- Show the TOP reggers of the HUB

sBot = "Top-Regger"

arrReg = {}
fReg = "topreg.dat"

--## Configuration ##--

uLaterPtokax = 0 -- Choose 0 if you are using a Ptokax version 0.3.3.0 or higher
-- Choose 1 if you are using a Ptokax version lower then 0.3.3.0

--## END ##--


function Main()
frmHub:RegBot(sBot)
LoadFromFile(fReg)
end

function OnExit()
SaveToFile(fReg , arrReg , "arrReg")
end

function DataArrival(user,data)
if (strsub(data,1,1) == "<" or strsub(data,1,5+strlen(sBot)) == "$To: "..sBot) then
data = strsub(data,1,strlen(data)-1)
s,e,cmd = strfind(data, "%b<>%s+(%S+)")
if (cmd == "!topreg" and user.bOperator) then
local sTmp,usr,num = "The TOP reggers of the HUB:\r\n\r\n"
for usr, num in arrReg do
sTmp = sTmp.."\tUser: "..usr.." Regged: "..num.."\r\n"
end
user:SendPM(sBot, sTmp)
return 1
elseif (user.bOperator and (cmd == "!reguser" or cmd == "!regvip")) then
local s,e,usr,pass = strfind(data, "%b<>%s+%S+%s+(%S+)%s+(%S+)")
if (usr ~= nil and pass ~= nil) then
if (arrReg[user.sName] == nil) then
arrReg[user.sName] = 1
else
arrReg[user.sName] = arrReg[user.sName] + 1
end
if (uLaterPtokax == 1) then
OnExit()
end
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

Best regards, nErBoS
Title:
Post by: QuikThinker on 24 August, 2004, 01:46:19
I tested this Nerbos & all I get when I run the !topreg command is this:
[00:42:20] The TOP reggers of the HUB:



Any ideas?
Title:
Post by: nErBoS on 24 August, 2004, 13:59:58
Hi,

Have you register any one ??? With the right syntax ??Is the script first then your major script in the Script List ??

Best regards, nErBoS
Title:
Post by: QuikThinker on 25 August, 2004, 02:11:07
lol yea we regged quite a few & I put it at the very top of the scriptlist. Still nuttin. It did create the .dat file but that was empty.
Title:
Post by: nErBoS on 25 August, 2004, 14:35:30
Hi,

Strange i have tried out and worked for me. Try to make him first in the list please. And i belive that this option "uLaterPtokax = 0" is acourd to yout ptokax version.

Best regards, nErBoS