Chat Stats
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

Chat Stats

Started by c h i l l a, 26 January, 2004, 19:53:56

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

c h i l l a

--Chat stats by chill for xjr13sp.
--Serialisation by RabidWombat


cmd1 = "+showstats"	-- Main Command

Max1 = 10		-- How Many to chatters are shown of eahc genre.

howToSort = 1	-- Stands for the sorting either 1= least first, 2 = highest first.

StatsFile = "ChatStats.txt"
StatsFolder = "txt"
ChatStats = {}
dofile(StatsFolder.."/"..StatsFile)

chatEmotions = {
	[":)"] = 1,
	[":-)"] = 1,
	[":("] = 1,
	[":-("] = 1,
	[";)"] = 1,
	[";-)"] = 1,
	[":-p"] = 1,
	[":p"] = 1,
	[":D"] = 1,
	[":-D"] = 1,
}


function Main()
	SetTimer(1000*60*5)
	StartTimer()
end

function OnTimer()
	WriteTable(ChatStats,"ChatStats",StatsFile)
end

function DataArrival(curUser,data)
	if strsub(data,1,1) == "<" then
		if not ChatStats[curUser.sName] then
			ChatStats[curUser.sName] = {}
			ChatStats[curUser.sName].words = 0
			ChatStats[curUser.sName].chars = 0
			ChatStats[curUser.sName].emotions = 0
		end
		data = strsub(data,strlen(curUser.sName)+4,strlen(data)-1)
		curName = curUser.sName
		gsub(data,"(%S+)",function(w)
			ChatStats[curName].chars = ChatStats[curName].chars + strlen(w)
			if chatEmotions[w] then
				ChatStats[curName].emotions = ChatStats[curName].emotions + 1
			else
				ChatStats[curName].words = ChatStats[curName].words + 1
			end
		end)
		curName = nil

		local _,_,word1 = strfind(data,"^(%S+)")

		if word1 and STATSFUNC[word1] then
			SendToAll(STATSFUNC[word1]())
		end

	end
end

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

--	TABLE FUNCTIONS

---------------------------------------------------------------------------------------
STATSFUNC = {
	[cmd1] = function()
		TCopy = {}

		for i,v in ChatStats do

			tinsert(TCopy,{i,v})

		end

		local msg = "-----  Current Chat Stats ------\r\n\r\n\tTop "..Max1.." Char Stats\r\n\r\n"
		if howToSort == 1 then
			sort(TCopy,function(a,b) return(a[2].chars < b[2].chars) end)
		else
			sort(TCopy,function(a,b) return(a[2].chars > b[2].chars) end)
		end
		for i = 1,Max1 do
			if TCopy[i] then
				msg = msg.."\t# "..i.."  -  "..TCopy[i][1]..", with "..TCopy[i][2].chars.." chars.\r\n"
			end
		end

		if howToSort == 1 then
			sort(TCopy,function(a,b) return(a[2].words < b[2].words) end)
		else
			sort(TCopy,function(a,b) return(a[2].words > b[2].words) end)
		end
		msg = msg.."\r\n\tTop "..Max1.." Word Stats\r\n\r\n"
		for i = 1,Max1 do
			if TCopy[i] then
				msg = msg.."\t# "..i.."  -  "..TCopy[i][1]..", with "..TCopy[i][2].words.." words.\r\n"
			end
		end

		if howToSort == 1 then
			sort(TCopy,function(a,b) return(a[2].emotions < b[2].emotions) end)
		else
			sort(TCopy,function(a,b) return(a[2].emotions > b[2].emotions) end)
		end
		msg = msg.."\r\n\tTop "..Max1.." Emotion Stats\r\n\r\n"
		for i = 1,Max1 do
			if TCopy[i] then
				msg = msg.."\t# "..i.."  -  "..TCopy[i][1]..", with "..TCopy[i][2].emotions.." emotions.\r\n"
			end
		end

		return(msg)
	end,
}

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

--	Write Tables

---------------------------------------------------------------------------------------
function WriteTable(table,tablename,file)
	local handle = openfile(StatsFolder.."/"..file,"w")
	Serialize(table,tablename,handle)
  	closefile(handle)
end
--------------------------------------------
function Serialize(tTable,sTableName,hFile,sTab)
	sTab = sTab or "";
	write(hFile,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,hFile,sTab.."\t");
		else
			local sValue = (type(value) == "string") and format("%q",value) or tostring(value);
			write(hFile,sTab.."\t"..sKey.." = "..sValue);
		end
		write(hFile,",\n");
	end
	write(hFile,sTab.."}");
end

BlazeXxX

chilla,
Nice to see this script, but have some doubts to ask.

I am using Guib's standalone chat scripts script, which is already built in with the Channelbot.

My Question is, Does this script use less resources than Guib's one?

If it is, i will grab it ;)

c h i l l a

well, I don't know guibs one..
the source using parts in this script, are

1. Memory whne haveing many users chatting.
2. the data parsing. the gsub function. I quiets slow acrtually.
3. when showing the top chatters. This sorst a table 3 times, also depending on how mayn users you have it will take longer or less long.

but I can't think of any optimazions, right now.
Works okey in my little 50 users hub.

around 100 KB at the moment

c h i l l a

Just checked guibs channel bot, but I would need to check it mor to find the stats part.

but since I doesn't have table indexing, its already slower in that part.
else I can't say, only the script would need major rewriting.

WickeD

Can you fix the chatstats script that you have write so when one user type the command +showstats in mainchat it is only shown for that user and not for all users???


//WickeD

BlazeXxX

Hi wicked,
Just do this..

Find this bit of code in DataArrival part:

if word1 and STATSFUNC[word1] then
SendToAll(STATSFUNC[word1]())
end

Replace it as :

if word1 and STATSFUNC[word1] then
SendPmToNick(STATSFUNC[word1]())
end


That will send the stats to the user in his pm.
If it doesn't work get back to me..

WickeD

I do not want the massage to go in a PM to the user! I want it to go in a PM in main chat to the user! So only the user that type the command can see it in the main chat!

Here are the script I use!


--------------------------------------------------------------------
--Chat stats by chill for xjr13sp.
--Serialisation by RabidWombat


cmd1 = "!showchatstats"   -- Main Command

Max1 = 10      -- How Many to chatters are shown of eahc genre.

howToSort = 2   -- Stands for the sorting either 1= least first, 2 = highest first.

StatsFile = "ChatStats.txt"
StatsFolder = "txt"
ChatStats = {}
dofile(StatsFolder.."/"..StatsFile)

chatEmotions = {
   [":)"] = 1,
   [":-)"] = 1,
   [":("] = 1,
   [":-("] = 1,
   [";)"] = 1,
   [";-)"] = 1,
   [":-p"] = 1,
   [":p"] = 1,
   [":D"] = 1,
   [":-D"] = 1,
}


function Main()
   SetTimer(1000*60*5)
   StartTimer()
end

function OnTimer()
   WriteTable(ChatStats,"ChatStats",StatsFile)
end

function DataArrival(curUser,data)
   if strsub(data,1,1) == "<" then
      if not ChatStats[curUser.sName] then
         ChatStats[curUser.sName] = {}
         ChatStats[curUser.sName].words = 0
         ChatStats[curUser.sName].chars = 0
         ChatStats[curUser.sName].emotions = 0
      end
      data = strsub(data,strlen(curUser.sName)+4,strlen(data)-1)
      curName = curUser.sName
      gsub(data,"(%S+)",function(w)
         ChatStats[curName].chars = ChatStats[curName].chars + strlen(w)
         if chatEmotions[w] then
            ChatStats[curName].emotions = ChatStats[curName].emotions + 1
         else
            ChatStats[curName].words = ChatStats[curName].words + 1
         end
      end)
      curName = nil

      local _,_,word1 = strfind(data,"^(%S+)")

      if word1 and STATSFUNC[word1] then
         SendToAll(STATSFUNC[word1]())
      end

   end
end

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

--   TABLE FUNCTIONS

---------------------------------------------------------------------------------------
STATSFUNC = {
   [cmd1] = function()
      TCopy = {}

      for i,v in ChatStats do

         tinsert(TCopy,{i,v})

      end

      local msg = "-----  Current Chat Stats ------\r\n\r\n\tTop "..Max1.." Chat Stats\r\n\r\n"
      if howToSort == 1 then
         sort(TCopy,function(a,b) return(a[2].chars < b[2].chars) end)
      else
         sort(TCopy,function(a,b) return(a[2].chars > b[2].chars) end)
      end
      for i = 1,Max1 do
         if TCopy then
            msg = msg.."\t# "..i.."  -  "..TCopy[1]..", with "..TCopy[2].chars.." chars.\r\n"
         end
      end

      if howToSort == 1 then
         sort(TCopy,function(a,b) return(a[2].words < b[2].words) end)
      else
         sort(TCopy,function(a,b) return(a[2].words > b[2].words) end)
      end
      msg = msg.."\r\n\tTop "..Max1.." Word Stats\r\n\r\n"
      for i = 1,Max1 do
         if TCopy then
            msg = msg.."\t# "..i.."  -  "..TCopy[1]..", with "..TCopy[2].words.." words.\r\n"
         end
      end

      if howToSort == 1 then
         sort(TCopy,function(a,b) return(a[2].emotions < b[2].emotions) end)
      else
         sort(TCopy,function(a,b) return(a[2].emotions > b[2].emotions) end)
      end
      msg = msg.."\r\n\tTop "..Max1.." Emotion Stats\r\n\r\n"
      for i = 1,Max1 do
         if TCopy then
            msg = msg.."\t# "..i.."  -  "..TCopy[1]..", with "..TCopy[2].emotions.." emotions.\r\n"
         end
      end

      return(msg)
   end,
}

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

--   Write Tables

---------------------------------------------------------------------------------------
function WriteTable(table,tablename,file)
   local handle = openfile(StatsFolder.."/"..file,"w")
   Serialize(table,tablename,handle)
     closefile(handle)
end
--------------------------------------------
function Serialize(tTable,sTableName,hFile,sTab)
   sTab = sTab or "";
   write(hFile,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,hFile,sTab.."\t");
      else
         local sValue = (type(value) == "string") and format("%q",value) or tostring(value);
         write(hFile,sTab.."\t"..sKey.." = "..sValue);
      end
      write(hFile,",\n");
   end
   write(hFile,sTab.."}");
end

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

//WickeD

c h i l l a

#7
it's added, and luckily I know now how to access a variable in outerscope, gave me some headaches ;).

--Chat stats by chill
--Serialisation by RabidWombat

----------------------------------------------------------
----------------------------------------------------------
cmd1 = "+showstats"	-- Main Command
Max1 = 10		-- How Many top chatters are shown of each genre.
ChatConf = {
	howToSort = 1,	-- Stands for the sorting either 1= least first, 2 = highest first.
	howToSend = 1,	-- 1 = Sends to all, 2 = Sends to user.
}
----------------------------------------------------------
----------------------------------------------------------
StatsFile = "ChatStats.txt"
StatsFolder = "txt"
----------------------------------------------------------
----------------------------------------------------------

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

--	MAIN SCRIPT

---------------------------------------------------------------------------------------
ChatStats = {}
dofile(StatsFolder.."/"..StatsFile)
----------------------------------------------------------
chatEmotions = {
	[":)"] = 1,
	[":-)"] = 1,
	[":("] = 1,
	[":-("] = 1,
	[";)"] = 1,
	[";-)"] = 1,
	[":-p"] = 1,
	[":p"] = 1,
	[":D"] = 1,
	[":-D"] = 1,
}
----------------------------------------------------------
function Main()
	SetTimer(1000*60*5)
	StartTimer()
end
----------------------------------------------------------
function OnTimer()
	WriteTable(ChatStats,"ChatStats",StatsFile)
end
----------------------------------------------------------
function DataArrival(curUser,data)

	if strsub(data,1,1) == "<" then

		if not ChatStats[curUser.sName] then
			ChatStats[curUser.sName] = {}
			ChatStats[curUser.sName].words = 0
			ChatStats[curUser.sName].chars = 0
			ChatStats[curUser.sName].emotions = 0
		end

		data = strsub(data,strlen(curUser.sName)+4,strlen(data)-1)

		gsub(data,"(%S+)",function(w)
			ChatStats[%curUser.sName].chars = ChatStats[%curUser.sName].chars + strlen(w)
			if chatEmotions[w] then
				ChatStats[%curUser.sName].emotions = ChatStats[%curUser.sName].emotions + 1
			else
				ChatStats[%curUser.sName].words = ChatStats[%curUser.sName].words + 1
			end
		end)

		local _,_,word1 = strfind(data,"^(%S+)")

		if word1 and STATSFUNC[word1] then
			if ChatConf.howToSend == 1 then
				SendToAll(STATSFUNC[word1]())
			elseif ChatConf.howToSend == 2 then
				curUser:SendData(STATSFUNC[word1]())
			end
		end

	end
end
---------------------------------------------------------------------------------------

--	SORTING TABLE

---------------------------------------------------------------------------------------
function doSortTable(table,field)
	if ChatConf.howToSort == 1 then
		if field == "ALL" then
			sort(table, function(a,b) return((a[2].chars + a[2].words + a[2].emotions)  < (b[2].chars + b[2].words + b[2].emotions)) end)
		else
			sort(table, function(a,b) return(a[2][%field] < b[2][%field]) end)
		end
	elseif ChatConf.howToSort == 2 then
		if field == "ALL" then
			sort(table, function(a,b) return((a[2].chars + a[2].words + a[2].emotions)  > (b[2].chars + b[2].words + b[2].emotions)) end)
		else
			sort(table, function(a,b) return(a[2][%field] > b[2][%field]) end)
		end
	end
	return table
end
---------------------------------------------------------------------------------------

--	TABLE FUNCTIONS

---------------------------------------------------------------------------------------
STATSFUNC = {
	[cmd1] = function()

		local sTable = {}
		foreach(ChatStats, function(i,v) tinsert(%sTable,{i,v}) end)
		local msg = "-----  Current Chat Stats ------\r\n"

		sTable = doSortTable(sTable,"ALL")
		msg = msg.."\r\n\tTop "..Max1.." Overall Stats\r\n\r\n"
		for i = 1,Max1 do
			if sTable[i] then
				msg = msg.."\t# "..i.."  -  "..sTable[i][1]..", "..(sTable[i][2].chars + sTable[i][2].words + sTable[i][2].emotions).." overall,  "..sTable[i][2].chars.." chars, "..sTable[i][2].words.." words, "..sTable[i][2].emotions.." emotions.\r\n"
			end
		end
		sTable = doSortTable(sTable,"chars")
		msg = msg.."\r\n\tTop "..Max1.." Char Stats\r\n\r\n"
		for i = 1,Max1 do
			if sTable[i] then
				msg = msg.."\t# "..i.."  -  "..sTable[i][1]..", with "..sTable[i][2].chars.." chars.\r\n"
			end
		end
		sTable = doSortTable(sTable,"words")
		msg = msg.."\r\n\tTop "..Max1.." Word Stats\r\n\r\n"
		for i = 1,Max1 do
			if sTable[i] then
				msg = msg.."\t# "..i.."  -  "..sTable[i][1]..", with "..sTable[i][2].words.." words.\r\n"
			end
		end
		sTable = doSortTable(sTable,"emotions")
		msg = msg.."\r\n\tTop "..Max1.." Emotion Stats\r\n\r\n"
		for i = 1,Max1 do
			if sTable[i] then
				msg = msg.."\t# "..i.."  -  "..sTable[i][1]..", with "..sTable[i][2].emotions.." emotions.\r\n"
			end
		end
		return(msg)

	end,
}
---------------------------------------------------------------------------------------

--	Write Tables

---------------------------------------------------------------------------------------
function WriteTable(table,tablename,file)
	local handle = openfile(StatsFolder.."/"..file,"w")
	Serialize(table,tablename,handle)
  	closefile(handle)
end
--------------------------------------------
function Serialize(tTable,sTableName,hFile,sTab)
	sTab = sTab or "";
	write(hFile,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,hFile,sTab.."\t");
		else
			local sValue = (type(value) == "string") and format("%q",value) or tostring(value);
			write(hFile,sTab.."\t"..sKey.." = "..sValue);
		end
		write(hFile,",\n");
	end
	write(hFile,sTab.."}");
end

WickeD

Thx!!!!  Love you for all your help!!!!  ;)

//WickeD

c h i l l a

ahahaha,

thanks Wicked ;),

I could help you a lot more, if you were ...
a woman ,175, blond and had a fine body.
ahmm.. nope hair color doesn't matter.

[NL]trucker

actuallly chilla i had q few probs with this one.

the name emoticon wasn,t spelled right and when i tried to fix it by adding a c to it [you had emotions ]

i messed up the script somehow.

when i tried to chance this :

cmd1 = "+showstats"   -- Main Command
Max1 = 10      -- How Many top chatters are shown of each genre.
ChatConf = {
   howToSort = 1,   -- Stands for the sorting either 1= least first, 2 = highest first.
   howToSend = 1,   -- 1 = Sends to all, 2 = Sends to user.
}


into this:

cmd1 = "+showstats"   -- Main Command
Max1 = 10      -- How Many top chatters are shown of each genre.
ChatConf = {
   howToSort = 2,   -- Stands for the sorting either 1= least first, 2 = highest first.
   howToSend = 1,   -- 1 = Sends to all, 2 = Sends to user.
}


it gave me some errors wich i dindt record [stupid me]
Owner of FunnyHub
 
Funyhub.no-ip.info
       Forum Master of


c h i l l a

try this one...

--Chat stats by chill
--Serialisation by RabidWombat

----------------------------------------------------------
----------------------------------------------------------
ChatConf = {
	bot = "-ChatStats-",		-- The Name of the bot.
	cmd1 = "+showstats",		-- Shows the Stats.
	Max1 = 10,			-- How Many top chatters are shown of each genre.
	howToSort = 2,		-- Stands for the sorting either 1= least first, 2 = highest first.
	howToSend = 1,		-- 1 = Sends to all, 2 = Sends to user, 3 = PM to the user, 4 = PM to the user and regs a bot.
	StatsFile = "ChatStats.txt",	-- The Filename
	StatsFolder = "txt",		-- The Folder
}
----------------------------------------------------------
----------------------------------------------------------

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

--	MAIN SCRIPT

---------------------------------------------------------------------------------------
ChatStats = {}
dofile(ChatConf.StatsFolder.."/"..ChatConf.StatsFile)
----------------------------------------------------------
chatEmotions = {
	[":)"] = 1,
	[":-)"] = 1,
	[":("] = 1,
	[":-("] = 1,
	[";)"] = 1,
	[";-)"] = 1,
	[":-p"] = 1,
	[":p"] = 1,
	[":D"] = 1,
	[":-D"] = 1,
}
----------------------------------------------------------
function Main()
	frmHub:UnregBot(ChatConf.bot)
	if ChatConf.howToSend == 4 then
		frmHub:RegBot(ChatConf.bot)
	end
	SetTimer(1000*60*5)
	StartTimer()
end
----------------------------------------------------------
function OnTimer()
	WriteTable(ChatStats,"ChatStats",ChatConf.StatsFile)
end
----------------------------------------------------------
function DataArrival(curUser,data)

	if strsub(data,1,1) == "<" then

		if not ChatStats[curUser.sName] then
			ChatStats[curUser.sName] = {}
			ChatStats[curUser.sName].words = 0
			ChatStats[curUser.sName].chars = 0
			ChatStats[curUser.sName].emotions = 0
		end

		data = strsub(data,strlen(curUser.sName)+4,strlen(data)-1)

		gsub(data,"(%S+)",function(w)
			ChatStats[%curUser.sName].chars = ChatStats[%curUser.sName].chars + strlen(w)
			if chatEmotions[w] then
				ChatStats[%curUser.sName].emotions = ChatStats[%curUser.sName].emotions + 1
			else
				ChatStats[%curUser.sName].words = ChatStats[%curUser.sName].words + 1
			end
		end)

		local _,_,word1 = strfind(data,"^(%S+)")

		if word1 and STATSFUNC[word1] then
			if ChatConf.howToSend == 1 then
				SendToAll(ChatConf.bot,STATSFUNC[word1]())
			elseif ChatConf.howToSend == 2 then
				curUser:SendData(ChatConf.bot,STATSFUNC[word1]())
			elseif (ChatConf.howToSend == 3) or (ChatConf.howToSend == 4) then
				curUser:SendPM(ChatConf.bot,STATSFUNC[word1]())
			end
		end

	end
end
---------------------------------------------------------------------------------------

--	SORTING TABLE

---------------------------------------------------------------------------------------
function doSortTable(table,field)
	if ChatConf.howToSort == 1 then
		if field == "ALL" then
			sort(table, function(a,b) return((a[2].chars + a[2].words + a[2].emotions)  < (b[2].chars + b[2].words + b[2].emotions)) end)
		else
			sort(table, function(a,b) return(a[2][%field] < b[2][%field]) end)
		end
	elseif ChatConf.howToSort == 2 then
		if field == "ALL" then
			sort(table, function(a,b) return((a[2].chars + a[2].words + a[2].emotions)  > (b[2].chars + b[2].words + b[2].emotions)) end)
		else
			sort(table, function(a,b) return(a[2][%field] > b[2][%field]) end)
		end
	end
	return table
end
---------------------------------------------------------------------------------------

--	TABLE FUNCTIONS

---------------------------------------------------------------------------------------
STATSFUNC = {
	[ChatConf.cmd1] = function()

		local sTable = {}
		foreach(ChatStats, function(i,v) tinsert(%sTable,{i,v}) end)
		local msg = "-----  Current Chat Stats ------\r\n"

		sTable = doSortTable(sTable,"ALL")
		msg = msg.."\r\n\tTop "..ChatConf.Max1.." Overall Stats\r\n\r\n"
		for i = 1,ChatConf.Max1 do
			if sTable[i] then
				msg = msg.."\t# "..i.."  -  "..sTable[i][1]..", "..(sTable[i][2].chars + sTable[i][2].words + sTable[i][2].emotions).." overall,  "..sTable[i][2].chars.." chars, "..sTable[i][2].words.." words, "..sTable[i][2].emotions.." emotions.\r\n"
			end
		end
		sTable = doSortTable(sTable,"chars")
		msg = msg.."\r\n\tTop "..ChatConf.Max1.." Char Stats\r\n\r\n"
		for i = 1,ChatConf.Max1 do
			if sTable[i] then
				msg = msg.."\t# "..i.."  -  "..sTable[i][1]..", with "..sTable[i][2].chars.." chars.\r\n"
			end
		end
		sTable = doSortTable(sTable,"words")
		msg = msg.."\r\n\tTop "..ChatConf.Max1.." Word Stats\r\n\r\n"
		for i = 1,ChatConf.Max1 do
			if sTable[i] then
				msg = msg.."\t# "..i.."  -  "..sTable[i][1]..", with "..sTable[i][2].words.." words.\r\n"
			end
		end
		sTable = doSortTable(sTable,"emotions")
		msg = msg.."\r\n\tTop "..ChatConf.Max1.." Emotion Stats\r\n\r\n"
		for i = 1,ChatConf.Max1 do
			if sTable[i] then
				msg = msg.."\t# "..i.."  -  "..sTable[i][1]..", with "..sTable[i][2].emotions.." emotions.\r\n"
			end
		end
		return(msg)

	end,
}
---------------------------------------------------------------------------------------

--	Write Tables

---------------------------------------------------------------------------------------
function WriteTable(table,tablename,file)
	local handle = openfile(ChatConf.StatsFolder.."/"..file,"w")
	Serialize(table,tablename,handle)
  	closefile(handle)
end
--------------------------------------------
function Serialize(tTable,sTableName,hFile,sTab)
	sTab = sTab or "";
	write(hFile,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,hFile,sTab.."\t");
		else
			local sValue = (type(value) == "string") and format("%q",value) or tostring(value);
			write(hFile,sTab.."\t"..sKey.." = "..sValue);
		end
		write(hFile,",\n");
	end
	write(hFile,sTab.."}");
end

[NL]trucker

chilla

it is working fine now but i have one request left

could you make it so that it is onley sown to the user who asks for it?
this can be in main no need for sending an pm .;-)
Owner of FunnyHub
 
Funyhub.no-ip.info
       Forum Master of


c h i l l a

just read the head of the script again..

howToSend = 1,      -- 1 = Sends to all, 2 = Sends to user, 3 = PM to the user, 4 = PM to the user and regs a bot.

;)

[NL]trucker

chilla

sorry m8 you,re right think it is to late for me need to get some sleep to think straight again :-))
Owner of FunnyHub
 
Funyhub.no-ip.info
       Forum Master of


Snoris

#15
 1:  function `write' [C]
   2:  function `Serialize' at line 152 [file `D:\Freedom][Haninge\scripts\Chatstats.lua']
   3:  function `WriteTable' at line 146 [file `D:\Freedom][Haninge\scripts\Chatstats.lua']
   4:  function `OnTimer' at line 51 [file `D:\Freedom][Haninge\scripts\Chatstats.lua']

Did take a look at it..But I dont know anything of this =))

*LINE 51*
WriteTable(ChatStats,"ChatStats",ChatConf.StatsFile)
*LINE 146*
Serialize(table,tablename,handle)
*LINE 152*
write(hFile,sTab..sTableName.." = {\n");

Well whats the problem=))
And YES...I have a *.TXT file in the TEXT folder with the right name =)

SMF spam blocked by CleanTalk