PtokaX forum

Archive => Archived 4.0 boards => Help with Lua 4 scripts => Topic started by: nEgativE on 25 February, 2004, 14:25:30

Title: Script Help
Post by: nEgativE on 25 February, 2004, 14:25:30
Hi all, Hi Plop.. could u help me once again with this script here ? :(((
I'm getting syntax errors, when a user get in with no TAG i think.. running ptokax 0.3.3.0 beta.



-----------------------------------------------------------------------------
-- online user counter by plop v:1.2
-- based on a bot by ....... witch showed basic hub info 2 users on entry
-- (fill in the name pls if you know who this was)
-----------------------------------------------------------------------------
-- LEVELSTOT[number] = total number of users with that level
-- LEVELS[number] = total online number of users with that level
-- commands = table of triggers used by the hub 2 add/delete users
-- add the script commands yourself if you use a script 2 add/delete users
-- same can be done if you have more user levels then default
-----------------------------------------------------------------------------
-- tables all over but i seem 2 have forgotten 2 add chairs. snif snif
-----------------------------------------------------------------------------
-- manual stuff
-----------------------------------------------------------------------------
-- LEVELSTOT["0"] -- total masters
-- LEVELSTOT["1"] -- total operators
-- LEVELSTOT["2"] -- total VIPs
-- LEVELSTOT["3"] -- total registred users
-- tmp -- total operators and masters
-- frmHub:GetUsersCount() -- total online users
----------
-- LEVELS["0"] -- total online masters
-- LEVELS["1"] -- total online operators
-- LEVELS["2"] -- total online VIPs
-- LEVELS["3"] -- total online registered users
-- LEVELS["-1"] -- total online unregistered users
-- tmp3 -- total operators and masters
----------
-- offline users
-- LEVELSTOT["0"] - LEVELS["0"] == offline operators
-- tmp1 -- total offline VIPs
-- tmp2 -- total offline registered users
-----------------------------------------------------------------------------


-- name of the bot
Bot = "[operserv]"

-- couter tables, if you have more levels add there numbers in BOTH tables,
-- except unreg users, those only work in the lower table
LEVELSTOT = {["0"]=0, ["1"]=0, ["2"]=0, ["3"]=0}
LEVELS = {["0"]=0, ["1"]=0, ["2"]=0, ["3"]=0, ["-1"]=0}

-- table holding the commands ptokax uses 2 add/delete users
-- add your bot's commands 2 this table if you use a bot 2 add/delete ppl
commands = {["!addreguser"]=1, ["!delreguser"]=1}

function Message(user)
   local s,e,share = strfind(user.sMyInfoString, "$(%d+)%$")
   share = format("%0.2f", ( share / (1024*1024*1024)))
   local hubshare = format("%0.2f",  ( frmHub:GetCurrentShareAmount() / (1024*1024*1024)))
   local tmp = LEVELSTOT["1"] + LEVELSTOT["0"]  --- total ops  (adding masters 2 ops)
   local tmp1 = (LEVELSTOT["2"] - LEVELS["2"]) if tmp1 < 0 then tmp1 = 0 end --- offline vips (total - online)
   local tmp2 = (LEVELSTOT["3"] - LEVELS["3"]) if tmp2 < 0 then tmp2 = 0 end --- offline regs (total - online)
   local tmp3 = LEVELS["1"] + LEVELS["0"] -- online ops (adding masters 2 the ops)
   user:SendData(Bot, "-=[?]=-----------------------------------------------------------------------------------------------=[?]=-")
   user:SendData(Bot, " <-----=[- "..frmHub:GetHubName().." ? "..GetDate().." -]=----->")
   user:SendData(Bot, "-=[?]=-----------------------------------------------------------------------------------------------=[?]=-")
   user:SendData(Bot, "      ? Comunidade Lusobrasileira de ?irect C?nnect - P2P ?")
   user:SendData(Bot, "      ? "..user.sName..", bem vindo ao servidor.")
   user:SendData(Bot, "      ? Seu endere?o IP: "..user.sIP)
   user:SendData(Bot, "      ? Seu status no Hub: "..(GetProfileName(user.iProfile) or "N?o registrado"))
   user:SendData(Bot, "      ? Voc? est? compartilhando: "..share.." GB.")
   user:SendData(Bot, "      ? Usu?rios Online no Hub: "..frmHub:GetUsersCount()..".")
   user:SendData(Bot, "      ? Operadores Online no Hub: "..tmp3..". ViPs: "..LEVELS["2"]..".")
   user:SendData(Bot, "      ? Total de Operadores registrados no Hub: "..tmp..". ViPs: "..LEVELSTOT["2"]..".")
   user:SendData(Bot, "      ? Usu?rios registrados, n?o conectados: "..tmp2..".")
   user:SendData(Bot, "      ? Compartilhamento atual no Hub: "..hubshare.." GB.")
   user:SendData(Bot, "      ? Lista de comandos, regras, ajuda e informa??o: !ajuda")
   user:SendData(Bot, "      ? Website - F?rum: [URL]www.lusobrasil.site.vu[/URL]")
   user:SendData(Bot, "-=[?]=-----------------------------------------------------------------------------------------------=[?]=-")
   user:SendData(Bot, " <-----=[- "..frmHub:GetHubName().." ? "..GetDate().." -]=----->")
   user:SendData(Bot, "-=[?]=-----------------------------------------------------------------------------------------------=[?]=-")
end
-------------------------------------------------------------------------------------------------------------------------------------------------
function GetDate()
d = date("%d")
mm = date("%m")
y = date("%y")
Date = ""..d.."/"..mm.."/"..y
return Date
end
-------------------------------------------------------------------------------------------------------------------------------------------------
ALLUSERS={}

function NewUserConnected(user)
   if ALLUSERS[user.sName]==nil then
      ALLUSERS[user.sName]=1
      LEVELS[tostring(user.iProfile)]=LEVELS[tostring(user.iProfile)]+1
   end
   Message(user)
end

function OpConnected(user)
   if ALLUSERS[user.sName]==nil then
      ALLUSERS[user.sName]=1
      LEVELS[tostring(user.iProfile)]=LEVELS[tostring(user.iProfile)]+1
   end
   Message(user)
end

function DataArrival(user, data)
   if ALLUSERS[user.sName]==nil then
      ALLUSERS[user.sName]=1
      LEVELS[tostring(user.iProfile)]=LEVELS[tostring(user.iProfile)]+1
   end
   s,e,cmd= strfind(data, "%b<>%s+(%S+)")
   if cmd ~= nil and commands[cmd] then
      SetTimer(5 * 1000)
      StartTimer()
   end
end

function OnTimer()
   StopTimer()
   OpenRegisterdUsersFile()
end

function UserDisconnected(user)
   if ALLUSERS[user.sName] then
      ALLUSERS[user.sName]=nil
      if LEVELS[tostring(user.iProfile)] > 0 then
         LEVELS[tostring(user.iProfile)]=LEVELS[tostring(user.iProfile)]-1
      end
   end
end

function OpDisconnected(user)
   if ALLUSERS[user.sName] then
      ALLUSERS[user.sName]=nil
      if LEVELS[tostring(user.iProfile)] > 0 then
         LEVELS[tostring(user.iProfile)]=LEVELS[tostring(user.iProfile)]-1
      end
   end
end

function Main()
   frmHub:RegBot(Bot)
   OpenRegisterdUsersFile()
end

function OpenRegisterdUsersFile()
   readfrom("../RegisteredUsers.dat")
   for a,b in LEVELSTOT do
      LEVELSTOT[a]=0
   end
   while 1 do
      local line = read()
      local level
      if line == nil then
         readfrom()
         break
      end
      s,e,level = strfind(line,".+|.+|(.+)")
      if LEVELSTOT[level] then
         LEVELSTOT[level] = LEVELSTOT[level] +1
      end
   end  
end



Error:

Syntax error: bad argument #1 to `strfind' (string expected, got nil)
stack traceback:
   1:  function `strfind' [C]
   2:  function `Message' at line 50 [file `...\ptokax\scripts\online.counter.lua']
   3:  function `NewUserConnected' at line 92 [file `...\ptokax\scripts\online.counter.lua']

TkS in advance !

Plop Plop Plop :(
Title:
Post by: plop on 07 March, 2004, 21:01:44
i was on a sort of holiday.
but as you can see i'm back.

the tag/description isn't used @ all so that can't cause it.
what i can see is that it's caused by users without share.
bit weird as those should return 0 as share, but the script can find it @ all.
but this should fix it.
-----------------------------------------------------------------------------
-- online user counter by plop v:1.2
-- based on a bot by ....... witch showed basic hub info 2 users on entry
-- (fill in the name pls if you know who this was)
-----------------------------------------------------------------------------
-- LEVELSTOT[number] = total number of users with that level
-- LEVELS[number] = total online number of users with that level
-- commands = table of triggers used by the hub 2 add/delete users
-- add the script commands yourself if you use a script 2 add/delete users
-- same can be done if you have more user levels then default
-----------------------------------------------------------------------------
-- tables all over but i seem 2 have forgotten 2 add chairs. snif snif
-----------------------------------------------------------------------------
-- manual stuff
-----------------------------------------------------------------------------
-- LEVELSTOT["0"] -- total masters
-- LEVELSTOT["1"] -- total operators
-- LEVELSTOT["2"] -- total VIPs
-- LEVELSTOT["3"] -- total registred users
-- tmp -- total operators and masters
-- frmHub:GetUsersCount() -- total online users
----------
-- LEVELS["0"] -- total online masters
-- LEVELS["1"] -- total online operators
-- LEVELS["2"] -- total online VIPs
-- LEVELS["3"] -- total online registered users
-- LEVELS["-1"] -- total online unregistered users
-- tmp3 -- total operators and masters
----------
-- offline users
-- LEVELSTOT["0"] - LEVELS["0"] == offline operators
-- tmp1 -- total offline VIPs
-- tmp2 -- total offline registered users
-----------------------------------------------------------------------------


-- name of the bot
Bot = "[operserv]"

-- couter tables, if you have more levels add there numbers in BOTH tables,
-- except unreg users, those only work in the lower table
LEVELSTOT = {["0"]=0, ["1"]=0, ["2"]=0, ["3"]=0}
LEVELS = {["0"]=0, ["1"]=0, ["2"]=0, ["3"]=0, ["-1"]=0}

-- table holding the commands ptokax uses 2 add/delete users
-- add your bot's commands 2 this table if you use a bot 2 add/delete ppl
commands = {["!addreguser"]=1, ["!delreguser"]=1}

function Message(user)
   local s,e,share = strfind(user.sMyInfoString, "$(%d+)%$")
   if share ~= nil then
      share = format("%0.2f", ( share / (1024*1024*1024)))
   else
      share = 0
   end
   local hubshare = format("%0.2f",  ( frmHub:GetCurrentShareAmount() / (1024*1024*1024)))
   local tmp = LEVELSTOT["1"] + LEVELSTOT["0"]  --- total ops  (adding masters 2 ops)
   local tmp1 = (LEVELSTOT["2"] - LEVELS["2"]) if tmp1 < 0 then tmp1 = 0 end --- offline vips (total - online)
   local tmp2 = (LEVELSTOT["3"] - LEVELS["3"]) if tmp2 < 0 then tmp2 = 0 end --- offline regs (total - online)
   local tmp3 = LEVELS["1"] + LEVELS["0"] -- online ops (adding masters 2 the ops)
   user:SendData(Bot, "-=[?]=-----------------------------------------------------------------------------------------------=[?]=-")
   user:SendData(Bot, "        <-----=[- "..frmHub:GetHubName().." ? "..GetDate().." -]=----->")
   user:SendData(Bot, "-=[?]=-----------------------------------------------------------------------------------------------=[?]=-")
   user:SendData(Bot, "          ? Comunidade Lusobrasileira de ?irect C?nnect - P2P ?")
   user:SendData(Bot, "          ? "..user.sName..", bem vindo ao servidor.")
   user:SendData(Bot, "          ? Seu endere?o IP: "..user.sIP)
   user:SendData(Bot, "          ? Seu status no Hub: "..(GetProfileName(user.iProfile) or "N?o registrado"))
   user:SendData(Bot, "          ? Voc? est? compartilhando: "..share.." GB.")
   user:SendData(Bot, "          ? Usu?rios Online no Hub: "..frmHub:GetUsersCount()..".")
   user:SendData(Bot, "          ? Operadores Online no Hub: "..tmp3..". ViPs: "..LEVELS["2"]..".")
   user:SendData(Bot, "          ? Total de Operadores registrados no Hub: "..tmp..". ViPs: "..LEVELSTOT["2"]..".")
   user:SendData(Bot, "          ? Usu?rios registrados, n?o conectados: "..tmp2..".")
   user:SendData(Bot, "          ? Compartilhamento atual no Hub: "..hubshare.." GB.")
   user:SendData(Bot, "          ? Lista de comandos, regras, ajuda e informa??o: !ajuda")
   user:SendData(Bot, "          ? Website - F?rum: [URL]www.lusobrasil.site.vu[/URL]")
   user:SendData(Bot, "-=[?]=-----------------------------------------------------------------------------------------------=[?]=-")
   user:SendData(Bot, "        <-----=[- "..frmHub:GetHubName().." ? "..GetDate().." -]=----->")
   user:SendData(Bot, "-=[?]=-----------------------------------------------------------------------------------------------=[?]=-")
end

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

function GetDate()
    d = date("%d")
    mm = date("%m")
    y = date("%y")
    Date = ""..d.."/"..mm.."/"..y
    return Date
end
-------------------------------------------------------------------------------------------------------------------------------------------------
ALLUSERS={}

function NewUserConnected(user)
   if ALLUSERS[user.sName]==nil then
      ALLUSERS[user.sName]=1
      LEVELS[tostring(user.iProfile)]=LEVELS[tostring(user.iProfile)]+1
   end
   Message(user)
end

function OpConnected(user)
   if ALLUSERS[user.sName]==nil then
      ALLUSERS[user.sName]=1
      LEVELS[tostring(user.iProfile)]=LEVELS[tostring(user.iProfile)]+1
   end
   Message(user)
end

function DataArrival(user, data)
   if ALLUSERS[user.sName]==nil then
      ALLUSERS[user.sName]=1
      LEVELS[tostring(user.iProfile)]=LEVELS[tostring(user.iProfile)]+1
   end
   s,e,cmd= strfind(data, "%b<>%s+(%S+)")
   if cmd ~= nil and commands[cmd] then
      SetTimer(5 * 1000)
      StartTimer()
   end
end

function OnTimer()
   StopTimer()
   OpenRegisterdUsersFile()
end

function UserDisconnected(user)
   if ALLUSERS[user.sName] then
      ALLUSERS[user.sName]=nil
      if LEVELS[tostring(user.iProfile)] > 0 then
         LEVELS[tostring(user.iProfile)]=LEVELS[tostring(user.iProfile)]-1
      end
   end
end

function OpDisconnected(user)
   if ALLUSERS[user.sName] then
      ALLUSERS[user.sName]=nil
      if LEVELS[tostring(user.iProfile)] > 0 then
         LEVELS[tostring(user.iProfile)]=LEVELS[tostring(user.iProfile)]-1
      end
   end
end

function Main()
   frmHub:RegBot(Bot)
   OpenRegisterdUsersFile()
end

function OpenRegisterdUsersFile()
   readfrom("../RegisteredUsers.dat")
   for a,b in LEVELSTOT do
      LEVELSTOT[a]=0
   end
   while 1 do
      local line = read()
      local level
      if line == nil then
         readfrom()
         break
      end
      s,e,level = strfind(line,".+|.+|(.+)")
      if LEVELSTOT[level] then
         LEVELSTOT[level] = LEVELSTOT[level] +1
      end
   end  
end
plop
Title:
Post by: nEgativE on 07 March, 2004, 22:17:48
QuoteOriginally posted by plop
i was on a sort of holiday.
but as you can see i'm back.

the tag/description isn't used @ all so that can't cause it.
what i can see is that it's caused by users without share.
bit weird as those should return 0 as share, but the script can find it @ all.
but this should fix it.
-----------------------------------------------------------------------------
-- online user counter by plop v:1.2
-- based on a bot by ....... witch showed basic hub info 2 users on entry
-- (fill in the name pls if you know who this was)
-----------------------------------------------------------------------------
-- LEVELSTOT[number] = total number of users with that level
-- LEVELS[number] = total online number of users with that level
-- commands = table of triggers used by the hub 2 add/delete users
-- add the script commands yourself if you use a script 2 add/delete users
-- same can be done if you have more user levels then default
-----------------------------------------------------------------------------
-- tables all over but i seem 2 have forgotten 2 add chairs. snif snif
-----------------------------------------------------------------------------
-- manual stuff
-----------------------------------------------------------------------------
-- LEVELSTOT["0"] -- total masters
-- LEVELSTOT["1"] -- total operators
-- LEVELSTOT["2"] -- total VIPs
-- LEVELSTOT["3"] -- total registred users
-- tmp -- total operators and masters
-- frmHub:GetUsersCount() -- total online users
----------
-- LEVELS["0"] -- total online masters
-- LEVELS["1"] -- total online operators
-- LEVELS["2"] -- total online VIPs
-- LEVELS["3"] -- total online registered users
-- LEVELS["-1"] -- total online unregistered users
-- tmp3 -- total operators and masters
----------
-- offline users
-- LEVELSTOT["0"] - LEVELS["0"] == offline operators
-- tmp1 -- total offline VIPs
-- tmp2 -- total offline registered users
-----------------------------------------------------------------------------


-- name of the bot
Bot = "[operserv]"

-- couter tables, if you have more levels add there numbers in BOTH tables,
-- except unreg users, those only work in the lower table
LEVELSTOT = {["0"]=0, ["1"]=0, ["2"]=0, ["3"]=0}
LEVELS = {["0"]=0, ["1"]=0, ["2"]=0, ["3"]=0, ["-1"]=0}

-- table holding the commands ptokax uses 2 add/delete users
-- add your bot's commands 2 this table if you use a bot 2 add/delete ppl
commands = {["!addreguser"]=1, ["!delreguser"]=1}

function Message(user)
   local s,e,share = strfind(user.sMyInfoString, "$(%d+)%$")
   if share ~= nil then
      share = format("%0.2f", ( share / (1024*1024*1024)))
   else
      share = 0
   end
   local hubshare = format("%0.2f",  ( frmHub:GetCurrentShareAmount() / (1024*1024*1024)))
   local tmp = LEVELSTOT["1"] + LEVELSTOT["0"]  --- total ops  (adding masters 2 ops)
   local tmp1 = (LEVELSTOT["2"] - LEVELS["2"]) if tmp1 < 0 then tmp1 = 0 end --- offline vips (total - online)
   local tmp2 = (LEVELSTOT["3"] - LEVELS["3"]) if tmp2 < 0 then tmp2 = 0 end --- offline regs (total - online)
   local tmp3 = LEVELS["1"] + LEVELS["0"] -- online ops (adding masters 2 the ops)
   user:SendData(Bot, "-=[?]=-----------------------------------------------------------------------------------------------=[?]=-")
   user:SendData(Bot, "        <-----=[- "..frmHub:GetHubName().." ? "..GetDate().." -]=----->")
   user:SendData(Bot, "-=[?]=-----------------------------------------------------------------------------------------------=[?]=-")
   user:SendData(Bot, "          ? Comunidade Lusobrasileira de ?irect C?nnect - P2P ?")
   user:SendData(Bot, "          ? "..user.sName..", bem vindo ao servidor.")
   user:SendData(Bot, "          ? Seu endere?o IP: "..user.sIP)
   user:SendData(Bot, "          ? Seu status no Hub: "..(GetProfileName(user.iProfile) or "N?o registrado"))
   user:SendData(Bot, "          ? Voc? est? compartilhando: "..share.." GB.")
   user:SendData(Bot, "          ? Usu?rios Online no Hub: "..frmHub:GetUsersCount()..".")
   user:SendData(Bot, "          ? Operadores Online no Hub: "..tmp3..". ViPs: "..LEVELS["2"]..".")
   user:SendData(Bot, "          ? Total de Operadores registrados no Hub: "..tmp..". ViPs: "..LEVELSTOT["2"]..".")
   user:SendData(Bot, "          ? Usu?rios registrados, n?o conectados: "..tmp2..".")
   user:SendData(Bot, "          ? Compartilhamento atual no Hub: "..hubshare.." GB.")
   user:SendData(Bot, "          ? Lista de comandos, regras, ajuda e informa??o: !ajuda")
   user:SendData(Bot, "          ? Website - F?rum: [URL]www.lusobrasil.site.vu[/URL]")
   user:SendData(Bot, "-=[?]=-----------------------------------------------------------------------------------------------=[?]=-")
   user:SendData(Bot, "        <-----=[- "..frmHub:GetHubName().." ? "..GetDate().." -]=----->")
   user:SendData(Bot, "-=[?]=-----------------------------------------------------------------------------------------------=[?]=-")
end

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

function GetDate()
    d = date("%d")
    mm = date("%m")
    y = date("%y")
    Date = ""..d.."/"..mm.."/"..y
    return Date
end
-------------------------------------------------------------------------------------------------------------------------------------------------
ALLUSERS={}

function NewUserConnected(user)
   if ALLUSERS[user.sName]==nil then
      ALLUSERS[user.sName]=1
      LEVELS[tostring(user.iProfile)]=LEVELS[tostring(user.iProfile)]+1
   end
   Message(user)
end

function OpConnected(user)
   if ALLUSERS[user.sName]==nil then
      ALLUSERS[user.sName]=1
      LEVELS[tostring(user.iProfile)]=LEVELS[tostring(user.iProfile)]+1
   end
   Message(user)
end

function DataArrival(user, data)
   if ALLUSERS[user.sName]==nil then
      ALLUSERS[user.sName]=1
      LEVELS[tostring(user.iProfile)]=LEVELS[tostring(user.iProfile)]+1
   end
   s,e,cmd= strfind(data, "%b<>%s+(%S+)")
   if cmd ~= nil and commands[cmd] then
      SetTimer(5 * 1000)
      StartTimer()
   end
end

function OnTimer()
   StopTimer()
   OpenRegisterdUsersFile()
end

function UserDisconnected(user)
   if ALLUSERS[user.sName] then
      ALLUSERS[user.sName]=nil
      if LEVELS[tostring(user.iProfile)] > 0 then
         LEVELS[tostring(user.iProfile)]=LEVELS[tostring(user.iProfile)]-1
      end
   end
end

function OpDisconnected(user)
   if ALLUSERS[user.sName] then
      ALLUSERS[user.sName]=nil
      if LEVELS[tostring(user.iProfile)] > 0 then
         LEVELS[tostring(user.iProfile)]=LEVELS[tostring(user.iProfile)]-1
      end
   end
end

function Main()
   frmHub:RegBot(Bot)
   OpenRegisterdUsersFile()
end

function OpenRegisterdUsersFile()
   readfrom("../RegisteredUsers.dat")
   for a,b in LEVELSTOT do
      LEVELSTOT[a]=0
   end
   while 1 do
      local line = read()
      local level
      if line == nil then
         readfrom()
         break
      end
      s,e,level = strfind(line,".+|.+|(.+)")
      if LEVELSTOT[level] then
         LEVELSTOT[level] = LEVELSTOT[level] +1
      end
   end  
end
plop

Thank U i'll check the script :))
Hope u had some good time there at holidays !!
Title:
Post by: plop on 08 March, 2004, 00:23:20
QuoteOriginally posted by Luso Thank U i'll check the script :))
Hope u had some good time there at holidays !!
yep was great, i was actualy here @ home.
just i wasn't allowed 2 be here on the keyboard as much as normal.
my g/f came over here finaly again.
girls are so demanding. lol (if she sees this remark she would smack me in the face).
naa sweet girl, after 9 month's not seeing eachother you need some qualety time 2gether.
and we sure had that.

plop
Title:
Post by: nEgativE on 10 March, 2004, 02:50:39
Hehehe, don't get married like i did !! major war here, had 2 computers now.. she's allways playing that UT game onlime.. still need to increase my dsl band here.. ! grr.

tell me Plop / nErBoS, is there a way to include on this script, how many Hubs and slots the user is / have ?
like this:    user:SendData(Bot, "? You are on "..hubs.." and have "..slots.." open.")


-----------------------------------------------------------------------------
-- online user counter by plop v:1.2
-- based on a bot by ....... witch showed basic hub info 2 users on entry
-- (fill in the name pls if you know who this was)
-----------------------------------------------------------------------------
-- LEVELSTOT[number] = total number of users with that level
-- LEVELS[number] = total online number of users with that level
-- commands = table of triggers used by the hub 2 add/delete users
-- add the script commands yourself if you use a script 2 add/delete users
-- same can be done if you have more user levels then default
-----------------------------------------------------------------------------
-- tables all over but i seem 2 have forgotten 2 add chairs. snif snif
-----------------------------------------------------------------------------
-- manual stuff
-----------------------------------------------------------------------------
-- LEVELSTOT["0"] -- total masters
-- LEVELSTOT["1"] -- total operators
-- LEVELSTOT["2"] -- total VIPs
-- LEVELSTOT["3"] -- total registred users
-- tmp -- total operators and masters
-- frmHub:GetUsersCount() -- total online users
----------
-- LEVELS["0"] -- total online masters
-- LEVELS["1"] -- total online operators
-- LEVELS["2"] -- total online VIPs
-- LEVELS["3"] -- total online registered users
-- LEVELS["-1"] -- total online unregistered users
-- tmp3 -- total operators and masters
----------
-- offline users
-- LEVELSTOT["0"] - LEVELS["0"] == offline operators
-- tmp1 -- total offline VIPs
-- tmp2 -- total offline registered users
-----------------------------------------------------------------------------
-- name of the bot
Bot = "[operserv]"

-- couter tables, if you have more levels add there numbers in BOTH tables,
-- except unreg users, those only work in the lower table
LEVELSTOT = {["0"]=0, ["1"]=0, ["2"]=0, ["3"]=0}
LEVELS = {["0"]=0, ["1"]=0, ["2"]=0, ["3"]=0, ["-1"]=0}

Stattxt = "txt/stat.txt" --Will be created in the script folder

Stat = {
logins = 0,
share = 0,
users = 0,
}

-- table holding the commands ptokax uses 2 add/delete users
-- add your bot's commands 2 this table if you use a bot 2 add/delete ppl
commands = {["!addreguser"]=1, ["!delreguser"]=1}
-------------------------------------------------------------------------------------------------------------------------------------------------
function Message(user)
   local s,e,share = strfind(user.sMyInfoString, "$(%d+)%$")
   if share ~= nil then
   share = format("%0.2f", ( share / (1024*1024*1024)))
   else
   share = 0
   end
   local hubshare = format("%0.2f",  ( frmHub:GetCurrentShareAmount() / (1024*1024*1024)))
   local ttshare = format("%0.2f", tonumber(Stat.share)/(1024*1024*1024))
   local tmp = LEVELSTOT["1"] + LEVELSTOT["0"]  --- total ops  (adding masters 2 ops)
   local tmp1 = (LEVELSTOT["2"] - LEVELS["2"]) if tmp1 < 0 then tmp1 = 0 end --- offline vips (total - online)
   local tmp2 = (LEVELSTOT["3"] - LEVELS["3"]) if tmp2 < 0 then tmp2 = 0 end --- offline regs (total - online)
   local tmp3 = LEVELS["1"] + LEVELS["0"] -- online ops (adding masters 2 the ops)
   user:SendData(Bot, "-=[?]=-----------------------------------------------------------------------------------------------=[?]=-")
   user:SendData(Bot, " <-----=[- "..frmHub:GetHubName().." ? v2004 -]=----->")
   user:SendData(Bot, "-=[?]=-----------------------------------------------------------------------------------------------=[?]=-")
   user:SendData(Bot, "      ? Comunidade Lusobrasileira de ?irect C?nnect - P2P ?")
   user:SendData(Bot, "      ? "..user.sName..", bem vindo ao servidor.")
   user:SendData(Bot, "      ? Seu endere?o IP: "..user.sIP.." - StatuS: "..(GetProfileName(user.iProfile) or "N?o registrado")..".")
   user:SendData(Bot, "      ? Voc? est? compartilhando: "..share.." GB. Limite minimo: "..frmHub:GetMinShare()/(1024).." GB.")
   user:SendData(Bot, "      ? Usu?rios Online no Hub: "..frmHub:GetUsersCount()..". Recorde: "..Stat.users..".")
   user:SendData(Bot, "      ? Operadores Online no Hub: "..tmp3..". ViPs: "..LEVELS["2"]..".")
   user:SendData(Bot, "      ? Total de Operadores registrados no Hub: "..tmp..". ViPs: "..LEVELSTOT["2"]..".")
   user:SendData(Bot, "      ? Usu?rios registrados, n?o conectados: "..tmp2..".")
   user:SendData(Bot, "      ? Compartilhamento atual no Hub: "..hubshare.." GB. Recorde: "..ttshare.." GB.")
   user:SendData(Bot, "      ? Logins no Hub: "..Stat.logins..".")
   user:SendData(Bot, "      ? Lista de comandos, regras, ajuda e informa??o: !ajuda")
   user:SendData(Bot, "      ? "..GetTime().."")
   user:SendData(Bot, "      ? Website - F?rum: [URL]www.lusobrasil.site.vu[/URL]")
   user:SendData(Bot, "-=[?]=-----------------------------------------------------------------------------------------------=[?]=-")
   user:SendData(Bot, "      ? Registros sem login no Hub por: 1 semana(s) ser?o auto-removidos. [- Perman?ncia de 5 min. -]")
   user:SendData(Bot, "-=[?]=-----------------------------------------------------------------------------------------------=[?]=-")
end
-------------------------------------------------------------------------------------------------------------------------------------------------
function GetTime()
s = date("%S")
h = date("%H")
m = date("%M")
d = date("%d")
mm = date("%m")
y = date("%y")
Date = "Hora local: "..h..":"..m..":"..s.." - "..d.."/"..mm.."/20"..y.."."
return Date
end
-------------------------------------------------------------------------------------------------------------------------------------------------
ALLUSERS={}

function NewUserConnected(user)
local s,e,usrshare = strfind(user.sMyInfoString, "%$%s*(%d+)%$")
if (readfrom(Stattxt) == nil) then
if (Stat.users < frmHub:GetUsersCount() ) then
Stat.users = frmHub:GetUsersCount()
else
end
if (Stat.share < frmHub:GetCurrentShareAmount() + usrshare) then
Stat.share = frmHub:GetCurrentShareAmount() + usrshare
end
Stat.logins = Stat.logins + 1
SaveToFile(Stattxt , Stat , "Stat")
else
LoadFromFile (Stattxt)
local logins = Stat["logins"]
local share = Stat["share"]
local users = Stat["users"]
if (users < frmHub:GetUsersCount() ) then
Stat.users = frmHub:GetUsersCount()
else
Stat.users = users
end
if (share < frmHub:GetCurrentShareAmount() + usrshare) then
Stat.share = frmHub:GetCurrentShareAmount() + usrshare
else
Stat.share = share
end
Stat.logins = logins + 1
SaveToFile(Stattxt , Stat , "Stat")
end

   if ALLUSERS[user.sName]==nil then
      ALLUSERS[user.sName]=1
      LEVELS[tostring(user.iProfile)]=LEVELS[tostring(user.iProfile)]+1
   end
   Message(user)
end
-------------------------------------------------------------------------------------------------------------------------------------------------
OpConnected = NewUserConnected

-------------------------------------------------------------------------------------------------------------------------------------------------
function DataArrival(user, data)
   if ALLUSERS[user.sName]==nil then
      ALLUSERS[user.sName]=1
      LEVELS[tostring(user.iProfile)]=LEVELS[tostring(user.iProfile)]+1
   end
   s,e,cmd= strfind(data, "%b<>%s+(%S+)")
   if cmd ~= nil and commands[cmd] then
      SetTimer(5 * 1000)
      StartTimer()
   end
end
-------------------------------------------------------------------------------------------------------------------------------------------------
function OnTimer()
   StopTimer()
   OpenRegisterdUsersFile()
end
-------------------------------------------------------------------------------------------------------------------------------------------------
function UserDisconnected(user)
   if ALLUSERS[user.sName] then
      ALLUSERS[user.sName]=nil
      if LEVELS[tostring(user.iProfile)] > 0 then
         LEVELS[tostring(user.iProfile)]=LEVELS[tostring(user.iProfile)]-1
      end
   end
end
-------------------------------------------------------------------------------------------------------------------------------------------------
function OpDisconnected(user)
   if ALLUSERS[user.sName] then
      ALLUSERS[user.sName]=nil
      if LEVELS[tostring(user.iProfile)] > 0 then
         LEVELS[tostring(user.iProfile)]=LEVELS[tostring(user.iProfile)]-1
      end
   end
end
-------------------------------------------------------------------------------------------------------------------------------------------------
function Main()
   frmHub:RegBot(Bot)
   OpenRegisterdUsersFile()
end
-------------------------------------------------------------------------------------------------------------------------------------------------
function OpenRegisterdUsersFile()
   readfrom("../RegisteredUsers.dat")
   for a,b in LEVELSTOT do
      LEVELSTOT[a]=0
   end
   while 1 do
      local line = read()
      local level
      if line == nil then
         readfrom()
         break
      end
      s,e,level = strfind(line,".+|.+|(.+)")
      if LEVELSTOT[level] then
         LEVELSTOT[level] = LEVELSTOT[level] +1
      end
   end  
end
-------------------------------------------------------------------------------------------------------------------------------------------------
function Serialize(tTable, sTableName, hFile, sTab)
assert(tTable, "tTable equals nil");
assert(sTableName, "sTableName equals nil");
assert(hFile, "hFile equals nil");

assert(type(tTable) == "table", "tTable must be a table!");
assert(type(sTableName) == "string", "sTableName must be a string!");

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

function SaveToFile(file , table , tablename)
local hFile = openfile(file, "w");
Serialize(table, tablename, hFile);
closefile(hFile);
end

function LoadFromFile (file)
assert(readfrom(file),"Making file, not to horry")
dostring(read("*all"))
readfrom()
end


PS: Plop, i still not tested that fix.. hope it will work.. i will run this one to check.. just waiting, for this little addy if is possible. and please.. could u take a little look if i put the fix correct ? :))

TkS All
Title:
Post by: nErBoS on 10 March, 2004, 05:35:35
Hi,

Hope it helps..

-----------------------------------------------------------------------------
-- online user counter by plop v:1.2
-- based on a bot by ....... witch showed basic hub info 2 users on entry
-- (fill in the name pls if you know who this was)
-----------------------------------------------------------------------------
-- LEVELSTOT[number] = total number of users with that level
-- LEVELS[number] = total online number of users with that level
-- commands = table of triggers used by the hub 2 add/delete users
-- add the script commands yourself if you use a script 2 add/delete users
-- same can be done if you have more user levels then default
-----------------------------------------------------------------------------
-- tables all over but i seem 2 have forgotten 2 add chairs. snif snif
-----------------------------------------------------------------------------
-- manual stuff
-----------------------------------------------------------------------------
-- LEVELSTOT["0"] -- total masters
-- LEVELSTOT["1"] -- total operators
-- LEVELSTOT["2"] -- total VIPs
-- LEVELSTOT["3"] -- total registred users
-- tmp -- total operators and masters
-- frmHub:GetUsersCount() -- total online users
----------
-- LEVELS["0"] -- total online masters
-- LEVELS["1"] -- total online operators
-- LEVELS["2"] -- total online VIPs
-- LEVELS["3"] -- total online registered users
-- LEVELS["-1"] -- total online unregistered users
-- tmp3 -- total operators and masters
----------
-- offline users
-- LEVELSTOT["0"] - LEVELS["0"] == offline operators
-- tmp1 -- total offline VIPs
-- tmp2 -- total offline registered users
-----------------------------------------------------------------------------
-- name of the bot
Bot = "[operserv]"

-- couter tables, if you have more levels add there numbers in BOTH tables,
-- except unreg users, those only work in the lower table
LEVELSTOT = {["0"]=0, ["1"]=0, ["2"]=0, ["3"]=0}
LEVELS = {["0"]=0, ["1"]=0, ["2"]=0, ["3"]=0, ["-1"]=0}

Stattxt = "txt/stat.txt" --Will be created in the script folder

Stat = {
logins = 0,
share = 0,
users = 0,
}

-- table holding the commands ptokax uses 2 add/delete users
-- add your bot's commands 2 this table if you use a bot 2 add/delete ppl
commands = {["!addreguser"]=1, ["!delreguser"]=1}
-------------------------------------------------------------------------------------------------------------------------------------------------
function Message(user)
   local s,e,share = strfind(user.sMyInfoString, "$(%d+)%$")
   local s,e,hubs,slots = strfind(user.sMyInfoString, "H:(%S+),S:(%d+)")
   if share ~= nil then
   share = format("%0.2f", ( share / (1024*1024*1024)))
   else
   share = 0
   end
   if (strfind(hubs, "%d+/") ~= nil) then
   local s,e,notreg,reg,opped = strfind(hubs, "(%d+)/(%d+)/(%d+)")
   hubs = notreg + reg + opped
   end
   local hubshare = format("%0.2f",  ( frmHub:GetCurrentShareAmount() / (1024*1024*1024)))
   local ttshare = format("%0.2f", tonumber(Stat.share)/(1024*1024*1024))
   local tmp = LEVELSTOT["1"] + LEVELSTOT["0"]  --- total ops  (adding masters 2 ops)
   local tmp1 = (LEVELSTOT["2"] - LEVELS["2"]) if tmp1 < 0 then tmp1 = 0 end --- offline vips (total - online)
   local tmp2 = (LEVELSTOT["3"] - LEVELS["3"]) if tmp2 < 0 then tmp2 = 0 end --- offline regs (total - online)
   local tmp3 = LEVELS["1"] + LEVELS["0"] -- online ops (adding masters 2 the ops)
   user:SendData(Bot, "-=[?]=-----------------------------------------------------------------------------------------------=[?]=-")
   user:SendData(Bot, " <-----=[- "..frmHub:GetHubName().." ? v2004 -]=----->")
   user:SendData(Bot, "-=[?]=-----------------------------------------------------------------------------------------------=[?]=-")
   user:SendData(Bot, "      ? Comunidade Lusobrasileira de ?irect C?nnect - P2P ?")
   user:SendData(Bot, "      ? "..user.sName..", bem vindo ao servidor.")
   user:SendData(Bot, "      ? Seu endere?o IP: "..user.sIP.." - StatuS: "..(GetProfileName(user.iProfile) or "N?o registrado")..".")
   user:SendData(Bot, "      ? Voc? est? compartilhando: "..share.." GB. Limite minimo: "..frmHub:GetMinShare()/(1024).." GB.")
   user:SendData(Bot, "      ? Usu?rios Online no Hub: "..frmHub:GetUsersCount()..". Recorde: "..Stat.users..".")
   user:SendData(Bot, "      ? Operadores Online no Hub: "..tmp3..". ViPs: "..LEVELS["2"]..".")
   user:SendData(Bot, "      ? Total de Operadores registrados no Hub: "..tmp..". ViPs: "..LEVELSTOT["2"]..".")
   user:SendData(Bot, "      ? Usu?rios registrados, n?o conectados: "..tmp2..".")
   user:SendData(Bot, "      ? Estas em "..hubs.." Hubs e com "..slots.." Slots.")
   user:SendData(Bot, "      ? Compartilhamento atual no Hub: "..hubshare.." GB. Recorde: "..ttshare.." GB.")
   user:SendData(Bot, "      ? Logins no Hub: "..Stat.logins..".")
   user:SendData(Bot, "      ? Lista de comandos, regras, ajuda e informa??o: !ajuda")
   user:SendData(Bot, "      ? "..GetTime().."")
   user:SendData(Bot, "      ? Website - F?rum: [URL]www.lusobrasil.site.vu[/URL]")
   user:SendData(Bot, "-=[?]=-----------------------------------------------------------------------------------------------=[?]=-")
   user:SendData(Bot, "      ? Registros sem login no Hub por: 1 semana(s) ser?o auto-removidos. [- Perman?ncia de 5 min. -]")
   user:SendData(Bot, "-=[?]=-----------------------------------------------------------------------------------------------=[?]=-")
end
-------------------------------------------------------------------------------------------------------------------------------------------------
function GetTime()
s = date("%S")
h = date("%H")
m = date("%M")
d = date("%d")
mm = date("%m")
y = date("%y")
Date = "Hora local: "..h..":"..m..":"..s.." - "..d.."/"..mm.."/20"..y.."."
return Date
end
-------------------------------------------------------------------------------------------------------------------------------------------------
ALLUSERS={}

function NewUserConnected(user)
local s,e,usrshare = strfind(user.sMyInfoString, "%$%s*(%d+)%$")
if (readfrom(Stattxt) == nil) then
if (Stat.users < frmHub:GetUsersCount() ) then
Stat.users = frmHub:GetUsersCount()
else
end
if (Stat.share < frmHub:GetCurrentShareAmount() + usrshare) then
Stat.share = frmHub:GetCurrentShareAmount() + usrshare
end
Stat.logins = Stat.logins + 1
SaveToFile(Stattxt , Stat , "Stat")
else
LoadFromFile (Stattxt)
local logins = Stat["logins"]
local share = Stat["share"]
local users = Stat["users"]
if (users < frmHub:GetUsersCount() ) then
Stat.users = frmHub:GetUsersCount()
else
Stat.users = users
end
if (share < frmHub:GetCurrentShareAmount() + usrshare) then
Stat.share = frmHub:GetCurrentShareAmount() + usrshare
else
Stat.share = share
end
Stat.logins = logins + 1
SaveToFile(Stattxt , Stat , "Stat")
end

   if ALLUSERS[user.sName]==nil then
      ALLUSERS[user.sName]=1
      LEVELS[tostring(user.iProfile)]=LEVELS[tostring(user.iProfile)]+1
   end
   Message(user)
end
-------------------------------------------------------------------------------------------------------------------------------------------------
OpConnected = NewUserConnected

-------------------------------------------------------------------------------------------------------------------------------------------------
function DataArrival(user, data)
   if ALLUSERS[user.sName]==nil then
      ALLUSERS[user.sName]=1
      LEVELS[tostring(user.iProfile)]=LEVELS[tostring(user.iProfile)]+1
   end
   s,e,cmd= strfind(data, "%b<>%s+(%S+)")
   if cmd ~= nil and commands[cmd] then
      SetTimer(5 * 1000)
      StartTimer()
   end
end
-------------------------------------------------------------------------------------------------------------------------------------------------
function OnTimer()
   StopTimer()
   OpenRegisterdUsersFile()
end
-------------------------------------------------------------------------------------------------------------------------------------------------
function UserDisconnected(user)
   if ALLUSERS[user.sName] then
      ALLUSERS[user.sName]=nil
      if LEVELS[tostring(user.iProfile)] > 0 then
         LEVELS[tostring(user.iProfile)]=LEVELS[tostring(user.iProfile)]-1
      end
   end
end
-------------------------------------------------------------------------------------------------------------------------------------------------
function OpDisconnected(user)
   if ALLUSERS[user.sName] then
      ALLUSERS[user.sName]=nil
      if LEVELS[tostring(user.iProfile)] > 0 then
         LEVELS[tostring(user.iProfile)]=LEVELS[tostring(user.iProfile)]-1
      end
   end
end
-------------------------------------------------------------------------------------------------------------------------------------------------
function Main()
   frmHub:RegBot(Bot)
   OpenRegisterdUsersFile()
end
-------------------------------------------------------------------------------------------------------------------------------------------------
function OpenRegisterdUsersFile()
   readfrom("../RegisteredUsers.dat")
   for a,b in LEVELSTOT do
      LEVELSTOT[a]=0
   end
   while 1 do
      local line = read()
      local level
      if line == nil then
         readfrom()
         break
      end
      s,e,level = strfind(line,".+|.+|(.+)")
      if LEVELSTOT[level] then
         LEVELSTOT[level] = LEVELSTOT[level] +1
      end
   end  
end
-------------------------------------------------------------------------------------------------------------------------------------------------
function Serialize(tTable, sTableName, hFile, sTab)
assert(tTable, "tTable equals nil");
assert(sTableName, "sTableName equals nil");
assert(hFile, "hFile equals nil");

assert(type(tTable) == "table", "tTable must be a table!");
assert(type(sTableName) == "string", "sTableName must be a string!");

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

function SaveToFile(file , table , tablename)
local hFile = openfile(file, "w");
Serialize(table, tablename, hFile);
closefile(hFile);
end

function LoadFromFile (file)
assert(readfrom(file),"Making file, not to horry")
dostring(read("*all"))
readfrom()
end

Best regards, nErBoS
Title:
Post by: nEgativE on 10 March, 2004, 05:46:24
Maravilha :) Thank U.
Title:
Post by: nEgativE on 12 March, 2004, 06:16:06
Plop :( i have less erros, but still keep getting some, strange :\

Syntax error: bad argument #1 to `strfind' (string expected, got nil)
stack traceback:
   1:  function `strfind' [C]
   2:  function `Message' at line 63 [file `...\ptokax\scripts\onjoin.lua']
   3:  function `NewUserConnected' at line 143 [file `...\ptokax\scripts\onjoin.lua']



-----------------------------------------------------------------------------
-- online user counter by plop v:1.2
-- based on a bot by ....... witch showed basic hub info 2 users on entry
-- (fill in the name pls if you know who this was)
-----------------------------------------------------------------------------
-- LEVELSTOT[number] = total number of users with that level
-- LEVELS[number] = total online number of users with that level
-- commands = table of triggers used by the hub 2 add/delete users
-- add the script commands yourself if you use a script 2 add/delete users
-- same can be done if you have more user levels then default
-----------------------------------------------------------------------------
-- tables all over but i seem 2 have forgotten 2 add chairs. snif snif
-----------------------------------------------------------------------------
-- manual stuff
-----------------------------------------------------------------------------
-- LEVELSTOT["0"] -- total masters
-- LEVELSTOT["1"] -- total operators
-- LEVELSTOT["2"] -- total VIPs
-- LEVELSTOT["3"] -- total registred users
-- tmp -- total operators and masters
-- frmHub:GetUsersCount() -- total online users
----------
-- LEVELS["0"] -- total online masters
-- LEVELS["1"] -- total online operators
-- LEVELS["2"] -- total online VIPs
-- LEVELS["3"] -- total online registered users
-- LEVELS["-1"] -- total online unregistered users
-- tmp3 -- total operators and masters
----------
-- offline users
-- LEVELSTOT["0"] - LEVELS["0"] == offline operators
-- tmp1 -- total offline VIPs
-- tmp2 -- total offline registered users
-----------------------------------------------------------------------------
-- name of the bot
Bot = "[operserv]"

-- couter tables, if you have more levels add there numbers in BOTH tables,
-- except unreg users, those only work in the lower table
LEVELSTOT = {["0"]=0, ["1"]=0, ["2"]=0, ["3"]=0}
LEVELS = {["0"]=0, ["1"]=0, ["2"]=0, ["3"]=0, ["-1"]=0}

Stattxt = "txt/stat.txt" --Will be created in the script folder

Stat = {
logins = 0,
share = 0,
users = 0,
}

-- table holding the commands ptokax uses 2 add/delete users
-- add your bot's commands 2 this table if you use a bot 2 add/delete ppl
commands = {["!addreguser"]=1, ["!delreguser"]=1}
-------------------------------------------------------------------------------------------------------------------------------------------------
function Message(user)
   local s,e,share = strfind(user.sMyInfoString, "$(%d+)%$")
   local s,e,hubs,slots = strfind(user.sMyInfoString, "H:(%S+),S:(%d+)")
   if share ~= nil then
   share = format("%0.2f", ( share / (1024*1024*1024)))
   else
   share = 0
   end
   if (strfind(hubs, "%d+/") ~= nil) then
   local s,e,notreg,reg,opped = strfind(hubs, "(%d+)/(%d+)/(%d+)")
   hubs = notreg + reg + opped
   end
   local hubshare = format("%0.2f",  ( frmHub:GetCurrentShareAmount() / (1024*1024*1024)))
   local ttshare = format("%0.2f", tonumber(Stat.share)/(1024*1024*1024))
   local tmp = LEVELSTOT["1"] + LEVELSTOT["0"]  --- total ops  (adding masters 2 ops)
   local tmp1 = (LEVELSTOT["2"] - LEVELS["2"]) if tmp1 < 0 then tmp1 = 0 end --- offline vips (total - online)
   local tmp2 = (LEVELSTOT["3"] - LEVELS["3"]) if tmp2 < 0 then tmp2 = 0 end --- offline regs (total - online)
   local tmp3 = LEVELS["1"] + LEVELS["0"] -- online ops (adding masters 2 the ops)
   user:SendData(Bot, "-=[?]=-----------------------------------------------------------------------------------------------=[?]=-")
   user:SendData(Bot, " <-----=[- "..frmHub:GetHubName().." ? v2004 -]=----->")
   user:SendData(Bot, "-=[?]=-----------------------------------------------------------------------------------------------=[?]=-")
   user:SendData(Bot, "      ? Comunidade Lusobrasileira de ?irect C?nnect - P2P ?")
   user:SendData(Bot, "      ? "..user.sName..", bem vindo ao servidor.")
   user:SendData(Bot, "      ? Seu endere?o IP: "..user.sIP.." - StatuS: "..(GetProfileName(user.iProfile) or "N?o registrado")..".")
   user:SendData(Bot, "      ? Voc? est? compartilhando: "..share.." GB. Limite minimo: "..frmHub:GetMinShare()/(1024).." GB.")
   user:SendData(Bot, "      ? Voc? est? conectado em: "..hubs.." Hub(s) e tem: "..slots.." Slot(s) liberado(s).")
   user:SendData(Bot, "      ? Usu?rios Online no Hub: "..frmHub:GetUsersCount()..". Recorde: "..Stat.users..".")
   user:SendData(Bot, "      ? Operadores Online no Hub: "..tmp3..". ViPs: "..LEVELS["2"]..".")
   user:SendData(Bot, "      ? Total de Operadores registrados no Hub: "..tmp..". ViPs: "..LEVELSTOT["2"]..".")
   user:SendData(Bot, "      ? Usu?rios registrados, n?o conectados: "..tmp2..".")
   user:SendData(Bot, "      ? Compartilhamento atual no Hub: "..hubshare.." GB. Recorde: "..ttshare.." GB.")
   user:SendData(Bot, "      ? Logins no Hub: "..Stat.logins..".")
   user:SendData(Bot, "      ? Lista de comandos, regras, ajuda e informa??o: !ajuda")
   user:SendData(Bot, "      ? "..GetTime().."")
   user:SendData(Bot, "      ? Website - F?rum: [URL]www.lusobrasil.site.vu[/URL]")
   user:SendData(Bot, "-=[?]=-----------------------------------------------------------------------------------------------=[?]=-")
   user:SendData(Bot, "      ? Registros sem login no Hub por: 1 semana(s) ser?o auto-removidos. [- Perman?ncia de 5 min. -]")
   user:SendData(Bot, "-=[?]=-----------------------------------------------------------------------------------------------=[?]=-")
end
-------------------------------------------------------------------------------------------------------------------------------------------------
function GetTime()
s = date("%S")
h = date("%H")
m = date("%M")
d = date("%d")
mm = date("%m")
y = date("%y")
Date = "Hora local: "..h..":"..m..":"..s.." - "..d.."/"..mm.."/20"..y.."."
return Date
end
-------------------------------------------------------------------------------------------------------------------------------------------------
ALLUSERS={}

function NewUserConnected(user)
local s,e,usrshare = strfind(user.sMyInfoString, "%$%s*(%d+)%$")
if (readfrom(Stattxt) == nil) then
if (Stat.users < frmHub:GetUsersCount() ) then
Stat.users = frmHub:GetUsersCount()
else
end
if (Stat.share < frmHub:GetCurrentShareAmount() + usrshare) then
Stat.share = frmHub:GetCurrentShareAmount() + usrshare
end
Stat.logins = Stat.logins + 1
SaveToFile(Stattxt , Stat , "Stat")
else
LoadFromFile (Stattxt)
local logins = Stat["logins"]
local share = Stat["share"]
local users = Stat["users"]
if (users < frmHub:GetUsersCount() ) then
Stat.users = frmHub:GetUsersCount()
else
Stat.users = users
end
if (share < frmHub:GetCurrentShareAmount() + usrshare) then
Stat.share = frmHub:GetCurrentShareAmount() + usrshare
else
Stat.share = share
end
Stat.logins = logins + 1
SaveToFile(Stattxt , Stat , "Stat")
end

   if ALLUSERS[user.sName]==nil then
      ALLUSERS[user.sName]=1
      LEVELS[tostring(user.iProfile)]=LEVELS[tostring(user.iProfile)]+1
   end
   Message(user)
end
-------------------------------------------------------------------------------------------------------------------------------------------------
OpConnected = NewUserConnected

-------------------------------------------------------------------------------------------------------------------------------------------------
function DataArrival(user, data)
   if ALLUSERS[user.sName]==nil then
      ALLUSERS[user.sName]=1
      LEVELS[tostring(user.iProfile)]=LEVELS[tostring(user.iProfile)]+1
   end
   s,e,cmd= strfind(data, "%b<>%s+(%S+)")
   if cmd ~= nil and commands[cmd] then
      SetTimer(5 * 1000)
      StartTimer()
   end
end
-------------------------------------------------------------------------------------------------------------------------------------------------
function OnTimer()
   StopTimer()
   OpenRegisterdUsersFile()
end
-------------------------------------------------------------------------------------------------------------------------------------------------
function UserDisconnected(user)
   if ALLUSERS[user.sName] then
      ALLUSERS[user.sName]=nil
      if LEVELS[tostring(user.iProfile)] > 0 then
         LEVELS[tostring(user.iProfile)]=LEVELS[tostring(user.iProfile)]-1
      end
   end
end
-------------------------------------------------------------------------------------------------------------------------------------------------
function OpDisconnected(user)
   if ALLUSERS[user.sName] then
      ALLUSERS[user.sName]=nil
      if LEVELS[tostring(user.iProfile)] > 0 then
         LEVELS[tostring(user.iProfile)]=LEVELS[tostring(user.iProfile)]-1
      end
   end
end
-------------------------------------------------------------------------------------------------------------------------------------------------
function Main()
   frmHub:RegBot(Bot)
   OpenRegisterdUsersFile()
end
-------------------------------------------------------------------------------------------------------------------------------------------------
function OpenRegisterdUsersFile()
   readfrom("../RegisteredUsers.dat")
   for a,b in LEVELSTOT do
      LEVELSTOT[a]=0
   end
   while 1 do
      local line = read()
      local level
      if line == nil then
         readfrom()
         break
      end
      s,e,level = strfind(line,".+|.+|(.+)")
      if LEVELSTOT[level] then
         LEVELSTOT[level] = LEVELSTOT[level] +1
      end
   end  
end
-------------------------------------------------------------------------------------------------------------------------------------------------
function Serialize(tTable, sTableName, hFile, sTab)
assert(tTable, "tTable equals nil");
assert(sTableName, "sTableName equals nil");
assert(hFile, "hFile equals nil");

assert(type(tTable) == "table", "tTable must be a table!");
assert(type(sTableName) == "string", "sTableName must be a string!");

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

function SaveToFile(file , table , tablename)
local hFile = openfile(file, "w");
Serialize(table, tablename, hFile);
closefile(hFile);
end

function LoadFromFile (file)
assert(readfrom(file),"Making file, not to horry")
dostring(read("*all"))
readfrom()
end
Title:
Post by: [NL]trucker on 12 March, 2004, 08:28:16
Luso

try this script i have it running now for about a week and i sure like it.

http://board.univ-angers.fr/thread.php?threadid=1435&boardid=13&styleid=1&sid=579bd8b13817711a69f077accfb1883c
Title:
Post by: nEgativE on 18 March, 2004, 08:11:09
[NL]trucker, heh, i'll give it a try later :) but i do like this one a lot.. =)

nErBoS, one more request, is it possible to include something like Modes and Client ?

   user:SendData(Bot, "         ? Voc? est? usando "..dc.." e est? em modo "..mode..".")

if it's possible, could somehow get erros about those fakers without TAGs or messed up.. ?

Thanks :)

Plop, i still get some erros about that 'strfind :( strange, but i will live with that, i really like the script.
Title:
Post by: nErBoS on 18 March, 2004, 13:43:53
Hi,

Luso that error was my fault, fixed and with your request..

-----------------------------------------------------------------------------
-- online user counter by plop v:1.2
-- based on a bot by ....... witch showed basic hub info 2 users on entry
-- (fill in the name pls if you know who this was)
-----------------------------------------------------------------------------
-- LEVELSTOT[number] = total number of users with that level
-- LEVELS[number] = total online number of users with that level
-- commands = table of triggers used by the hub 2 add/delete users
-- add the script commands yourself if you use a script 2 add/delete users
-- same can be done if you have more user levels then default
-----------------------------------------------------------------------------
-- tables all over but i seem 2 have forgotten 2 add chairs. snif snif
-----------------------------------------------------------------------------
-- manual stuff
-----------------------------------------------------------------------------
-- LEVELSTOT["0"] -- total masters
-- LEVELSTOT["1"] -- total operators
-- LEVELSTOT["2"] -- total VIPs
-- LEVELSTOT["3"] -- total registred users
-- tmp -- total operators and masters
-- frmHub:GetUsersCount() -- total online users
----------
-- LEVELS["0"] -- total online masters
-- LEVELS["1"] -- total online operators
-- LEVELS["2"] -- total online VIPs
-- LEVELS["3"] -- total online registered users
-- LEVELS["-1"] -- total online unregistered users
-- tmp3 -- total operators and masters
----------
-- offline users
-- LEVELSTOT["0"] - LEVELS["0"] == offline operators
-- tmp1 -- total offline VIPs
-- tmp2 -- total offline registered users
-----------------------------------------------------------------------------
-- name of the bot
Bot = "[operserv]"

-- couter tables, if you have more levels add there numbers in BOTH tables,
-- except unreg users, those only work in the lower table
LEVELSTOT = {["0"]=0, ["1"]=0, ["2"]=0, ["3"]=0}
LEVELS = {["0"]=0, ["1"]=0, ["2"]=0, ["3"]=0, ["-1"]=0}

Stattxt = "txt/stat.txt" --Will be created in the script folder

Stat = {
logins = 0,
share = 0,
users = 0,
}

-- table holding the commands ptokax uses 2 add/delete users
-- add your bot's commands 2 this table if you use a bot 2 add/delete ppl
commands = {["!addreguser"]=1, ["!delreguser"]=1}
-------------------------------------------------------------------------------------------------------------------------------------------------
function Message(user)
   local s,e,share = strfind(user.sMyInfoString, "$(%d+)%$")
   local s,e,hubs,slots = strfind(user.sMyInfoString, "H:(%S+),S:(%d+)")
   if share ~= nil then
   share = format("%0.2f", ( share / (1024*1024*1024)))
   else
   share = 0
   end
   if (hubs == nil and slots == nil) then
hubs = "SEM TAG"
slots = hubs
   elseif (strfind(hubs, "%d+/") ~= nil) then
   local s,e,notreg,reg,opped = strfind(hubs, "(%d+)/(%d+)/(%d+)")
   hubs = notreg + reg + opped
   end
   local hubshare = format("%0.2f",  ( frmHub:GetCurrentShareAmount() / (1024*1024*1024)))
   local ttshare = format("%0.2f", tonumber(Stat.share)/(1024*1024*1024))
   local tmp = LEVELSTOT["1"] + LEVELSTOT["0"]  --- total ops  (adding masters 2 ops)
   local tmp1 = (LEVELSTOT["2"] - LEVELS["2"]) if tmp1 < 0 then tmp1 = 0 end --- offline vips (total - online)
   local tmp2 = (LEVELSTOT["3"] - LEVELS["3"]) if tmp2 < 0 then tmp2 = 0 end --- offline regs (total - online)
   local tmp3 = LEVELS["1"] + LEVELS["0"] -- online ops (adding masters 2 the ops)
   user:SendData(Bot, "-=[?]=-----------------------------------------------------------------------------------------------=[?]=-")
   user:SendData(Bot, " <-----=[- "..frmHub:GetHubName().." ? v2004 -]=----->")
   user:SendData(Bot, "-=[?]=-----------------------------------------------------------------------------------------------=[?]=-")
   user:SendData(Bot, "      ? Comunidade Lusobrasileira de ?irect C?nnect - P2P ?")
   user:SendData(Bot, "      ? "..user.sName..", bem vindo ao servidor.")
   user:SendData(Bot, "      ? Seu endere?o IP: "..user.sIP.." - StatuS: "..(GetProfileName(user.iProfile) or "N?o registrado")..".")
   user:SendData(Bot, "      ? Voc? est? compartilhando: "..share.." GB. Limite minimo: "..frmHub:GetMinShare()/(1024).." GB.")
   user:SendData(Bot, "      ? Voc? est? conectado em: "..hubs.." Hub(s) e tem: "..slots.." Slot(s) liberado(s).")
   user:SendData(Bot, "      ? Voc? est? usando "..VersionChecker(user).." e est? em modo "..ModeChecker(user)..".")
   user:SendData(Bot, "      ? Usu?rios Online no Hub: "..frmHub:GetUsersCount()..". Recorde: "..Stat.users..".")
   user:SendData(Bot, "      ? Operadores Online no Hub: "..tmp3..". ViPs: "..LEVELS["2"]..".")
   user:SendData(Bot, "      ? Total de Operadores registrados no Hub: "..tmp..". ViPs: "..LEVELSTOT["2"]..".")
   user:SendData(Bot, "      ? Usu?rios registrados, n?o conectados: "..tmp2..".")
   user:SendData(Bot, "      ? Compartilhamento atual no Hub: "..hubshare.." GB. Recorde: "..ttshare.." GB.")
   user:SendData(Bot, "      ? Logins no Hub: "..Stat.logins..".")
   user:SendData(Bot, "      ? Lista de comandos, regras, ajuda e informa??o: !ajuda")
   user:SendData(Bot, "      ? "..GetTime().."")
   user:SendData(Bot, "      ? Website - F?rum: [URL]www.lusobrasil.site.vu[/URL]")
   user:SendData(Bot, "-=[?]=-----------------------------------------------------------------------------------------------=[?]=-")
   user:SendData(Bot, "      ? Registros sem login no Hub por: 1 semana(s) ser?o auto-removidos. [- Perman?ncia de 5 min. -]")
   user:SendData(Bot, "-=[?]=-----------------------------------------------------------------------------------------------=[?]=-")
end
-------------------------------------------------------------------------------------------------------------------------------------------------
function GetTime()
s = date("%S")
h = date("%H")
m = date("%M")
d = date("%d")
mm = date("%m")
y = date("%y")
Date = "Hora local: "..h..":"..m..":"..s.." - "..d.."/"..mm.."/20"..y.."."
return Date
end
-------------------------------------------------------------------------------------------------------------------------------------------------
ALLUSERS={}

function NewUserConnected(user)
local s,e,usrshare = strfind(user.sMyInfoString, "%$%s*(%d+)%$")
if (readfrom(Stattxt) == nil) then
if (Stat.users < frmHub:GetUsersCount() ) then
Stat.users = frmHub:GetUsersCount()
else
end
if (Stat.share < frmHub:GetCurrentShareAmount() + usrshare) then
Stat.share = frmHub:GetCurrentShareAmount() + usrshare
end
Stat.logins = Stat.logins + 1
SaveToFile(Stattxt , Stat , "Stat")
else
LoadFromFile (Stattxt)
local logins = Stat["logins"]
local share = Stat["share"]
local users = Stat["users"]
if (users < frmHub:GetUsersCount() ) then
Stat.users = frmHub:GetUsersCount()
else
Stat.users = users
end
if (share < frmHub:GetCurrentShareAmount() + usrshare) then
Stat.share = frmHub:GetCurrentShareAmount() + usrshare
else
Stat.share = share
end
Stat.logins = logins + 1
SaveToFile(Stattxt , Stat , "Stat")
end

   if ALLUSERS[user.sName]==nil then
      ALLUSERS[user.sName]=1
      LEVELS[tostring(user.iProfile)]=LEVELS[tostring(user.iProfile)]+1
   end
   if (VersionChecker(user) == "Cliente sem TAG ou cliente desconhecido.") then
SendPmToOps(Bot, "O utilizador "..user.sName.." est? com um cliente sem TAG ou cliente desconhecido.")
   end
   Message(user)
end
-------------------------------------------------------------------------------------------------------------------------------------------------
OpConnected = NewUserConnected

-------------------------------------------------------------------------------------------------------------------------------------------------
function DataArrival(user, data)
   if ALLUSERS[user.sName]==nil then
      ALLUSERS[user.sName]=1
      LEVELS[tostring(user.iProfile)]=LEVELS[tostring(user.iProfile)]+1
   end
   s,e,cmd= strfind(data, "%b<>%s+(%S+)")
   if cmd ~= nil and commands[cmd] then
      SetTimer(5 * 1000)
      StartTimer()
   end
end
-------------------------------------------------------------------------------------------------------------------------------------------------
function OnTimer()
   StopTimer()
   OpenRegisterdUsersFile()
end
-------------------------------------------------------------------------------------------------------------------------------------------------
function UserDisconnected(user)
   if ALLUSERS[user.sName] then
      ALLUSERS[user.sName]=nil
      if LEVELS[tostring(user.iProfile)] > 0 then
         LEVELS[tostring(user.iProfile)]=LEVELS[tostring(user.iProfile)]-1
      end
   end
end
-------------------------------------------------------------------------------------------------------------------------------------------------
function OpDisconnected(user)
   if ALLUSERS[user.sName] then
      ALLUSERS[user.sName]=nil
      if LEVELS[tostring(user.iProfile)] > 0 then
         LEVELS[tostring(user.iProfile)]=LEVELS[tostring(user.iProfile)]-1
      end
   end
end
-------------------------------------------------------------------------------------------------------------------------------------------------
function Main()
   frmHub:RegBot(Bot)
   OpenRegisterdUsersFile()
end
-------------------------------------------------------------------------------------------------------------------------------------------------
function OpenRegisterdUsersFile()
   readfrom("../RegisteredUsers.dat")
   for a,b in LEVELSTOT do
      LEVELSTOT[a]=0
   end
   while 1 do
      local line = read()
      local level
      if line == nil then
         readfrom()
         break
      end
      s,e,level = strfind(line,".+|.+|(.+)")
      if LEVELSTOT[level] then
         LEVELSTOT[level] = LEVELSTOT[level] +1
      end
   end  
end
-------------------------------------------------------------------------------------------------------------------------------------------------
function Serialize(tTable, sTableName, hFile, sTab)
assert(tTable, "tTable equals nil");
assert(sTableName, "sTableName equals nil");
assert(hFile, "hFile equals nil");

assert(type(tTable) == "table", "tTable must be a table!");
assert(type(sTableName) == "string", "sTableName must be a string!");

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

function SaveToFile(file , table , tablename)
local hFile = openfile(file, "w");
Serialize(table, tablename, hFile);
closefile(hFile);
end

function LoadFromFile (file)
assert(readfrom(file),"Making file, not to horry")
dostring(read("*all"))
readfrom()
end

function VersionChecker(user)
local tmp = ""
if (strfind(user.sMyInfoString, " tmp = "oDc"
elseif (strfind(user.sMyInfoString," tmp = "DCGUI"
elseif strfind(user.sMyInfoString," tmp = "DCPRO"
elseif strfind(user.sMyInfoString,"L:") or strfind(user.sMyInfoString,"B:") then
tmp = "BCDC++"
elseif (strfind(user.sMyInfoString, "<+")) then
tmp = "DC++"
else
tmp = "Cliente sem TAG ou cliente desconhecido."
end
return tmp
end

function ModeChecker(user)
local tmp = ""
if (strfind(user.sMyInfoString, "M:P")) then
tmp = "Passivo"
else
tmp = "Activo"
end
return tmp
end

Best regards, nErBoS
Title:
Post by: nEgativE on 23 March, 2004, 08:11:08
Nice. Thank U nErBoS :)

About those 'strfind erros, if i restart the script manualy, then * plouf * i'll get all erros about strfind.. Heh. weired thing !!
Title: Translation request
Post by: [G-T-E]Gate? on 23 March, 2004, 08:48:13
HI ,
Been following the progress on the script below and seems great , any chance on getting the Spanish(?) translated back to english?  Tks

code:-------------------------------------------------------------------------------------------------------------------------------------------------------------
-- online user counter by plop v:1.2
-- based on a bot by ....... witch showed basic hub info 2 users on entry
-- (fill in the name pls if you know who this was)
-----------------------------------------------------------------------------
-- LEVELSTOT[number] = total number of users with that level
-- LEVELS[number] = total online number of users with that level
-- commands = table of triggers used by the hub 2 add/delete users
-- add the script commands yourself if you use a script 2 add/delete users
-- same can be done if you have more user levels then default
-----------------------------------------------------------------------------
-- tables all over but i seem 2 have forgotten 2 add chairs. snif snif
-----------------------------------------------------------------------------
-- manual stuff
-----------------------------------------------------------------------------
-- LEVELSTOT["0"] -- total masters
-- LEVELSTOT["1"] -- total operators
-- LEVELSTOT["2"] -- total VIPs
-- LEVELSTOT["3"] -- total registred users
-- tmp -- total operators and masters
-- frmHub:GetUsersCount() -- total online users
----------
-- LEVELS["0"] -- total online masters
-- LEVELS["1"] -- total online operators
-- LEVELS["2"] -- total online VIPs
-- LEVELS["3"] -- total online registered users
-- LEVELS["-1"] -- total online unregistered users
-- tmp3 -- total operators and masters
----------
-- offline users
-- LEVELSTOT["0"] - LEVELS["0"] == offline operators
-- tmp1 -- total offline VIPs
-- tmp2 -- total offline registered users
-----------------------------------------------------------------------------
-- name of the bot
Bot = "[operserv]"

-- couter tables, if you have more levels add there numbers in BOTH tables,
-- except unreg users, those only work in the lower table
LEVELSTOT = {["0"]=0, ["1"]=0, ["2"]=0, ["3"]=0}
LEVELS = {["0"]=0, ["1"]=0, ["2"]=0, ["3"]=0, ["-1"]=0}

Stattxt = "txt/stat.txt" --Will be created in the script folder

Stat = {
   logins = 0,
   share = 0,
   users = 0,
}

-- table holding the commands ptokax uses 2 add/delete users
-- add your bot's commands 2 this table if you use a bot 2 add/delete ppl
commands = {["!addreguser"]=1, ["!delreguser"]=1}
-------------------------------------------------------------------------------------------------------------------------------------------------
function Message(user)
   local s,e,share = strfind(user.sMyInfoString, "$(%d+)%$")
   local s,e,hubs,slots = strfind(user.sMyInfoString, "H:(%S+),S:(%d+)")
   if share ~= nil then
   share = format("%0.2f", ( share / (1024*1024*1024)))
   else
   share = 0
   end
   if (hubs == nil and slots == nil) then
   hubs = "SEM TAG"
   slots = hubs
   elseif (strfind(hubs, "%d+/") ~= nil) then
   local s,e,notreg,reg,opped = strfind(hubs, "(%d+)/(%d+)/(%d+)")
   hubs = notreg + reg + opped
   end
   local hubshare = format("%0.2f",  ( frmHub:GetCurrentShareAmount() / (1024*1024*1024)))
   local ttshare = format("%0.2f", tonumber(Stat.share)/(1024*1024*1024))
   local tmp = LEVELSTOT["1"] + LEVELSTOT["0"]  --- total ops  (adding masters 2 ops)
   local tmp1 = (LEVELSTOT["2"] - LEVELS["2"]) if tmp1 < 0 then tmp1 = 0 end --- offline vips (total - online)
   local tmp2 = (LEVELSTOT["3"] - LEVELS["3"]) if tmp2 < 0 then tmp2 = 0 end --- offline regs (total - online)
   local tmp3 = LEVELS["1"] + LEVELS["0"] -- online ops (adding masters 2 the ops)
   user:SendData(Bot, "-=[?]=-----------------------------------------------------------------------------------------------=[?]=-")
   user:SendData(Bot, "      <-----=[- "..frmHub:GetHubName().." ? v2004 -]=----->")
   user:SendData(Bot, "-=[?]=-----------------------------------------------------------------------------------------------=[?]=-")
   user:SendData(Bot, "         ? Comunidade Lusobrasileira de ?irect C?nnect - P2P ?")
   user:SendData(Bot, "         ? "..user.sName..", bem vindo ao servidor.")
   user:SendData(Bot, "         ? Seu endere?o IP: "..user.sIP.." - StatuS: "..(GetProfileName(user.iProfile) or "N?o registrado")..".")
   user:SendData(Bot, "         ? Voc? est? compartilhando: "..share.." GB. Limite minimo: "..frmHub:GetMinShare()/(1024).." GB.")
   user:SendData(Bot, "         ? Voc? est? conectado em: "..hubs.." Hub(s) e tem: "..slots.." Slot(s) liberado(s).")
   user:SendData(Bot, "         ? Voc? est? usando "..VersionChecker(user).." e est? em modo "..ModeChecker(user)..".")
   user:SendData(Bot, "         ? Usu?rios Online no Hub: "..frmHub:GetUsersCount()..". Recorde: "..Stat.users..".")
   user:SendData(Bot, "         ? Operadores Online no Hub: "..tmp3..". ViPs: "..LEVELS["2"]..".")
   user:SendData(Bot, "         ? Total de Operadores registrados no Hub: "..tmp..". ViPs: "..LEVELSTOT["2"]..".")
   user:SendData(Bot, "         ? Usu?rios registrados, n?o conectados: "..tmp2..".")
   user:SendData(Bot, "         ? Compartilhamento atual no Hub: "..hubshare.." GB. Recorde: "..ttshare.." GB.")
   user:SendData(Bot, "         ? Logins no Hub: "..Stat.logins..".")
   user:SendData(Bot, "         ? Lista de comandos, regras, ajuda e informa??o: !ajuda")
   user:SendData(Bot, "         ? "..GetTime().."")
   user:SendData(Bot, "         ? Website - F?rum: //www.lusobrasil.site.vu")
   user:SendData(Bot, "-=[?]=-----------------------------------------------------------------------------------------------=[?]=-")
   user:SendData(Bot, "         ? Registros sem login no Hub por: 1 semana(s) ser?o auto-removidos. [- Perman?ncia de 5 min. -]")
   user:SendData(Bot, "-=[?]=-----------------------------------------------------------------------------------------------=[?]=-")
end
-------------------------------------------------------------------------------------------------------------------------------------------------
function GetTime()
   s = date("%S")
   h = date("%H")
   m = date("%M")
   d = date("%d")
   mm = date("%m")
   y = date("%y")
   Date = "Hora local: "..h..":"..m..":"..s.." - "..d.."/"..mm.."/20"..y.."."
   return Date
end
-------------------------------------------------------------------------------------------------------------------------------------------------
ALLUSERS={}

function NewUserConnected(user)
   local s,e,usrshare = strfind(user.sMyInfoString, "%$%s*(%d+)%$")
   if (readfrom(Stattxt) == nil) then
      if (Stat.users < frmHub:GetUsersCount() ) then
         Stat.users = frmHub:GetUsersCount()
      else
      end
      if (Stat.share < frmHub:GetCurrentShareAmount() + usrshare) then
         Stat.share = frmHub:GetCurrentShareAmount() + usrshare
      end
      Stat.logins = Stat.logins + 1
      SaveToFile(Stattxt , Stat , "Stat")
   else
      LoadFromFile (Stattxt)
      local logins = Stat["logins"]
      local share = Stat["share"]
      local users = Stat["users"]
      if (users < frmHub:GetUsersCount() ) then
         Stat.users = frmHub:GetUsersCount()
      else
         Stat.users = users
      end
      if (share < frmHub:GetCurrentShareAmount() + usrshare) then
         Stat.share = frmHub:GetCurrentShareAmount() + usrshare
      else
         Stat.share = share
      end
      Stat.logins = logins + 1
      SaveToFile(Stattxt , Stat , "Stat")
   end

   if ALLUSERS[user.sName]==nil then
      ALLUSERS[user.sName]=1
      LEVELS[tostring(user.iProfile)]=LEVELS[tostring(user.iProfile)]+1
   end
   if (VersionChecker(user) == "Cliente sem TAG ou cliente desconhecido.") then
   SendPmToOps(Bot, "O utilizador "..user.sName.." est? com um cliente sem TAG ou cliente desconhecido.")
   end
   Message(user)
end
-------------------------------------------------------------------------------------------------------------------------------------------------
OpConnected = NewUserConnected

-------------------------------------------------------------------------------------------------------------------------------------------------
function DataArrival(user, data)
   if ALLUSERS[user.sName]==nil then
      ALLUSERS[user.sName]=1
      LEVELS[tostring(user.iProfile)]=LEVELS[tostring(user.iProfile)]+1
   end
   s,e,cmd= strfind(data, "%b<>%s+(%S+)")
   if cmd ~= nil and commands[cmd] then
      SetTimer(5 * 1000)
      StartTimer()
   end
end
-------------------------------------------------------------------------------------------------------------------------------------------------
function OnTimer()
   StopTimer()
   OpenRegisterdUsersFile()
end
-------------------------------------------------------------------------------------------------------------------------------------------------
function UserDisconnected(user)
   if ALLUSERS[user.sName] then
      ALLUSERS[user.sName]=nil
      if LEVELS[tostring(user.iProfile)] > 0 then
         LEVELS[tostring(user.iProfile)]=LEVELS[tostring(user.iProfile)]-1
      end
   end
end
-------------------------------------------------------------------------------------------------------------------------------------------------
function OpDisconnected(user)
   if ALLUSERS[user.sName] then
      ALLUSERS[user.sName]=nil
      if LEVELS[tostring(user.iProfile)] > 0 then
         LEVELS[tostring(user.iProfile)]=LEVELS[tostring(user.iProfile)]-1
      end
   end
end
-------------------------------------------------------------------------------------------------------------------------------------------------
function Main()
   frmHub:RegBot(Bot)
   OpenRegisterdUsersFile()
end
-------------------------------------------------------------------------------------------------------------------------------------------------
function OpenRegisterdUsersFile()
   readfrom("../RegisteredUsers.dat")
   for a,b in LEVELSTOT do
      LEVELSTOT[a]=0
   end
   while 1 do
      local line = read()
      local level
      if line == nil then
         readfrom()
         break
      end
      s,e,level = strfind(line,".+|.+|(.+)")
      if LEVELSTOT[level] then
         LEVELSTOT[level] = LEVELSTOT[level] +1
      end
   end  
end
-------------------------------------------------------------------------------------------------------------------------------------------------
function Serialize(tTable, sTableName, hFile, sTab)
   assert(tTable, "tTable equals nil");
   assert(sTableName, "sTableName equals nil");
   assert(hFile, "hFile equals nil");

   assert(type(tTable) == "table", "tTable must be a table!");
   assert(type(sTableName) == "string", "sTableName must be a string!");

   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

function SaveToFile(file , table , tablename)
   local hFile = openfile(file, "w");
   Serialize(table, tablename, hFile);
   closefile(hFile);
end

function LoadFromFile (file)
   assert(readfrom(file),"Making file, not to horry")
   dostring(read("*all"))
   readfrom()
end

function VersionChecker(user)
local tmp = ""
   if (strfind(user.sMyInfoString, "      tmp = "oDc"
   elseif (strfind(user.sMyInfoString,"      tmp = "DCGUI"
   elseif strfind(user.sMyInfoString,"      tmp = "DCPRO"
   elseif strfind(user.sMyInfoString,"L:") or strfind(user.sMyInfoString,"B:") then
      tmp = "BCDC++"
   elseif (strfind(user.sMyInfoString, "<+")) then
      tmp = "DC++"
   else
      tmp = "Cliente sem TAG ou cliente desconhecido."
   end
return tmp
end

function ModeChecker(user)
local tmp = ""
   if (strfind(user.sMyInfoString, "M:P")) then
      tmp = "Passivo"
   else
      tmp = "Activo"
   end
return tmp
end--------------------------------------------------------------------------------
Title:
Post by: nEgativE on 23 March, 2004, 08:55:08
Spanish !!?
Title:
Post by: [G-T-E]Gate? on 23 March, 2004, 09:01:08
OK then Brazilen or Portugise then.
What ever , the script doesnt contain full english ...
Title:
Post by: nEgativE on 23 March, 2004, 09:20:17
QuoteOriginally posted by [G-T-E]Gate?
OK then Brazilen or Portugise then.
What ever , the script doesnt contain full english ...

Hehe..
I think u can understand now those lines.


-----------------------------------------------------------------------------
-- online user counter by plop v:1.2
-- based on a bot by ....... witch showed basic hub info 2 users on entry
-- (fill in the name pls if you know who this was)
-----------------------------------------------------------------------------
-- LEVELSTOT[number] = total number of users with that level
-- LEVELS[number] = total online number of users with that level
-- commands = table of triggers used by the hub 2 add/delete users
-- add the script commands yourself if you use a script 2 add/delete users
-- same can be done if you have more user levels then default
-----------------------------------------------------------------------------
-- tables all over but i seem 2 have forgotten 2 add chairs. snif snif
-----------------------------------------------------------------------------
-- manual stuff
-----------------------------------------------------------------------------
-- LEVELSTOT["0"] -- total masters
-- LEVELSTOT["1"] -- total operators
-- LEVELSTOT["2"] -- total VIPs
-- LEVELSTOT["3"] -- total registred users
-- tmp -- total operators and masters
-- frmHub:GetUsersCount() -- total online users
----------
-- LEVELS["0"] -- total online masters
-- LEVELS["1"] -- total online operators
-- LEVELS["2"] -- total online VIPs
-- LEVELS["3"] -- total online registered users
-- LEVELS["-1"] -- total online unregistered users
-- tmp3 -- total operators and masters
----------
-- offline users
-- LEVELSTOT["0"] - LEVELS["0"] == offline operators
-- tmp1 -- total offline VIPs
-- tmp2 -- total offline registered users
-----------------------------------------------------------------------------
-- name of the bot
Bot = "BOT"

-- couter tables, if you have more levels add there numbers in BOTH tables,
-- except unreg users, those only work in the lower table
LEVELSTOT = {["0"]=0, ["1"]=0, ["2"]=0, ["3"]=0}
LEVELS = {["0"]=0, ["1"]=0, ["2"]=0, ["3"]=0, ["-1"]=0}

Stattxt = "stat.txt" --Will be created in the script folder

Stat = {
logins = 0,
share = 0,
users = 0,
}

-- table holding the commands ptokax uses 2 add/delete users
-- add your bot's commands 2 this table if you use a bot 2 add/delete ppl
commands = {["!addreguser"]=1, ["!delreguser"]=1}
-------------------------------------------------------------------------------------------------------------------------------------------------
function Message(user)
   local s,e,share = strfind(user.sMyInfoString, "$(%d+)%$")
   local s,e,hubs,slots = strfind(user.sMyInfoString, "H:(%S+),S:(%d+)")
   if share ~= nil then
   share = format("%0.2f", ( share / (1024*1024*1024)))
   else
   share = 0
   end
   if (hubs == nil and slots == nil) then
hubs = "SEM TAG"
slots = hubs
   elseif (strfind(hubs, "%d+/") ~= nil) then
   local s,e,notreg,reg,opped = strfind(hubs, "(%d+)/(%d+)/(%d+)")
   hubs = notreg + reg + opped
   end
   local hubshare = format("%0.2f",  ( frmHub:GetCurrentShareAmount() / (1024*1024*1024)))
   local ttshare = format("%0.2f", tonumber(Stat.share)/(1024*1024*1024))
   local tmp = LEVELSTOT["1"] + LEVELSTOT["0"]  --- total ops  (adding masters 2 ops)
   local tmp1 = (LEVELSTOT["2"] - LEVELS["2"]) if tmp1 < 0 then tmp1 = 0 end --- offline vips (total - online)
   local tmp2 = (LEVELSTOT["3"] - LEVELS["3"]) if tmp2 < 0 then tmp2 = 0 end --- offline regs (total - online)
   local tmp3 = LEVELS["1"] + LEVELS["0"] -- online ops (adding masters 2 the ops)
   user:SendData(Bot, "-=[?]=---------------------------------------------------------------------------------------------------------=[?]=-")
   user:SendData(Bot, " <-----=[- "..frmHub:GetHubName().." ? v2004 -]=----->")
   user:SendData(Bot, "-=[?]=---------------------------------------------------------------------------------------------------------=[?]=-")
   user:SendData(Bot, "      ? Hub desc.")
   user:SendData(Bot, "      ? "..user.sName..", welcome to server (xxx.no-ip.xxx).")
   user:SendData(Bot, "      ? Your IP is: "..user.sIP.." - StatuS: "..(GetProfileName(user.iProfile) or "Not registered")..".")
   user:SendData(Bot, "      ? You are sharing: "..share.." GB. Min. share of: "..frmHub:GetMinShare()/(1024).." GB.")
   user:SendData(Bot, "      ? You are connected on: "..hubs.." Hub(s) and have: "..slots.." free Slot(s)")
   user:SendData(Bot, "      ? You are using Client: "..VersionChecker(user)..", in Mode: "..ModeChecker(user)..".")
   user:SendData(Bot, "      ? Online users: "..frmHub:GetUsersCount()..". Record: "..Stat.users..". M?x of: "..frmHub:GetMaxUsers()..".")
   user:SendData(Bot, "      ? Online Operators: "..tmp3..". ViPs: "..LEVELS["2"]..".")
   user:SendData(Bot, "      ? Total Operators registered on Hub: "..tmp..". ViPs: "..LEVELSTOT["2"]..".")
   user:SendData(Bot, "      ? Total Offline registered users: "..tmp2..".")
   user:SendData(Bot, "      ? Total share on Hub: "..hubshare.." GB. Record: "..ttshare.." GB.")
   user:SendData(Bot, "      ? Hub logins: "..Stat.logins.." - Reseted at: 21/03/04.")
   user:SendData(Bot, "      ? Commands list, rules, help and info: !something")
   user:SendData(Bot, "      ? "..GetTime().."")
   user:SendData(Bot, "      ? Website - F?rum: [URL]www.xxx.org[/URL]")
   user:SendData(Bot, "-=[?]=---------------------------------------------------------------------------------------------------------=[?]=-")
   user:SendData(Bot, " <-----=[- "..frmHub:GetHubName().." ? v2004 -]=----->")
   user:SendData(Bot, "-=[?]=---------------------------------------------------------------------------------------------------------=[?]=-")
end
-------------------------------------------------------------------------------------------------------------------------------------------------
function GetTime()
s = date("%S")
h = date("%H")
m = date("%M")
d = date("%d")
mm = date("%m")
y = date("%y")
Date = "Local time: "..h..":"..m..":"..s.." - "..d.."/"..mm.."/20"..y.."."
return Date
end
-------------------------------------------------------------------------------------------------------------------------------------------------
ALLUSERS={}

function NewUserConnected(user)
local s,e,usrshare = strfind(user.sMyInfoString, "%$%s*(%d+)%$")
if (readfrom(Stattxt) == nil) then
if (Stat.users < frmHub:GetUsersCount() ) then
Stat.users = frmHub:GetUsersCount()
else
end
if (Stat.share < frmHub:GetCurrentShareAmount() + usrshare) then
Stat.share = frmHub:GetCurrentShareAmount() + usrshare
end
Stat.logins = Stat.logins + 1
SaveToFile(Stattxt , Stat , "Stat")
else
LoadFromFile (Stattxt)
local logins = Stat["logins"]
local share = Stat["share"]
local users = Stat["users"]
if (users < frmHub:GetUsersCount() ) then
Stat.users = frmHub:GetUsersCount()
else
Stat.users = users
end
if (share < frmHub:GetCurrentShareAmount() + usrshare) then
Stat.share = frmHub:GetCurrentShareAmount() + usrshare
else
Stat.share = share
end
Stat.logins = logins + 1
SaveToFile(Stattxt , Stat , "Stat")
end

   if ALLUSERS[user.sName]==nil then
      ALLUSERS[user.sName]=1
      LEVELS[tostring(user.iProfile)]=LEVELS[tostring(user.iProfile)]+1
   end
   if (VersionChecker(user) == "Cliente sem TAG ou Cliente desconhecido.") then
SendToOps(Bot, "Usu?rio: "..user.sName..", est? com um Cliente sem TAG ou Cliente desconhecido.")
   end
   Message(user)
end
-------------------------------------------------------------------------------------------------------------------------------------------------
OpConnected = NewUserConnected

-------------------------------------------------------------------------------------------------------------------------------------------------
function DataArrival(user, data)
   if ALLUSERS[user.sName]==nil then
      ALLUSERS[user.sName]=1
      LEVELS[tostring(user.iProfile)]=LEVELS[tostring(user.iProfile)]+1
   end
   s,e,cmd= strfind(data, "%b<>%s+(%S+)")
   if cmd ~= nil and commands[cmd] then
      SetTimer(5 * 1000)
      StartTimer()
   end
end
-------------------------------------------------------------------------------------------------------------------------------------------------
function OnTimer()
   StopTimer()
   OpenRegisterdUsersFile()
end
-------------------------------------------------------------------------------------------------------------------------------------------------
function UserDisconnected(user)
   if ALLUSERS[user.sName] then
      ALLUSERS[user.sName]=nil
      if LEVELS[tostring(user.iProfile)] > 0 then
         LEVELS[tostring(user.iProfile)]=LEVELS[tostring(user.iProfile)]-1
      end
   end
end
-------------------------------------------------------------------------------------------------------------------------------------------------
function OpDisconnected(user)
   if ALLUSERS[user.sName] then
      ALLUSERS[user.sName]=nil
      if LEVELS[tostring(user.iProfile)] > 0 then
         LEVELS[tostring(user.iProfile)]=LEVELS[tostring(user.iProfile)]-1
      end
   end
end
-------------------------------------------------------------------------------------------------------------------------------------------------
function Main()
   frmHub:RegBot(Bot)
   OpenRegisterdUsersFile()
end
-------------------------------------------------------------------------------------------------------------------------------------------------
function OpenRegisterdUsersFile()
   readfrom("../RegisteredUsers.dat")
   for a,b in LEVELSTOT do
      LEVELSTOT[a]=0
   end
   while 1 do
      local line = read()
      local level
      if line == nil then
         readfrom()
         break
      end
      s,e,level = strfind(line,".+|.+|(.+)")
      if LEVELSTOT[level] then
         LEVELSTOT[level] = LEVELSTOT[level] +1
      end
   end  
end
-------------------------------------------------------------------------------------------------------------------------------------------------
function Serialize(tTable, sTableName, hFile, sTab)
assert(tTable, "tTable equals nil");
assert(sTableName, "sTableName equals nil");
assert(hFile, "hFile equals nil");

assert(type(tTable) == "table", "tTable must be a table!");
assert(type(sTableName) == "string", "sTableName must be a string!");

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

function SaveToFile(file , table , tablename)
local hFile = openfile(file, "w");
Serialize(table, tablename, hFile);
closefile(hFile);
end

function LoadFromFile (file)
assert(readfrom(file),"Making file, not to horry")
dostring(read("*all"))
readfrom()
end

function VersionChecker(user)
local tmp = ""
if (strfind(user.sMyInfoString, " tmp = "oDC"
elseif (strfind(user.sMyInfoString," tmp = "DCGUI"
elseif strfind(user.sMyInfoString," tmp = "DCPRO"
elseif strfind(user.sMyInfoString,"L:") or strfind(user.sMyInfoString,"B:") then
tmp = "BCDC++"
elseif (strfind(user.sMyInfoString, "<+")) then
tmp = "DC++"
else
tmp = "Client without TAG or unknown client."
end
return tmp
end

function ModeChecker(user)
local tmp = ""
if (strfind(user.sMyInfoString, "M:P")) then
tmp = "Passive"
else
tmp = "Active"
end
return tmp
end

Title:
Post by: [G-T-E]Gate? on 23 March, 2004, 09:25:46
Morning Luso
0930 here and just got up so I think my eyes are still abit ? closed but the other ? still sees things like .........

if (VersionChecker(user) == "Cliente sem TAG ou Cliente desconhecido.") then
   SendToOps(Bot, "Usu?rio: "..user.sName..", est? com um Cliente sem TAG ou Cliente desconhecido.")

Big Yawn  :rolleyes:
Title:
Post by: nEgativE on 23 March, 2004, 09:38:34
QuoteOriginally posted by [G-T-E]Gate?
Morning Luso
0930 here and just got up so I think my eyes are still abit ? closed but the other ? still sees things like .........

if (VersionChecker(user) == "Cliente sem TAG ou Cliente desconhecido.") then
   SendToOps(Bot, "Usu?rio: "..user.sName..", est? com um Cliente sem TAG ou Cliente desconhecido.")

Big Yawn  :rolleyes:

sorry.. 5.33 here, didn't sleep yet

if (VersionChecker(user) == "Client without TAG or unknown client.") then
   SendToOps(Bot, "User: "..user.sName..", is using a Client without TAG or a unknown Client")