hi people :D
I use the chatstat script made by amutex for my hub, but it even counts the privatechat lines.. what can i do if i want that he count only the mainchat lines?
p.s sorru for my bad english :(
here is the amutex chatstat
-----------Top 10 By aMutex, MatrixX, Dazzler-------
--------------------------------------------------------------
botname = "ChatStat"
TimeSpanInMinutes = 30
ChatStat={}
ChatStatCounter=1
function Main()
local handle=openfile("chatstat.dat","r")
ChatStatCounter=read(handle)
Poll={}
while 1 do
local line = read(handle)
if line == nil then break
else
x,y,a=strfind(line,"([^?]*)")
x,y,b=strfind(line,"([^?]*)$")
ChatStat[a]=tonumber(b)
end
end
closefile(handle)
SetTimer(TimeSpanInMinutes*60000)
StartTimer()
frmHub:RegBot(botname)
end
function reset(user)
ChatStat={}
ChatStatCounter=0
user:SendPM(botname,"Azzeramento delle statistiche effettuato!")
end
function save_stats(user)
remove("chatstat.dat")
local handle=openfile("chatstat.dat","a")
write(handle,ChatStatCounter.."\n")
for a,b in ChatStat do
write(handle,a.."?"..b.."\n")
end
closefile(handle)
SendToAll( "?Stats?"," Classifica salvata...")
end
function show_top5(userobj)
local index1, key1
local index2, key2
local index3, key3
local index4, key4
local index5, key5
local index6, key6
local index7, key7
local index8, key8
local index9, key9
local index10, key10
key1=0
key2=0
key3=0
key4=0
key5=0
key6=0
key7=0
key8=0
key9=0
key10=0
for a,b in ChatStat do
if (ChatStat[a]>key1) then
----for top 10-------
index10=index9
key10=key9
index9=index8
key9=key8
index8=index7
key8=key7
index7=index6
key7=key6
index6=index5
key6=key5
-----------
index5=index4
key5=key4
index4=index3
key4=key3
index3=index2
key3=key2
index2=index1
key2=key1
index1=a
key1=ChatStat[a]
else
if (ChatStat[a]>key2) then
index10=index9
key10=key9
index9=index8
key9=key8
index8=index7
key8=key7
index7=index6
key7=key6
index6=index5
key6=key5
index5=index4
key5=key4
index4=index3
key4=key3
index3=index2
key3=key2
index2=a
key2=ChatStat[a]
else
if (ChatStat[a]>key3) then
index10=index9
key10=key9
index9=index8
key9=key8
index8=index7
key8=key7
index7=index6
key7=key6
index6=index5
key6=key5
index5=index4
key5=key4
index4=index3
key4=key3
index3=a
key3=ChatStat[a]
else
if (ChatStat[a]>key4) then
index10=index9
key10=key9
index9=index8
key9=key8
index8=index7
key8=key7
index7=index6
key7=key6
index6=index5
key6=key5
index5=index4
key5=key4
index4=a
key4=ChatStat[a]
else
if (ChatStat[a]>key5) then
index10=index9
key10=key9
index9=index8
key9=key8
index8=index7
key8=key7
index7=index6
key7=key6
index6=index5
key6=key5
index5=a
key5=ChatStat[a]
else
if (ChatStat[a]>key6) then
index10=index9
key10=key9
index9=index8
key9=key8
index8=index7
key8=key7
index7=index6
key7=key6
index6=a
key6=ChatStat[a]
else
if (ChatStat[a]>key7) then
index10=index9
key10=key9
index9=index8
key9=key8
index8=index7
key8=key7
index7=a
key7=ChatStat[a]
else
if (ChatStat[a]>key8) then
index10=index9
key10=key9
index9=index8
key9=key8
index8=a
key8=ChatStat[a]
else
if (ChatStat[a]>key9) then
index10=index9
key10=key9
index9=a
key9=ChatStat[a]
else
if (ChatStat[a]>key10) then
index10=a
key10=ChatStat[a]
end
end
end
end
end
end
end
end
end
end
end
SendToAll(" Top 10 Chatters ")
SendToAll("_____________________________________________________")
SendToAll(" Nr. Posts\t=> User ")
SendToAll("?????????????????????????????????????????????????????")
if (index1~=nil) then
SendToAll("?"," N?1. "..ChatStat[index1].." linee \t=> "..index1)
end
if (index2~=nil) then
SendToAll("?"," N?2. "..ChatStat[index2].." linee \t=> "..index2)
end
if (index3~=nil) then
SendToAll("?"," N?3. "..ChatStat[index3].." linee \t=> "..index3)
end
if (index4~=nil) then
SendToAll("?"," N?4. "..ChatStat[index4].." linee \t=> "..index4)
end
if (index5~=nil) then
SendToAll("?"," N?5. "..ChatStat[index5].." linee \t=> "..index5)
end
if (index6~=nil) then
SendToAll("?"," N?6. "..ChatStat[index6].." linee \t=> "..index6)
end
if (index7~=nil) then
SendToAll("?"," N?7. "..ChatStat[index7].." linee \t=> "..index7)
end
if (index8~=nil) then
SendToAll("?"," N?8. "..ChatStat[index8].." linee \t=> "..index8)
end
if (index9~=nil) then
SendToAll("?"," N?9. "..ChatStat[index9].." linee \t=> "..index9)
end
if (index10~=nil) then
SendToAll("?"," N?10. "..ChatStat[index10].." linee \t=> "..index10)
end
SendToAll("_____________________________________________________")
end
function GetCommand(data)
s,e,whoTo,from,cmd = strfind(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(%S+)")
return cmd
end
function DataArrival(user, data)
if (( strsub(data, 1, 1) == "<" ) or ( strsub(data, 1, 4) == "$To:" )) then
if (ChatStat[user.sName] == nil) then
ChatStat[user.sName]=1
else
ChatStat[user.sName]=ChatStat[user.sName]+1
end
ChatStatCounter=ChatStatCounter+1
end
if(strsub(data, 1, 4) == "$To:") then
s,e,whoTo,from,cmd = strfind(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(%S+)")
cmd=strsub(cmd,1,strlen(cmd)-1)
if (whoTo == botname) then
if (cmd=="+stats")then
show_top5(user)
end
if (cmd=="+help")then
user:SendPM(botname, "===============================================")
user:SendPM(botname, "Here's the commands :")
user:SendPM(botname, "")
user:SendPM(botname, "+stats\t- Show top")
user:SendPM(botname, "+load\t- Load Stats( OP's)")
user:SendPM(botname, "+save\t- Save Stats ( OP's)")
user:SendPM(botname, "===============================================")
end
if (user.bOperator) then
if (cmd=="+save") then
save_stats(user)
end
if (cmd=="+load") then
load_stats(user)
end
if (cmd=="!reset") then
reset(user)
end
end
end
end
-------Chat Commands Added By D@zzler------------
if( strsub(data, 1, 1) == "<" ) then
-- get the msg only using regular expression
data=strsub(data,1,strlen(data)-1)
-- parse the command
s,e,cmd = strfind( data, "%b<>%s+(%S+)" )
s,e,mess = strfind(data, "%b<> ([%w ]*)")
if (cmd=="+stats")then
a = 3
show_top5(user)
end
if (user.bOperator) then
if (cmd=="+save") then
save_stats(user)
end
if (user.bOperator) then
if (cmd=="+load") then
load_stats(user)
end
end
end
end
-----------------------------------------------
-----------------------------------------------
end
function OnTimer()
remove("chatstat.dat")
local handle=openfile("chatstat.dat","a")
write(handle,ChatStatCounter.."\n")
for a,b in ChatStat do
write(handle,a.."?"..b.."\n")
end
closefile(handle)
end
function load_stats(user)
local handle=openfile("chatstat.dat","r")
ChatStatCounter=read(handle)
Poll={}
while 1 do
local line = read(handle)
if line == nil then break
else
x,y,a=strfind(line,"([^?]*)")
x,y,b=strfind(line,"([^?]*)$")
ChatStat[a]=tonumber(b)
end
end
closefile(handle)
SendToAll( "?Stats?"," ? Classifica caricata...")
end
---------------------------------------------------
Hmm... I also wanted that :) so hope someone can rewrite it :)
it shouldn't count pms now. if there is any mistake or u get a error. just say and i will try 2 fix it. :D
-----------Top 10 By aMutex, MatrixX, Dazzler-------
----------------------------------------------------
botname = "ChatStat"
TimeSpanInMinutes = 30
ChatStat={}
ChatStatCounter=1
function Main()
local handle=openfile("chatstat.dat","r")
ChatStatCounter=read(handle)
Poll={}
while 1 do
local line = read(handle)
if line == nil then break
else
x,y,a=strfind(line,"([^?]*)")
x,y,b=strfind(line,"([^?]*)$")
ChatStat[a]=tonumber(b)
end
end
closefile(handle)
SetTimer(TimeSpanInMinutes*60000)
StartTimer()
frmHub:RegBot(botname)
end
function reset(user)
ChatStat={}
ChatStatCounter=0
user:SendPM(botname,"Azzeramento delle statistiche effettuato!")
end
function save_stats(user)
remove("chatstat.dat")
local handle=openfile("chatstat.dat","a")
write(handle,ChatStatCounter.."\n")
for a,b in ChatStat do
write(handle,a.."?"..b.."\n")
end
closefile(handle)
SendToAll( "?Stats?"," Classifica salvata...")
end
function show_top5(userobj)
local index1, key1
local index2, key2
local index3, key3
local index4, key4
local index5, key5
local index6, key6
local index7, key7
local index8, key8
local index9, key9
local index10, key10
key1=0
key2=0
key3=0
key4=0
key5=0
key6=0
key7=0
key8=0
key9=0
key10=0
for a,b in ChatStat do
if (ChatStat[a]>key1) then
----for top 10-------
index10=index9
key10=key9
index9=index8
key9=key8
index8=index7
key8=key7
index7=index6
key7=key6
index6=index5
key6=key5
-----------
index5=index4
key5=key4
index4=index3
key4=key3
index3=index2
key3=key2
index2=index1
key2=key1
index1=a
key1=ChatStat[a]
else
if (ChatStat[a]>key2) then
index10=index9
key10=key9
index9=index8
key9=key8
index8=index7
key8=key7
index7=index6
key7=key6
index6=index5
key6=key5
index5=index4
key5=key4
index4=index3
key4=key3
index3=index2
key3=key2
index2=a
key2=ChatStat[a]
else
if (ChatStat[a]>key3) then
index10=index9
key10=key9
index9=index8
key9=key8
index8=index7
key8=key7
index7=index6
key7=key6
index6=index5
key6=key5
index5=index4
key5=key4
index4=index3
key4=key3
index3=a
key3=ChatStat[a]
else
if (ChatStat[a]>key4) then
index10=index9
key10=key9
index9=index8
key9=key8
index8=index7
key8=key7
index7=index6
key7=key6
index6=index5
key6=key5
index5=index4
key5=key4
index4=a
key4=ChatStat[a]
else
if (ChatStat[a]>key5) then
index10=index9
key10=key9
index9=index8
key9=key8
index8=index7
key8=key7
index7=index6
key7=key6
index6=index5
key6=key5
index5=a
key5=ChatStat[a]
else
if (ChatStat[a]>key6) then
index10=index9
key10=key9
index9=index8
key9=key8
index8=index7
key8=key7
index7=index6
key7=key6
index6=a
key6=ChatStat[a]
else
if (ChatStat[a]>key7) then
index10=index9
key10=key9
index9=index8
key9=key8
index8=index7
key8=key7
index7=a
key7=ChatStat[a]
else
if (ChatStat[a]>key8) then
index10=index9
key10=key9
index9=index8
key9=key8
index8=a
key8=ChatStat[a]
else
if (ChatStat[a]>key9) then
index10=index9
key10=key9
index9=a
key9=ChatStat[a]
else
if (ChatStat[a]>key10) then
index10=a
key10=ChatStat[a]
end
end
end
end
end
end
end
end
end
end
end
SendToAll(" Top 10 Chatters ")
SendToAll("_____________________________________________________")
SendToAll(" Nr. Posts\t=> User ")
SendToAll("?????????????????????????????????????????????????????")
if (index1~=nil) then
SendToAll("?"," N?1. "..ChatStat[index1].." linee \t=> "..index1)
end
if (index2~=nil) then
SendToAll("?"," N?2. "..ChatStat[index2].." linee \t=> "..index2)
end
if (index3~=nil) then
SendToAll("?"," N?3. "..ChatStat[index3].." linee \t=> "..index3)
end
if (index4~=nil) then
SendToAll("?"," N?4. "..ChatStat[index4].." linee \t=> "..index4)
end
if (index5~=nil) then
SendToAll("?"," N?5. "..ChatStat[index5].." linee \t=> "..index5)
end
if (index6~=nil) then
SendToAll("?"," N?6. "..ChatStat[index6].." linee \t=> "..index6)
end
if (index7~=nil) then
SendToAll("?"," N?7. "..ChatStat[index7].." linee \t=> "..index7)
end
if (index8~=nil) then
SendToAll("?"," N?8. "..ChatStat[index8].." linee \t=> "..index8)
end
if (index9~=nil) then
SendToAll("?"," N?9. "..ChatStat[index9].." linee \t=> "..index9)
end
if (index10~=nil) then
SendToAll("?"," N?10. "..ChatStat[index10].." linee \t=> "..index10)
end
SendToAll("_____________________________________________________")
end
function GetCommand(data)
s,e,whoTo,from,cmd = strfind(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(%S+)")
return cmd
end
function DataArrival(user, data)
if (( strsub(data, 1, 1) == "<" ))then
if (ChatStat[user.sName] == nil) then
ChatStat[user.sName]=1
else
ChatStat[user.sName]=ChatStat[user.sName]+1
end
ChatStatCounter=ChatStatCounter
end
if(strsub(data, 1, 4) == "$To:") then
s,e,whoTo,from,cmd = strfind(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(%S+)")
cmd=strsub(cmd,1,strlen(cmd)-1)
if (whoTo == botname) then
if (cmd=="+stats")then
show_top5(user)
end
if (cmd=="+help")then
user:SendPM(botname, "===============================================")
user:SendPM(botname, "Here's the commands :")
user:SendPM(botname, "")
user:SendPM(botname, "+stats\t- Show top")
user:SendPM(botname, "+load\t- Load Stats( OP's)")
user:SendPM(botname, "+save\t- Save Stats ( OP's)")
user:SendPM(botname, "===============================================")
end
if (user.bOperator) then
if (cmd=="+save") then
save_stats(user)
end
if (cmd=="+load") then
load_stats(user)
end
if (cmd=="!reset") then
reset(user)
end
end
end
end
-------Chat Commands Added By D@zzler------------
if( strsub(data, 1, 1) == "<" ) then
-- get the msg only using regular expression
data=strsub(data,1,strlen(data)-1)
-- parse the command
s,e,cmd = strfind( data, "%b<>%s+(%S+)" )
s,e,mess = strfind(data, "%b<> ([%w ]*)")
if (cmd=="+stats")then
a = 3
show_top5(user)
end
if (user.bOperator) then
if (cmd=="+save") then
save_stats(user)
end
if (user.bOperator) then
if (cmd=="+load") then
load_stats(user)
end
end
end
end
-----------------------------------------------
-----------------------------------------------
end
function OnTimer()
remove("chatstat.dat")
local handle=openfile("chatstat.dat","a")
write(handle,ChatStatCounter.."\n")
for a,b in ChatStat do
write(handle,a.."?"..b.."\n")
end
closefile(handle)
end
function load_stats(user)
local handle=openfile("chatstat.dat","r")
ChatStatCounter=read(handle)
Poll={}
while 1 do
local line = read(handle)
if line == nil then break
else
x,y,a=strfind(line,"([^?]*)")
x,y,b=strfind(line,"([^?]*)$")
ChatStat[a]=tonumber(b)
end
end
closefile(handle)
SendToAll( "?Stats?"," ? Classifica caricata...")
end
Hee Hee Hee... Deactivate your smilies :P
blazeXxX u also wnated this script tell me if it works. :D
Yea M8 but the post u have there is having mixed smilies.. Pls repost the script with "Deactivate Smilies in this post" option ticked...
Ok, i have Deactivaed and fixed the smile things...
Toke some time.. but i hade nothing better to do....
But i got a error..
Syntax error: bad argument #1 to `read' (string expected, got nil)
stack traceback:
1: function `read' [C]
2: function `Main' at line 10 [file `D:\Program\Hub\PtokaX-0.330\scripts\chatter.lua']
But it seems to work anyway... Not sure...
*Edit*
Found another bug, if you restart it, it resets the stats... lets hope it is beacuse of the Syntax error...
-----------Top 10 By aMutex, MatrixX, Dazzler-------
----------------------------------------------------
botname = "ChatStat"
TimeSpanInMinutes = 30
ChatStat={}
ChatStatCounter=1
function Main()
local handle=openfile("chatstat.dat","r")
ChatStatCounter=read(handle)
Poll={}
while 1 do
local line = read(handle)
if line == nil then break
else
x,y,a=strfind(line,"[^?]*)")
x,y,b=strfind(line,"[^?]*)$")
ChatStat[a]=tonumber(b)
end
end
closefile(handle)
SetTimer(TimeSpanInMinutes*60000)
StartTimer()
frmHub:RegBot(botname)
end
function reset(user)
ChatStat={}
ChatStatCounter=0
user:SendPM(botname,"Azzeramento delle statistiche effettuato!")
end
function save_stats(user)
remove("chatstat.dat")
local handle=openfile("chatstat.dat","a")
write(handle,ChatStatCounter.."\n")
for a,b in ChatStat do
write(handle,a.."?"..b.."\n")
end
closefile(handle)
SendToAll( "?Stats?"," Classifica salvata...")
end
function show_top5(userobj)
local index1, key1
local index2, key2
local index3, key3
local index4, key4
local index5, key5
local index6, key6
local index7, key7
local index8, key8
local index9, key9
local index10, key10
key1=0
key2=0
key3=0
key4=0
key5=0
key6=0
key7=0
key8=0
key9=0
key10=0
for a,b in ChatStat do
if (ChatStat[a]>key1) then
----for top 10-------
index10=index9
key10=key9
index9=index8
key9=key8
index8=index7
key8=key7
index7=index6
key7=key6
index6=index5
key6=key5
-----------
index5=index4
key5=key4
index4=index3
key4=key3
index3=index2
key3=key2
index2=index1
key2=key1
index1=a
key1=ChatStat[a]
else
if (ChatStat[a]>key2) then
index10=index9
key10=key9
index9=index8
key9=key8
index8=index7
key8=key7
index7=index6
key7=key6
index6=index5
key6=key5
index5=index4
key5=key4
index4=index3
key4=key3
index3=index2
key3=key2
index2=a
key2=ChatStat[a]
else
if (ChatStat[a]>key3) then
index10=index9
key10=key9
index9=index8
key9=key8
index8=index7
key8=key7
index7=index6
key7=key6
index6=index5
key6=key5
index5=index4
key5=key4
index4=index3
key4=key3
index3=a
key3=ChatStat[a]
else
if (ChatStat[a]>key4) then
index10=index9
key10=key9
index9=index8
key9=key8
index8=index7
key8=key7
index7=index6
key7=key6
index6=index5
key6=key5
index5=index4
key5=key4
index4=a
key4=ChatStat[a]
else
if (ChatStat[a]>key5) then
index10=index9
key10=key9
index9=index8
key9=key8
index8=index7
key8=key7
index7=index6
key7=key6
index6=index5
key6=key5
index5=a
key5=ChatStat[a]
else
if (ChatStat[a]>key6) then
index10=index9
key10=key9
index9=index8
key9=key8
index8=index7
key8=key7
index7=index6
key7=key6
index6=a
key6=ChatStat[a]
else
if (ChatStat[a]>key7) then
index10=index9
key10=key9
index9=index8
key9=key8
index8=index7
key8=key7
index7=a
key7=ChatStat[a]
else
if (ChatStat[a]>key) then
index10=index9
key10=key9
index9=index8
key9=key8
index8=a
key8=ChatStat[a]
else
if (ChatStat[a]>key9) then
index10=index9
key10=key9
index9=a
key9=ChatStat[a]
else
if (ChatStat[a]>key10) then
index10=a
key10=ChatStat[a]
end
end
end
end
end
end
end
end
end
end
end
SendToAll(" Top 10 Chatters ")
SendToAll("_____________________________________________________")
SendToAll(" Nr. Posts\t=> User ")
SendToAll("?????????????????????????????????????????????????????")
if (index1~=nil) then
SendToAll("?"," N?1. "..ChatStat[index1].." linee \t=> "..index1)
end
if (index2~=nil) then
SendToAll("?"," N?2. "..ChatStat[index2].." linee \t=> "..index2)
end
if (index3~=nil) then
SendToAll("?"," N?3. "..ChatStat[index3].." linee \t=> "..index3)
end
if (index4~=nil) then
SendToAll("?"," N?4. "..ChatStat[index4].." linee \t=> "..index4)
end
if (index5~=nil) then
SendToAll("?"," N?5. "..ChatStat[index5].." linee \t=> "..index5)
end
if (index6~=nil) then
SendToAll("?"," N?6. "..ChatStat[index6].." linee \t=> "..index6)
end
if (index7~=nil) then
SendToAll("?"," N?7. "..ChatStat[index7].." linee \t=> "..index7)
end
if (index8~=nil) then
SendToAll("?"," N?8. "..ChatStat[index8].." linee \t=> "..index8)
end
if (index9~=nil) then
SendToAll("?"," N?9. "..ChatStat[index9].." linee \t=> "..index9)
end
if (index10~=nil) then
SendToAll("?"," N?10. "..ChatStat[index10].." linee \t=> "..index10)
end
SendToAll("_____________________________________________________")
end
function GetCommand(data)
s,e,whoTo,from,cmd = strfind(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(%S+)")
return cmd
end
function DataArrival(user, data)
if (( strsub(data, 1, 1) == "<" ))then
if (ChatStat[user.sName] == nil) then
ChatStat[user.sName]=1
else
ChatStat[user.sName]=ChatStat[user.sName]+1
end
ChatStatCounter=ChatStatCounter
end
if(strsub(data, 1, 4) == "$To:") then
s,e,whoTo,from,cmd = strfind(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(%S+)")
cmd=strsub(cmd,1,strlen(cmd)-1)
if (whoTo == botname) then
if (cmd=="+stats") then
show_top5(user)
end
if (cmd=="+help")then
user:SendPM(botname, "===============================================")
user:SendPM(botname, "Here's the commands :")
user:SendPM(botname, "")
user:SendPM(botname, "+stats\t- Show top")
user:SendPM(botname, "+load\t- Load Stats( OP's)")
user:SendPM(botname, "+save\t- Save Stats ( OP's)")
user:SendPM(botname, "===============================================")
end
if (user.bOperator) then
if (cmd=="+save") then
save_stats(user)
end
if (cmd=="+load") then
load_stats(user)
end
if (cmd=="!reset") then
reset(user)
end
end
end
end
-------Chat Commands Added By D@zzler------------
if( strsub(data, 1, 1) == "<" ) then
-- get the msg only using regular expression
data=strsub(data,1,strlen(data)-1)
-- parse the command
s,e,cmd = strfind( data, "%b<>%s+(%S+)" )
s,e,mess = strfind(data, "%b<> ([%w ]*)")
if (cmd=="+stats")then
a = 3
show_top5(user)
end
if (user.bOperator) then
if (cmd=="+save") then
save_stats(user)
end
if (user.bOperator) then
if (cmd=="+load") then
load_stats(user)
end
end
end
end
-----------------------------------------------
-----------------------------------------------
end
function OnTimer()
remove("chatstat.dat")
local handle=openfile("chatstat.dat","a")
write(handle,ChatStatCounter.."\n")
for a,b in ChatStat do
write(handle,a.."?"..b.."\n")
end
closefile(handle)
end
function load_stats(user)
local handle=openfile("chatstat.dat","r")
ChatStatCounter=read(handle)
Poll={}
while 1 do
local line = read(handle)
if line == nil then break
else
x,y,a=strfind(line,")[^?]*)")
x,y,b=strfind(line,")[^?]*)$")
ChatStat[a]=tonumber(b)
end
end
closefile(handle)
SendToAll( "?Stats?"," ? Classifica caricata...")
end