Graphbot conversion
 

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

Graphbot conversion

Started by ConejoDelMal, 14 March, 2005, 05:00:41

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ConejoDelMal

Can somebody please help me convert this script? I've been trying to convert on my own, but this one is too much for a beginner like me...

--#-- GraphBot by Herodes
-- Working Version (but after repeating the cmd x 5 times u don't get any refresh on the tables ...)
-- fixed correction of kb, mb, gb, tb display
-- now the user count centers on top of the column...
-- input from NotRambitWombat made it even shorter.. :)
-- Tried to get the extra tables working but I couldn't .. :(
-- Making progress on this ... Added tables tried to get them to work again ..
-- It gets the values to the tables but it has an error (indicated in script) [ 8:20 pm 30-5-2004 ]
-- After heavy tutoring session with plop, The Script is working as Intented !
--##-- thanx to All the ppl who helped ... bonus to plop  5:02 am 3-6-2004
--- Returns a graph of the present user count along with the present share and the time
--- Remembers up to three previous graphs and displays simultaneously
---** Trying the command while you are the only user turns up with error (fixed //  1:29 pm 3-6-2004 // )
---** ...  no worries wait for someone to join and then try it again ... (fixed //  1:29 pm 3-6-2004 // )
-- Script edited by [BR]Carlos, script now doesnt looses data when restarting scripts 

gBot = "-=Brainu=-"		-- you may edit the bot to whatever u want
graphcmd = "!graph"		-- you may edit the command to whatever u want
rstgraphcmd = "!rstgraph"	-- you may edit the command to whatever u want
fullcell = "   :?:\t"
emptycell = "\t"
count = 0
DataFile = "graphdata.txt"
tTab = { [1] = "\t", [2] = "\t", [3] = "\t", [4] = "\t", [5] = "\t", [6] = "\t", [7] = "\t", [8] = "\t", [9] = "\t", [10] = "\t", [11] = "\t", [12] = "\t", };
tTable = { [1] = "\t", [2] = "\t", [3] = "\t", [4] = "\t", [5] = "\t", [6] = "\t", [7] = "\t", [8] = "\t", [9] = "\t", [10] = "\t", [11] = "\t", [12] = "\t", };
tCol1= { [1] = "\t", [2] = "\t", [3] = "\t", [4] = "\t", [5] = "\t", [6] = "\t", [7] = "\t", [8] = "\t", [9] = "\t", [10] = "\t", [11] = "\t", [12] = "\t", };
tCol2= { [1] = "\t", [2] = "\t", [3] = "\t", [4] = "\t", [5] = "\t", [6] = "\t", [7] = "\t", [8] = "\t", [9] = "\t", [10] = "\t", [11] = "\t", [12] = "\t", };
tCol3= { [1] = "\t", [2] = "\t", [3] = "\t", [4] = "\t", [5] = "\t", [6] = "\t", [7] = "\t", [8] = "\t", [9] = "\t", [10] = "\t", [11] = "\t", [12] = "\t", };

-----------------------------------------------------------------------------------
function resetGraph() 
	count = 0
	tTab = { [1] = "\t", [2] = "\t", [3] = "\t", [4] = "\t", [5] = "\t", [6] = "\t", [7] = "\t", [8] = "\t", [9] = "\t", [10] = "\t", [11] = "\t", [12] = "\t", };
	tTable = { [1] = "\t", [2] = "\t", [3] = "\t", [4] = "\t", [5] = "\t", [6] = "\t", [7] = "\t", [8] = "\t", [9] = "\t", [10] = "\t", [11] = "\t", [12] = "\t", };
	tCol1= { [1] = "\t", [2] = "\t", [3] = "\t", [4] = "\t", [5] = "\t", [6] = "\t", [7] = "\t", [8] = "\t", [9] = "\t", [10] = "\t", [11] = "\t", [12] = "\t", };
	tCol2= { [1] = "\t", [2] = "\t", [3] = "\t", [4] = "\t", [5] = "\t", [6] = "\t", [7] = "\t", [8] = "\t", [9] = "\t", [10] = "\t", [11] = "\t", [12] = "\t", };
	tCol3= { [1] = "\t", [2] = "\t", [3] = "\t", [4] = "\t", [5] = "\t", [6] = "\t", [7] = "\t", [8] = "\t", [9] = "\t", [10] = "\t", [11] = "\t", [12] = "\t", };
end 
-----------------------------------------------------------------------------------
function Load()
	readfrom(DataFile) -- arquivo que vai dar o append
	
	local teste = read()
	
	if teste == nil then
		resetGraph()
	else
	
		tTab[1] = teste
		tTab[2] = read()
		tTab[3] = read()
		tTab[4] = read()
		tTab[5] = read()
		tTab[6] = read()
		tTab[7] = read()
		tTab[8] = read()
		tTab[9] = read()
		tTab[10] = read()
		tTab[11] = read()
		tTab[12] = read()

		tTable[1] = read()
		tTable[2] = read()
		tTable[3] = read()
		tTable[4] = read()
		tTable[5] = read()
		tTable[6] = read()
		tTable[7] = read()
		tTable[8] = read()
		tTable[9] = read()
		tTable[10] = read()
		tTable[11] = read()
		tTable[12] = read()

		tCol1[1] = read()
		tCol1[2] = read()
		tCol1[3] = read()
		tCol1[4] = read()
		tCol1[5] = read()
		tCol1[6] = read()
		tCol1[7] = read()
		tCol1[8] = read()
		tCol1[9] = read()
		tCol1[10] = read()
		tCol1[11] = read()
		tCol1[12] = read()

		tCol2[1] = read()
		tCol2[2] = read()
		tCol2[3] = read()
		tCol2[4] = read()
		tCol2[5] = read()
		tCol2[6] = read()
		tCol2[7] = read()
		tCol2[8] = read()
		tCol2[9] = read()
		tCol2[10] = read()
		tCol2[11] = read()
		tCol2[12] = read()

		tCol3[1] = read()
		tCol3[2] = read()
		tCol3[3] = read()
		tCol3[4] = read()
		tCol3[5] = read()
		tCol3[6] = read()
		tCol3[7] = read()
		tCol3[8] = read()
		tCol3[9] = read()
		tCol3[10] = read()
		tCol3[11] = read()
		tCol3[12] = read()
	end
	
	flush()
	readfrom()

end
-----------------------------------------------------------------------------------
function Save()
	writeto(DataFile) -- o writeto pra apagar oq tinha antes
	write("")
	appendto(DataFile) -- agora soh vai adicionando coisas
	write(tTab[1].."\n"..tTab[2].."\n"..tTab[3].."\n"..tTab[4].."\n"..tTab[5].."\n"..tTab[6].."\n"..tTab[7].."\n"..tTab[8].."\n"..tTab[9].."\n"..tTab[10].."\n"..tTab[11].."\n"..tTab[12].."\n")
	write(tTable[1].."\n"..tTable[2].."\n"..tTable[3].."\n"..tTable[4].."\n"..tTable[5].."\n"..tTable[6].."\n"..tTable[7].."\n"..tTable[8].."\n"..tTable[9].."\n"..tTable[10].."\n"..tTable[11].."\n"..tTable[12].."\n") 
	write(tCol1[1].."\n"..tCol1[2].."\n"..tCol1[3].."\n"..tCol1[4].."\n"..tCol1[5].."\n"..tCol1[6].."\n"..tCol1[7].."\n"..tCol1[8].."\n"..tCol1[9].."\n"..tCol1[10].."\n"..tCol1[11].."\n"..tCol1[12].."\n") 
	write(tCol2[1].."\n"..tCol2[2].."\n"..tCol2[3].."\n"..tCol2[4].."\n"..tCol2[5].."\n"..tCol2[6].."\n"..tCol2[7].."\n"..tCol2[8].."\n"..tCol2[9].."\n"..tCol2[10].."\n"..tCol2[11].."\n"..tCol2[12].."\n") 
	write(tCol3[1].."\n"..tCol3[2].."\n"..tCol3[3].."\n"..tCol3[4].."\n"..tCol3[5].."\n"..tCol3[6].."\n"..tCol3[7].."\n"..tCol3[8].."\n"..tCol3[9].."\n"..tCol3[10].."\n"..tCol3[11].."\n"..tCol3[12]) 
	writeto(DataFile) 
	writeto() -- fecha o arquivo
	flush()
end
-----------------------------------------------------------------------------------
function Main()
	Load()
	FixTable(tCol2, tCol3) 
	FixTable(tCol1, tCol2) 
	FixTable(tTable, tCol1)
end
----------------------------------------------------------------------- the command
function DataArrival(user, data)
	if (strsub(data, 1, 1) == "<" ) then
		data=strsub(data,1,strlen(data)-1)
		s,e,cmd = strfind(data,"%b<>%s+(%S+)")
		if cmd~=nil then
			if cmd==graphcmd then
				TransferAll()
				Save()
			elseif cmd==rstgraphcmd then --and user.iProfile == 0  then -- interessante soh OP pode executar isso
				resetGraph()
			end
		end
	end
end
----------------------------------------------------------------------- place the values in table and return table
function AddValues()
	tTable = {}
	GetNumbers()
	if usrC > 1 then
		local pivot = 11 - floor(usrC / maxU * 10)
		for i = 1,10 do
			if ( i < pivot ) then
				tTable[i] = emptycell
			elseif ( i == pivot ) then
				tTable[i] = userCount
			else 
				tTable[i] = fullcell 
			end
		end
	end
	if usrC == 1 then
		SendToAll(gBot, "Where did everybody go ?")
	end
	tTable[11] = Time
	tTable[12] = hubshrS
	return tTable
end
----------------------------------------------------------------------- get the data (numbers) needed, format and return them
function GetNumbers()
   Time, userCount, maxU, hubshare = "\t"
   Time = date("%H")..":"..date("%M")..":"..date("%S")
   usrC = frmHub:GetUsersCount()
   userCount = AddSpacesToKey(usrC)
   maxU = frmHub:GetMaxUsers()
   midU = maxU/2
   local thubshare = format("%0.1f", ( frmHub:GetCurrentShareAmount() / 1024))
   hubshrS = thubshare.." kb"
   if tonumber(thubshare) >= 1024 and tonumber(thubshare) < (1024^2) then
      hubshrS = format("%0.1f", ( frmHub:GetCurrentShareAmount() / (1024^2))).." mb"
   elseif tonumber(thubshare) >= (1024^2) and tonumber(thubshare) < (1024^3) then
      hubshrS = format("%0.1f", ( frmHub:GetCurrentShareAmount() / (1024^3))).." gb"
   elseif tonumber(thubshare) >= (1024^3) then
      hubshrS = format("%0.1f", ( frmHub:GetCurrentShareAmount() / (1024^4))).." tb"
   end
   return Time, userCount, maxU, midU, hubshare, usrC, hubshrS
end
----------------------------------------------------------------------- push the values in a > b 
function FixTable(table1, table2)
   for i, v in table1 do
      i = tonumber(i)
      if i == nil then 
         i = 1 
      end
      table2[i]= v 
   end
end
----------------------------------------------------------------------- logical route for handling the tables ..
function TransferAll()
if count == 1 then
	FixTable(tCol2, tCol3) 
	FixTable(tCol1, tCol2) 
	FixTable(tTable, tCol1)
	AddValues()
	GiveGraph()
else
	DoTranferTab()
	AddValues() 
	GiveGraph()
end
end
----------------------------------------------------------------------- straigth run ? pushing the tables .. 
function DoTranferTab()
   if tTable[11] ~= "\t" then
      if tCol3[11] == "\t"then 
         FixTable(tCol2, tCol3) 
         FixTable(tCol1, tCol2) 
         FixTable(tTable, tCol1)
      elseif tCol2[11] == "\t" then
         FixTable(tCol1, tCol2) 
         FixTable(tTable, tCol1)
      elseif tCol1[11] == "\t" and count == 1 then 
         FixTable(tTable, tCol1)
         count = 0
      end
   end
count = count + 1
end
----------------------------------------------------------------------- the graph showing the values of all tables
function GiveGraph()
   tMsg = "\r\n\t\t\t- "..frmHub:GetHubName().." - Gr?fico de Users/Share -"
   tMsg = tMsg.."\r\n - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -o-0-o- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "
   tMsg = tMsg.."\r\n -> Share\t:\t"..tTable[12].."\t\t"..tCol1[12].."\t\t"..tCol2[12].."\t\t"..tCol3[12]
   tMsg = tMsg.."\r\n 100% ("..maxU..")\t\t"..tTable[1].."\t"..tCol1[1].."\t"..tCol2[1].."\t"..tCol3[1]
   tMsg = tMsg.."\r\n --- - -  -   -\t\t"..tTable[2].."\t"..tCol1[2].."\t"..tCol2[2].."\t"..tCol3[2]
   tMsg = tMsg.."\r\n --- - -  -   -\t\t"..tTable[3].."\t"..tCol1[3].."\t"..tCol2[3].."\t"..tCol3[3]
   tMsg = tMsg.."\r\n --- - -  -   -\t\t"..tTable[4].."\t"..tCol1[4].."\t"..tCol2[4].."\t"..tCol3[4]
   tMsg = tMsg.."\r\n --- - -  -   -\t\t"..tTable[5].."\t"..tCol1[5].."\t"..tCol2[5].."\t"..tCol3[5]
   tMsg = tMsg.."\r\n 50% ("..midU..")\t\t"..tTable[6].."\t"..tCol1[6].."\t"..tCol2[6].."\t"..tCol3[6]
   tMsg = tMsg.."\r\n --- - -  -   -\t\t"..tTable[7].."\t"..tCol1[7].."\t"..tCol2[7].."\t"..tCol3[7]
   tMsg = tMsg.."\r\n --- - -  -   -\t\t"..tTable[8].."\t"..tCol1[8].."\t"..tCol2[8].."\t"..tCol3[8]
   tMsg = tMsg.."\r\n --- - -  -   -\t\t"..tTable[9].."\t"..tCol1[9].."\t"..tCol2[9].."\t"..tCol3[9]
   tMsg = tMsg.."\r\n --- - -  -   -\t\t"..tTable[10].."\t"..tCol1[10].."\t"..tCol2[10].."\t"..tCol3[10]
   tMsg = tMsg.."\r\n- 0% (0). . . . . . . . . . \t. .:?:. . . . . . . . . . . . .\t. .:?:. . . . . . . . . . . . .\t. .:?:. . . . . . . . . . . . .\t. .:?:. . . . . . . . . . . . ."
   tMsg = tMsg.."\r\n ->  Time\t:            "..tTable[11].."\t             "..tCol1[11].."\t             "..tCol2[11].."\t             "..tCol3[11].."\t (GMT + 1)"
   SendToAll(gBot, tMsg)
end
----------------------------------------------------------------------- adding appropriate number of spaces to a string
function AddSpacesToKey(data)
   local ratio = (5 - strlen(data))
   local tcell = strrep(" ", ratio)..data.."\t"
   return tcell
end
Rede-DC Comunidade Portuguesa de DC

Jelf

Here ya go..
-- Converted to Lua5 By Jelf 14/03/05
--#-- GraphBot by Herodes
-- Working Version (but after repeating the cmd x 5 times u don't get any refresh on the tables ...)
-- fixed correction of kb, mb, gb, tb display
-- now the user count centers on top of the column...
-- input from NotRambitWombat made it even shorter.. :)
-- Tried to get the extra tables working but I couldn't .. :(
-- Making progress on this ... Added tables tried to get them to work again ..
-- It gets the values to the tables but it has an error (indicated in script) [ 8:20 pm 30-5-2004 ]
-- After heavy tutoring session with plop, The Script is working as Intented !
--##-- thanx to All the ppl who helped ... bonus to plop  5:02 am 3-6-2004
--- Returns a graph of the present user count along with the present share and the time
--- Remembers up to three previous graphs and displays simultaneously
---** Trying the command while you are the only user turns up with error (fixed //  1:29 pm 3-6-2004 // )
---** ...  no worries wait for someone to join and then try it again ... (fixed //  1:29 pm 3-6-2004 // )
-- Script edited by [BR]Carlos, script now doesnt looses data when restarting scripts 

gBot = "-=Brainu=-"		-- you may edit the bot to whatever u want
graphcmd = "!graph"		-- you may edit the command to whatever u want
rstgraphcmd = "!rstgraph"	-- you may edit the command to whatever u want
fullcell = "   :?:\t"
emptycell = "\t"
count = 0
DataFile = "graphdata.txt"
tTab = { [1] = "\t", [2] = "\t", [3] = "\t", [4] = "\t", [5] = "\t", [6] = "\t", [7] = "\t", [8] = "\t", [9] = "\t", [10] = "\t", [11] = "\t", [12] = "\t", };
tTable = { [1] = "\t", [2] = "\t", [3] = "\t", [4] = "\t", [5] = "\t", [6] = "\t", [7] = "\t", [8] = "\t", [9] = "\t", [10] = "\t", [11] = "\t", [12] = "\t", };
tCol1= { [1] = "\t", [2] = "\t", [3] = "\t", [4] = "\t", [5] = "\t", [6] = "\t", [7] = "\t", [8] = "\t", [9] = "\t", [10] = "\t", [11] = "\t", [12] = "\t", };
tCol2= { [1] = "\t", [2] = "\t", [3] = "\t", [4] = "\t", [5] = "\t", [6] = "\t", [7] = "\t", [8] = "\t", [9] = "\t", [10] = "\t", [11] = "\t", [12] = "\t", };
tCol3= { [1] = "\t", [2] = "\t", [3] = "\t", [4] = "\t", [5] = "\t", [6] = "\t", [7] = "\t", [8] = "\t", [9] = "\t", [10] = "\t", [11] = "\t", [12] = "\t", };

local f,e = io.open(DataFile, "a+" ) --//Error handle.. makes sure save file and dir exist...
f,e = io.open(DataFile, "a+" )
if f then
	f:write("" ) 
	f:close() --// file and path did not exist.. now they do.
end
-----------------------------------------------------------------------------------
function resetGraph() 
	count = 0
	tTab = { [1] = "\t", [2] = "\t", [3] = "\t", [4] = "\t", [5] = "\t", [6] = "\t", [7] = "\t", [8] = "\t", [9] = "\t", [10] = "\t", [11] = "\t", [12] = "\t", };
	tTable = { [1] = "\t", [2] = "\t", [3] = "\t", [4] = "\t", [5] = "\t", [6] = "\t", [7] = "\t", [8] = "\t", [9] = "\t", [10] = "\t", [11] = "\t", [12] = "\t", };
	tCol1= { [1] = "\t", [2] = "\t", [3] = "\t", [4] = "\t", [5] = "\t", [6] = "\t", [7] = "\t", [8] = "\t", [9] = "\t", [10] = "\t", [11] = "\t", [12] = "\t", };
	tCol2= { [1] = "\t", [2] = "\t", [3] = "\t", [4] = "\t", [5] = "\t", [6] = "\t", [7] = "\t", [8] = "\t", [9] = "\t", [10] = "\t", [11] = "\t", [12] = "\t", };
	tCol3= { [1] = "\t", [2] = "\t", [3] = "\t", [4] = "\t", [5] = "\t", [6] = "\t", [7] = "\t", [8] = "\t", [9] = "\t", [10] = "\t", [11] = "\t", [12] = "\t", };
end 
-----------------------------------------------------------------------------------
function Load()
	local handle = io.open(DataFile,"r") -- arquivo que vai dar o append
	local teste = handle:read()
	if teste == nil then
		resetGraph()
	else
		tTab[1] = teste
		tTab[2] = handle:read()
		tTab[3] = handle:read()
		tTab[4] = handle:read()
		tTab[5] = handle:read()
		tTab[6] = handle:read()
		tTab[7] = handle:read()
		tTab[8] = handle:read()
		tTab[9] = handle:read()
		tTab[10] = handle:read()
		tTab[11] = handle:read()
		tTab[12] = handle:read()

		tTable[1] = handle:read()
		tTable[2] = handle:read()
		tTable[3] = handle:read()
		tTable[4] = handle:read()
		tTable[5] = handle:read()
		tTable[6] = handle:read()
		tTable[7] = handle:read()
		tTable[8] = handle:read()
		tTable[9] = handle:read()
		tTable[10] = handle:read()
		tTable[11] = handle:read()
		tTable[12] = handle:read()

		tCol1[1] = handle:read()
		tCol1[2] = handle:read()
		tCol1[3] = handle:read()
		tCol1[4] = handle:read()
		tCol1[5] = handle:read()
		tCol1[6] = handle:read()
		tCol1[7] = handle:read()
		tCol1[8] = handle:read()
		tCol1[9] = handle:read()
		tCol1[10] = handle:read()
		tCol1[11] = handle:read()
		tCol1[12] = handle:read()

		tCol2[1] = handle:read()
		tCol2[2] = handle:read()
		tCol2[3] = handle:read()
		tCol2[4] = handle:read()
		tCol2[5] = handle:read()
		tCol2[6] = handle:read()
		tCol2[7] = handle:read()
		tCol2[8] = handle:read()
		tCol2[9] = handle:read()
		tCol2[10] = handle:read()
		tCol2[11] = handle:read()
		tCol2[12] = handle:read()

		tCol3[1] = handle:read()
		tCol3[2] = handle:read()
		tCol3[3] = handle:read()
		tCol3[4] = handle:read()
		tCol3[5] = handle:read()
		tCol3[6] = handle:read()
		tCol3[7] = handle:read()
		tCol3[8] = handle:read()
		tCol3[9] = handle:read()
		tCol3[10] = handle:read()
		tCol3[11] = handle:read()
		tCol3[12] = handle:read()
	end
	io.flush()
	handle:close()
end
-----------------------------------------------------------------------------------
function Save()
	local handle = io.open(DataFile,"a+") -- agora soh vai adicionando coisas
	handle:write(tTab[1].."\n"..tTab[2].."\n"..tTab[3].."\n"..tTab[4].."\n"..tTab[5].."\n"..tTab[6].."\n"..tTab[7].."\n"..tTab[8].."\n"..tTab[9].."\n"..tTab[10].."\n"..tTab[11].."\n"..tTab[12].."\n")
	handle:write(tTable[1].."\n"..tTable[2].."\n"..tTable[3].."\n"..tTable[4].."\n"..tTable[5].."\n"..tTable[6].."\n"..tTable[7].."\n"..tTable[8].."\n"..tTable[9].."\n"..tTable[10].."\n"..tTable[11].."\n"..tTable[12].."\n") 
	handle:write(tCol1[1].."\n"..tCol1[2].."\n"..tCol1[3].."\n"..tCol1[4].."\n"..tCol1[5].."\n"..tCol1[6].."\n"..tCol1[7].."\n"..tCol1[8].."\n"..tCol1[9].."\n"..tCol1[10].."\n"..tCol1[11].."\n"..tCol1[12].."\n") 
	handle:write(tCol2[1].."\n"..tCol2[2].."\n"..tCol2[3].."\n"..tCol2[4].."\n"..tCol2[5].."\n"..tCol2[6].."\n"..tCol2[7].."\n"..tCol2[8].."\n"..tCol2[9].."\n"..tCol2[10].."\n"..tCol2[11].."\n"..tCol2[12].."\n") 
	handle:write(tCol3[1].."\n"..tCol3[2].."\n"..tCol3[3].."\n"..tCol3[4].."\n"..tCol3[5].."\n"..tCol3[6].."\n"..tCol3[7].."\n"..tCol3[8].."\n"..tCol3[9].."\n"..tCol3[10].."\n"..tCol3[11].."\n"..tCol3[12]) 
	handle:close() -- fecha o arquivo
	io.flush()
end
-----------------------------------------------------------------------------------
function Main()
	Load()
	FixTable(tCol2, tCol3) 
	FixTable(tCol1, tCol2) 
	FixTable(tTable, tCol1)
end
----------------------------------------------------------------------- the command
function ChatArrival(user, data)
	data=string.sub(data,1,string.len(data)-1)
	s,e,cmd = string.find(data,"%b<>%s+(%S+)")
	if cmd~=nil then
		if cmd==graphcmd then
			TransferAll()
			Save()
			return 1
		elseif cmd==rstgraphcmd then --and user.iProfile == 0  then -- interessante soh OP pode executar isso
			resetGraph()
			return 1
		end
	end
end
----------------------------------------------------------------------- place the values in table and return table
function AddValues()
	tTable = {}
	GetNumbers()
	if usrC > 1 then
		local pivot = 11 - math.floor(usrC / maxU * 10)
		for i = 1,10 do
			if ( i < pivot ) then
				tTable[i] = emptycell
			elseif ( i == pivot ) then
				tTable[i] = userCount
			else 
				tTable[i] = fullcell 
			end
		end
	end
	if usrC == 1 then
		SendToAll(gBot, "Where did everybody go ?")
	end
	tTable[11] = Time
	tTable[12] = hubshrS
	return tTable
end
----------------------------------------------------------------------- get the data (numbers) needed, format and return them
function GetNumbers()
   Time, userCount, maxU, hubshare = "\t"
   Time = os.date("%H")..":"..os.date("%M")..":"..os.date("%S")
   usrC = frmHub:GetUsersCount()
   userCount = AddSpacesToKey(usrC)
   maxU = frmHub:GetMaxUsers()
   midU = maxU/2
   local thubshare = string.format("%0.1f", ( frmHub:GetCurrentShareAmount() / 1024))
   hubshrS = thubshare.." kb"
   if tonumber(thubshare) >= 1024 and tonumber(thubshare) < (1024^2) then
      hubshrS = string.format("%0.1f", ( frmHub:GetCurrentShareAmount() / (1024^2))).." mb"
   elseif tonumber(thubshare) >= (1024^2) and tonumber(thubshare) < (1024^3) then
      hubshrS = string.format("%0.1f", ( frmHub:GetCurrentShareAmount() / (1024^3))).." gb"
   elseif tonumber(thubshare) >= (1024^3) then
      hubshrS = string.format("%0.1f", ( frmHub:GetCurrentShareAmount() / (1024^4))).." tb"
   end
   return Time, userCount, maxU, midU, hubshare, usrC, hubshrS
end
----------------------------------------------------------------------- push the values in a > b 
function FixTable(table1, table2)
   for i, v in table1 do
      i = tonumber(i)
      if i == nil then 
         i = 1 
      end
      table2[i]= v 
   end
end
----------------------------------------------------------------------- logical route for handling the tables ..
function TransferAll()
if count == 1 then
	FixTable(tCol2, tCol3) 
	FixTable(tCol1, tCol2) 
	FixTable(tTable, tCol1)
	AddValues()
	GiveGraph()
else
	DoTranferTab()
	AddValues() 
	GiveGraph()
end
end
----------------------------------------------------------------------- straigth run ? pushing the tables .. 
function DoTranferTab()
   if tTable[11] ~= "\t" then
      if tCol3[11] == "\t"then 
         FixTable(tCol2, tCol3) 
         FixTable(tCol1, tCol2) 
         FixTable(tTable, tCol1)
      elseif tCol2[11] == "\t" then
         FixTable(tCol1, tCol2) 
         FixTable(tTable, tCol1)
      elseif tCol1[11] == "\t" and count == 1 then 
         FixTable(tTable, tCol1)
         count = 0
      end
   end
count = count + 1
end
----------------------------------------------------------------------- the graph showing the values of all tables
function GiveGraph()
   tMsg = "\r\n\t\t\t- "..frmHub:GetHubName().." - Gr?fico de Users/Share -"
   tMsg = tMsg.."\r\n - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -o-0-o- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "
   tMsg = tMsg.."\r\n -> Share\t:\t"..tTable[12].."\t\t"..tCol1[12].."\t\t"..tCol2[12].."\t\t"..tCol3[12]
   tMsg = tMsg.."\r\n 100% ("..maxU..")\t\t"..tTable[1].."\t"..tCol1[1].."\t"..tCol2[1].."\t"..tCol3[1]
   tMsg = tMsg.."\r\n --- - -  -   -\t\t"..tTable[2].."\t"..tCol1[2].."\t"..tCol2[2].."\t"..tCol3[2]
   tMsg = tMsg.."\r\n --- - -  -   -\t\t"..tTable[3].."\t"..tCol1[3].."\t"..tCol2[3].."\t"..tCol3[3]
   tMsg = tMsg.."\r\n --- - -  -   -\t\t"..tTable[4].."\t"..tCol1[4].."\t"..tCol2[4].."\t"..tCol3[4]
   tMsg = tMsg.."\r\n --- - -  -   -\t\t"..tTable[5].."\t"..tCol1[5].."\t"..tCol2[5].."\t"..tCol3[5]
   tMsg = tMsg.."\r\n 50% ("..midU..")\t\t"..tTable[6].."\t"..tCol1[6].."\t"..tCol2[6].."\t"..tCol3[6]
   tMsg = tMsg.."\r\n --- - -  -   -\t\t"..tTable[7].."\t"..tCol1[7].."\t"..tCol2[7].."\t"..tCol3[7]
   tMsg = tMsg.."\r\n --- - -  -   -\t\t"..tTable[8].."\t"..tCol1[8].."\t"..tCol2[8].."\t"..tCol3[8]
   tMsg = tMsg.."\r\n --- - -  -   -\t\t"..tTable[9].."\t"..tCol1[9].."\t"..tCol2[9].."\t"..tCol3[9]
   tMsg = tMsg.."\r\n --- - -  -   -\t\t"..tTable[10].."\t"..tCol1[10].."\t"..tCol2[10].."\t"..tCol3[10]
   tMsg = tMsg.."\r\n- 0% (0). . . . . . . . . . \t. .:?:. . . . . . . . . . . . .\t. .:?:. . . . . . . . . . . . .\t. .:?:. . . . . . . . . . . . .\t. .:?:. . . . . . . . . . . . ."
   tMsg = tMsg.."\r\n ->  Time\t:            "..tTable[11].."\t             "..tCol1[11].."\t             "..tCol2[11].."\t             "..tCol3[11].."\t (GMT + 1)"
   SendToAll(gBot, tMsg)
end
----------------------------------------------------------------------- adding appropriate number of spaces to a string
function AddSpacesToKey(data)
   local ratio = (5 - string.len(data))
   local tcell = string.rep(" ", ratio)..data.."\t"
   return tcell
end

UwV

[AT]conejodelmal

you may have seen it was ...

Was done already ..

Jelf nice work though ..
just a waist of your time .. unless you wanted to learn a thing or 1 .. ;0)
\NL   The knowledge and skills you have achieved are meant to be forgotten so you can float comfortably in emptiness, without obstruction.
" Holly loves me,...  . "      ;o)

& don't forget, the motto is :
  -- SUPPORT YOUR LOCAL DJ'S --

Jelf

LOL :)

Good job UwV

oh well, looks slightly different though

Always learning -  hehe

ConejoDelMal

#4
Thx a lot Jelf...will try it!

UwV, i searched, i looked, but the one i had wasnt exactly the same anymore, since it was changed by
Carlos, so that the data doesnt dissapears eveytime i restart scripts... so maybe you should take a closer look before acusing me.... just kiddin  :))

*Edited*
Works great Jelf....once again thx!
Rede-DC Comunidade Portuguesa de DC

UwV

right you are ..
didn't notice that one ..
so .. sorry for the 'accusing' .. ;0) ... coffee ?
\NL   The knowledge and skills you have achieved are meant to be forgotten so you can float comfortably in emptiness, without obstruction.
" Holly loves me,...  . "      ;o)

& don't forget, the motto is :
  -- SUPPORT YOUR LOCAL DJ'S --

ConejoDelMal

please  :P
no problem... all cleared
[]'s
Rede-DC Comunidade Portuguesa de DC

vadertje

1 question wen i use the graph script and the FreshStuff - v.2.60 togheter alway 1 not work how can that be and what can i do to so that i can use both scrips

SMF spam blocked by CleanTalk