Can somebody write script that shows lame users top.
Ops could wote like: !lamewote
and if op wote for user then wote saves in txt file.
So if you write !toplame message in PM shows lamest users. : )
_________________
Sorry for my english!
Hi,
Hope it helps...
--Requested by Janhouse
--Made by nErBoS
sBot = "The Lamer"
lamer = {}
top = {}
lamersv = "lamer.dat"
function Main()
frmHub:RegBot(sBot)
LoadFromFile(lamersv)
end
function OnExit()
SaveToFile(lamersv , lamer , "lamer")
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 == "!lamer" and user.bOperator) then
local s,e,nick = strfind(data, "%b<>%s+%S+%s+(%S+)")
if (nick == nil) then
user:SendPM(sBot, "Syntax Error, !lamer , you must write a nick.")
else
if (lamer[strlower(nick)] == nil) then
lamer[strlower(nick)] = 1
else
lamer[strlower(nick)] = lamer[strlower(nick)] + 1
end
user:SendPM(sBot, "Your vote for "..nick.." has been registered.")
end
return 1
elseif (cmd == "!toplamer" and user.bOperator) then
TopLamer(user)
return 1
end
end
end
function TopLamer(user)
local sTmp = "The Top 10 of lamers:\r\n\r\n"
local topper = ""
local iTop = 10
while 1 do
for usr, aux in lamer do
if (topper == "") then
topper = usr
elseif (lamer[usr] >= lamer[topper] and top[usr] == nil) then
topper = usr
end
end
if (topper == "") then
break
elseif (iTop == -1) then
break
else
top[topper] = 1
sTmp = sTmp..topper.."\tVoted: "..lamer[topper].."\r\n"
iTop = iTop - 1
end
end
user:SendPM(sBot, sTmp)
top = nil
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
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
Hi,
Little fix in the script above.
Best regards, nErBoS