PtokaX forum

Archive => Archived 5.0 boards => Help with scripts => Topic started by: suattnav on 17 May, 2005, 17:55:30

Title: ChatStat v3
Post by: suattnav on 17 May, 2005, 17:55:30
Chatstat erros


 No chat statics found!  
Title:
Post by: jiten on 17 May, 2005, 18:02:46
QuoteOriginally posted by suattnav
Chatstat erros


 No chat statics found!  
That's a common error for users that haven't spoken in main. Try chatting and using that command again. You'll see that the error report will be gone.

Btw, next time, please post in its respective thread ;)

Cheers
Title:
Post by: suattnav on 17 May, 2005, 21:14:00
Chatstat erros


 No chat statics found!  
[/QUOTE]
That's a common error for users that haven't spoken in main. Try chatting and using that command again. You'll see that the error report will be gone.

I spoken in main.Much.
The error report not gone.

 No chat statics found!
Title:
Post by: jiten on 17 May, 2005, 22:05:48
Which version of the script are you using? madman or Herodes one?
Title:
Post by: suattnav on 18 May, 2005, 07:41:25
QuoteOriginally posted by jiten
Which version of the script are you using? madman or Herodes one?

I use this.



-- ChatStats v3 Made By Optimus

-- Based on Tezlo chats

-- Added Send Commands By TiMeTrAVelleR

-- Madman fixed some in commands

-- Converted to lua5 by Madman with very little help by Jelf

-- with some help by ?

-- fixed stats saving on exit by jiten

---- Modded by Madman

-- Added so it's creates ChatStatsFile, if it's missing

-- Fixed so it dont counts commands

-- Added a IgnoreTable, users in that wont be counted

----



sBot = "Chatstats"      -- Name of Bot

SendComm = 1          -- Send UserCommands 1 = On  0 = Off

pMenu = "-=( ChatStats )=-"    -- Name of Menu

ChatStatsTo = "user" -- Send TopChatters to? user or all



Chatstats = {}



Sortstats = 2   -- 1=words / 2=posts



ChatStatsFile = "chatstats.tbl"



IgnoreTable = {

-- 0=dont ignore/1=ignore

   ["Madman"] = 0,

   ["-=FakeKiller=-"] = 1,

}



EnableChatStats = {

    then

--                              Nr:         Posts:            Chars:            Words:            Name:

               chat = chat.."\t "..i..".\t "..TCopy[2].."\t "..TCopy[3].."\t "..TCopy[4].."\t"..TCopy[1].."\r\n"

            end

         end

         if ChatStatsTo == "user" then

            user:SendData(sBot, chat)

         elseif ChatStatsTo == "all" then

            SendToAll(sBot, chat)

         end

         TCopy={}

      end

      return 1

   elseif (cmd == "!delchatter") and AllowedProfiles[user.iProfile] == 1 then

      local s,e,cmd,name = string.find( data, "%b<>%s+(%S+)%s+(%S+)" )

      if name then

         if Chatstats[name] then

            Chatstats[name] = nil

            user:SendData(sBot, "Chatstats from user "..name.." are now removed!")

            saveTableToFile(ChatStatsFile, Chatstats, "Chatstats")

         else

            user:SendData(sBot, "*** Chatstats from user "..name.." not found!")

         end

      else

         user:SendData(sBot, "*** Usage: !delchatter ")

      end

      return 1

   elseif (cmd == "!clearchatstats") and AllowedProfiles[user.iProfile] == 1 then

      Chatstats = {}

      saveTableToFile(ChatStatsFile, Chatstats, "Chatstats")

      user:SendData(sBot, "Chatstats are cleared by "..user.sName)

      return 1

   end

end



function updStats(nick, str)

   local tmp = Chatstats[nick] or {["post"]=0, ["chars"]=0, ["words"]=0, ["time"]=os.date("%x")}

   tmp["post"], tmp["chars"], tmp["words"], tmp["time"] = tmp["post"]+1, tmp["chars"]+string.len(str), tmp["words"]+cntargs(str,"(%a+)"), os.date("%x")

   Chatstats[nick] = tmp

   saveTableToFile(ChatStatsFile, Chatstats, "Chatstats")

end



function cntargs(str, rule)

   local s,n = string.gsub(str, rule, "")

   return n

end



----------------------------------------------

-- load & save Tables

----------------------------------------------

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 saveTableToFile(file, table, tablename)

   local handle = io.open(file,"w+")

   handle:write(Serialize(table, tablename))

   handle:flush()

   handle:close()

end

-----------------------------------------------------------

function loadTableFromFile(file)

   local handle = io.open(file,"r")

   if (handle ~= nil) then

      loadstring(handle:read("*all"))

      handle:flush()

      handle:close()

   end

end



-------------table checker by herodes

--- for an associative table, like ["smth"] = "smth else",

function isEmpty(t)

   for i,v in t do

      return false;

   end

   return true;

end;
Title:
Post by: jiten on 18 May, 2005, 10:00:23
That message is only sent when you use the "!mychatstat" command and when you haven't typed anything at all in main.
It's really strange as it would work after typing something.
Maybe you're doing something wrong there.
Title:
Post by: uffetjur on 18 May, 2005, 10:04:54
gets same problem with this version, might be interfering with other scripts
Title:
Post by: Dessamator on 18 May, 2005, 10:13:08
QuoteOriginally posted by uffetjur
gets same problem with this version, might be interfering with other scripts

yap, might be try disabling the other scripts, or puting this one on top !
Title:
Post by: suattnav on 18 May, 2005, 12:42:31
I put Script on to top.
 
Yes,its working.

Thanks to all.

It's very little think sometimes.
Title:
Post by: Dessamator on 18 May, 2005, 14:14:07
yaps scripts are like that sometimes, ur welcome!
Title:
Post by: jiten on 18 May, 2005, 18:23:38
QuoteOriginally posted by suattnav
I put Script on to top.
 
Yes,its working.

Thanks to all.

It's very little think sometimes.
I'm glad to know that the problem is solved.

Cheers m8