PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: nEgativE on 25 December, 2003, 10:55:00

Title: function CountOPs()
Post by: nEgativE on 25 December, 2003, 10:55:00
Hi There.. i'm looking 4 a stand alone function CountOPs() and vips..  :))

Tks in advance.
Title:
Post by: plop on 26 December, 2003, 01:41:54
quick job, hope it works.
ops =0
vips = 0
VIPS = {}
OPS = {}

function NewUserConnected(user)
   if user.iProfile == 2 then
      CountVips(user)
   end
end

function OpConnected(user)
   CountOps(user)
end

function DataArrival(user,data)
   if user.bOperator then
      CountOps(user)
   elseif user.iProfile == 2 then
      CountVips(user)
   end
end

function CountOps(user)
   if OPS[user.sName] == nil then
      OPS[user.sName]=1
      ops = ops + 1
   end
end

function CountVips(user)
   if VIPS[user.sName] == nil then
      VIPS[user.sName]=1
      vips=vips +1
   end
end

function UserDisconnected(user)
   if user.iProfile == 2 then
      if VIPS[user.sName] then
         VIPS[user.sName]=nil
         vips=vips - 1
      end
   end
end

function OpDisconnected(user)
   if OPS[user.sName] then
      OPS[user.sName]=nil
      ops = ops -1
   end
end
plop
Title:
Post by: nEgativE on 26 December, 2003, 23:04:07
QuoteOriginally posted by plop
quick job, hope it works.
ops =0
vips = 0
VIPS = {}
OPS = {}

function NewUserConnected(user)
   if user.iProfile == 2 then
      CountVips(user)
   end
end

function OpConnected(user)
   CountOps(user)
end

function DataArrival(user,data)
   if user.bOperator then
      CountOps(user)
   elseif user.iProfile == 2 then
      CountVips(user)
   end
end

function CountOps(user)
   if OPS[user.sName] == nil then
      OPS[user.sName]=1
      ops = ops + 1
   end
end

function CountVips(user)
   if VIPS[user.sName] == nil then
      VIPS[user.sName]=1
      vips=vips +1
   end
end

function UserDisconnected(user)
   if user.iProfile == 2 then
      if VIPS[user.sName] then
         VIPS[user.sName]=nil
         vips=vips - 1
      end
   end
end

function OpDisconnected(user)
   if OPS[user.sName] then
      OPS[user.sName]=nil
      ops = ops -1
   end
end
plop

Thank U Plop, what i really want is to put that script into this one, to get these line

   user:SendData(Bot, "   ? Ops Online: "..OPS[user.sName]..".")

i tried to merge them, But is not working for me :( i allways get 1 Op and if there is no Ops the script get error syntax..



Bot = "[operserv]"

--frmHub:RegBot(Bot)

function NewUserConnected(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) ))
   user:SendData(Bot, ":p2p:-------------------------------------------------------------------------------------------------:p2p:")
   user:SendData(Bot, " ? "..user.sName..", Bem vindo ao -=[- "..frmHub:GetHubName().." -]=-")  
   user:SendData(Bot, " ? Seu endere?o IP: "..user.sIP)
   user:SendData(Bot, " ? Website: [URL]www.lusobrasil.tk[/URL]")
   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: "..frmHub:GetUsersCount()..".")
   user:SendData(Bot, " ? Compartilhamento atual no Hub: "..hubshare.." GB.")
   user:SendData(Bot, " ? Digite: !ajuda no main chat.")
   user:SendData(Bot, ":p2p:-------------------------------------------------------------------------------------------------:p2p:")
end

function OpConnected(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)))
   user:SendData(Bot, ":p2p:-------------------------------------------------------------------------------------------------:p2p:")
   user:SendData(Bot, " ? "..user.sName..", Bem vindo ao -=[- "..frmHub:GetHubName().." -]=-")
   user:SendData(Bot, " ? Seu endere?o IP: "..user.sIP)
   user:SendData(Bot, " ? Website: [URL]www.lusobrasil.tk[/URL]")
   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: "..frmHub:GetUsersCount()..".")
   user:SendData(Bot, " ? Compartilhamento atual no Hub: "..hubshare.." GB.")
   user:SendData(Bot, " ? Digite: !ajuda e !ajuda.op no main chat.")
   user:SendData(Bot, ":p2p:-------------------------------------------------------------------------------------------------:p2p:")
end



 Sorry the english !! =\
 Ruuning Ptokax td4
Title:
Post by: plop on 27 December, 2003, 15:54:52
here you are.
Bot = "[operserv]"
ops =0
vips = 0
VIPS = {}
OPS = {}

function NewUserConnected(user)
   if user.iProfile == 2 then
      CountVips(user)
   end
   Message(user)
end

function OpConnected(user)
   CountOps(user)
   Message(user)
end

function DataArrival(user,data)
   if user.bOperator then
      CountOps(user)
   elseif user.iProfile == 2 then
      CountVips(user)
   end
end

function CountOps(user)
   if OPS[user.sName] == nil then
      OPS[user.sName]=1
      ops = ops + 1
   end
end

function CountVips(user)
   if VIPS[user.sName] == nil then
      VIPS[user.sName]=1
      vips=vips +1
   end
end

function UserDisconnected(user)
   if user.iProfile == 2 then
      if VIPS[user.sName] then
         VIPS[user.sName]=nil
         vips=vips - 1
      end
   end
end

function OpDisconnected(user)
   if OPS[user.sName] then
      OPS[user.sName]=nil
      ops = ops -1
   end
end

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)))
   user:SendData(Bot, ":p2p:-------------------------------------------------------------------------------------------------:p2p:")
   user:SendData(Bot, "    ? "..user.sName..", Bem vindo ao -=[- "..frmHub:GetHubName().." -]=-")
   user:SendData(Bot, "    ? Seu endere?o IP: "..user.sIP)
   user:SendData(Bot, "    ? Website: [URL]www.lusobrasil.tk[/URL]")
   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: "..frmHub:GetUsersCount()..".")
   user:SendData(Bot, "    ? Compartilhamento atual no Hub: "..hubshare.." GB.")
   user:SendData(Bot, "    ? There are "..ops.." Operators and "..vips.." VIPS online")
   user:SendData(Bot, "    ? Digite: !ajuda e !ajuda.op no main chat.")
   user:SendData(Bot, ":p2p:-------------------------------------------------------------------------------------------------:p2p:")
end
plop
Title:
Post by: nEgativE on 28 December, 2003, 08:59:45
Thank U Plop .. working fine !! :)
Title:
Post by: xfiles on 26 January, 2004, 02:43:38
Syntax error: bad argument #1 to `strfind' (string expected, got nil)
stack traceback:
1: function `strfind' [C]
2: function `Message' at line 59 [file `...25.dbg mit RoboCop v6.0d\scripts\OnJoinInfo.lua']
3: function `NewUserConnected' at line 12 [file `...25.dbg mit RoboCop v6.0d\scripts\OnJoinInfo.lua']




the fix bellow won?t show the syntaxerror above anymore.
thx to plop for the help. :)





Bot = "what-ever-you-want"

ops =0
vips = 0
VIPS = {}
OPS = {}

function NewUserConnected(user)
if user.iProfile == 2 then
CountVips(user)
end
Message(user)
end

function OpConnected(user)
CountOps(user)
Message(user)
end

function DataArrival(user,data)
if user.bOperator then
CountOps(user)
elseif user.iProfile == 2 then
CountVips(user)
end
end

function CountOps(user)
if OPS[user.sName] == nil then
OPS[user.sName]=1
ops = ops + 1
end
end

function CountVips(user)
if VIPS[user.sName] == nil then
VIPS[user.sName]=1
vips=vips + 1
end
end

function UserDisconnected(user)
if user.iProfile == 2 then
if VIPS[user.sName] then
VIPS[user.sName]=nil
vips=vips - 1
end
end
end

function OpDisconnected(user)
if OPS[user.sName] then
OPS[user.sName]=nil
ops = ops - 1
end
end

function Message(user)
   if strfind(user.sMyInfoString, "$MyINFO") then
      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)))
      user:SendData(Bot, ":--------------------------------------------------------------------------------------------------------------------:")
      user:SendData(Bot, "         Hello, "..user.sName.."")
      user:SendData(Bot, "")
      user:SendData(Bot, "   ? Your IP            ==> "..user.sIP)
      user:SendData(Bot, "   ? Welcome to         ==> "..frmHub:GetHubName().."")
      user:SendData(Bot, "   ? Your Status in this Hub      ==> "..(GetProfileName(user.iProfile) or "Not registered"))
      user:SendData(Bot, "   ? You are sharing         ==> "..share.." GB")
      user:SendData(Bot, "   ? Actual Share in the Hub      ==> "..hubshare.." GB")
      user:SendData(Bot, "   ? Operators Online         ==> "..ops.."")
      user:SendData(Bot, "   ? VIPs Online         ==> "..vips.."")
      user:SendData(Bot, "   ? Total Users in the Hub      ==> "..frmHub:GetUsersCount().."")
      user:SendData(Bot, ":--------------------------------------------------------------------------------------------------------------------:")
   end
end