PtokaX forum

Archive => Archived 4.0 boards => Help with Lua 4 scripts => Topic started by: [BR]Luso on 14 November, 2003, 23:47:21

Title: I need help with this script
Post by: [BR]Luso on 14 November, 2003, 23:47:21
Hi there, i'm having a problem with this scripts, when a user connect to the hub, i have this error --> "Syntax Error: attempt to concat a nil value" but it's not always, just some users on-connect, it's strange.. i tried to see if it was by those fakers without a tag.. but it's not, i have operators joinning in with that syntax error.



Bot = "[operserv]"

--frmHub:RegBot(Bot)


function NewUserConnected(user, data)
   s,e,description,speed,email,share = strfind(user.sMyInfoString, "$MyINFO $ALL ([^$]+)$ $([^$]*)$([^$]*)$([^$]+)")
   share = share / (1024*1024*1024)
   share = strsub(share, 1, 5)
   hubshare = frmHub:GetCurrentShareAmount() / (1024*1024*1024) + share
   hubshare = strsub(hubshare, 1, 5)
   user:SendData(Bot, ":p2p:--------------------------------------------------------------------------------------------:p2p:")
   user:SendData(Bot, " ? -=[:: "..user.sName.." ::]=-")
   user:SendData(Bot, " ? Host: "..tohostname(user.sIP)..", IP: " ..user.sIP)
   user:SendData(Bot, " ? Bem vindo ao "..frmHub:GetHubName()..".")
   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, ":p2p:--------------------------------------------------------------------------------------------:p2p:")
end

function OpConnected(user, data)
   s,e,description,speed,email,share = strfind(user.sMyInfoString, "$MyINFO $ALL ([^$]+)$ $([^$]*)$([^$]*)$([^$]+)")
   share = share / (1024*1024*1024)
   share = strsub(share, 1, 5)
   hubshare = frmHub:GetCurrentShareAmount() / (1024*1024*1024) + share
   hubshare = strsub(hubshare, 1, 5)
   user:SendData(Bot, ":p2p:--------------------------------------------------------------------------------------------:p2p:")
   user:SendData(Bot, " ? -=[:: "..user.sName.." ::]=-")
   user:SendData(Bot, " ? Host: "..tohostname(user.sIP)..", IP: " ..user.sIP)
   user:SendData(Bot, " ? Bem vindo ao "..frmHub:GetHubName()..".")
   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, ":p2p:--------------------------------------------------------------------------------------------:p2p:")
end

 

Another script, I'm using a script called "recordbotv0.952" for hub share and user record, but sometimes he get HUGE share amount on the hub and save it like "8321463217.17 GB." and then stays forever that amount.. hehehe, could be this a problem with the users DC Client ? don't know how to solve this problems :(

Tks in advance for all scripters :)
sorry the english.
Title:
Post by: NightLitch on 15 November, 2003, 00:15:14
I see no problem in your script... and I get no error's with it... dunno what wrong... what other script's are
you using but this and recordbot`???


Here my "tiny" face lift on the script hehe, Bored so...  :D

--// Face lift by NightLitch, hehe
Bot = "[operserv]"

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

function NewUserConnected(user, data)
   LoginMessage(user,data)
end

function OpConnected(user, data)
   LoginMessage(user,data)
end

function LoginMessage(user,data)
   s,e,description,speed,email,share = strfind(user.sMyInfoString, "$MyINFO $ALL ([^$]+)$ $([^$]*)$([^$]*)$([^$]+)")
   share = share / (1024*1024*1024)
   share = strsub(share, 1, 5)
   hubshare = frmHub:GetCurrentShareAmount() / (1024*1024*1024) + share
   hubshare = strsub(hubshare, 1, 5)
   user:SendData(Bot, ":p2p:--------------------------------------------------------------------------------------------:p2p:")
   user:SendData(Bot, "    ? -=[:: "..user.sName.." ::]=-")
   user:SendData(Bot, "    ? Host: "..tohostname(user.sIP)..", IP: " ..user.sIP)
   user:SendData(Bot, "    ? Bem vindo ao "..frmHub:GetHubName()..".")
   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, ":p2p:--------------------------------------------------------------------------------------------:p2p:")
end

/NL
Title:
Post by: plop on 15 November, 2003, 00:23:54
if your bored then do your facelift on this 1.  lol
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.." ::]=-")
   user:SendData(Bot, "    ? Host: "..tohostname(user.sIP)..", IP: " ..user.sIP)
   user:SendData(Bot, "    ? Bem vindo ao "..frmHub:GetHubName()..".")
   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, ":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.." ::]=-")
   user:SendData(Bot, "    ? Host: "..tohostname(user.sIP)..", IP: " ..user.sIP)
   user:SendData(Bot, "    ? Bem vindo ao "..frmHub:GetHubName()..".")
   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, ":p2p:--------------------------------------------------------------------------------------------:p2p:")
end
removed some not used stuff and optimized it a little.
hope it works now.
the share size problem should be fixed for sure now.

plop
Title:
Post by: tezlo on 15 November, 2003, 00:45:50
not all IPs can be resolved so tohostname() will occaonally return nil.. you could do this
user:SendData(Bot, "    ? Host: "..(tohostname(user.sIP) or "n/a")..", IP: " ..user.sIP)
Title:
Post by: plop on 15 November, 2003, 00:55:25
QuoteOriginally posted by tezlo
not all IPs can be resolved so tohostname() will occaonally return nil.. you could do this
user:SendData(Bot, "    ? Host: "..(tohostname(user.sIP) or "n/a")..", IP: " ..user.sIP)
thx didn't see that 1.
this 1 is fixed and facelifted.  lol
Bot = "[operserv]"

--frmHub:RegBot(Bot)


function NewUserConnected(user)
   ShowWelcome(user)
end

function OpConnected(user)
   ShowWelcome(user)
end

function ShowWelcome(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.." ::]=-")
   user:SendData(Bot, "    ? Host: "..(tohostname(user.sIP) or "n/a")..", IP: " ..user.sIP)
   user:SendData(Bot, "    ? Bem vindo ao "..frmHub:GetHubName()..".")
   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, ":p2p:--------------------------------------------------------------------------------------------:p2p:")
end
 
plop
Title:
Post by: NightLitch on 15 November, 2003, 13:38:22
hehe Lol... must have been tired when looking at the code... haha...

well the facelift was a good start, thx for the nice
styles plop... I can really see it coming now...

Hair, mustach hehe...

/NL
Title:
Post by: turkiye on 15 November, 2003, 14:02:27
is it clear?
Title:
Post by: [BR]Luso on 17 November, 2003, 05:50:07
WoW, Thank U all for help fixing the scripts !! :) work great now..

i wonder if it's possible to include the funtion CountOPs() in the scripts, and vips also, hehe.. :-)

Tks all  :D
Title:
Post by: plop on 17 November, 2003, 13:26:12
QuoteOriginally posted by
Luso

WoW, Thank U all for help fixing the scripts !! :) work great now..
i wonder if it's possible to include the funtion CountOPs() in the scripts, and vips also, hehe.. :-)
Tks all  :D
np, here it is, just you have 2 translate it yourself.  lol
now with mustache and nose job.
when you add a vip you need 2 reload them.
-- original by .... (fill in your name here if it was yours)
-- facelift idea's by nightlitch and plop
-- counting online op's/vip's by plop
-- nose job, mustache by plop
-- thx 2 tezlo for the fix of tohostname
-- greets 2 all users/scripters on the lua forum
-- works on 0.3.2.6+ (testdrive+)

Bot = "[operserv]"
OnlineOPs = {}
VipsTable = {}
OnlineVIPs = {}
-- reload vips command
RELOAD = "!reloadvips"

function Clear()
   collectgarbage()
   flush()
end

function ShowWelcome(user)
   local info = "\r\n\r\n"
   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) ))
   info = info..":p2p:--------------------------------------------------------------------------------------------:p2p:\r\n"
   info = info.."\t? -=[:: "..user.sName.." ::]=-\r\n"
   info = info.."\t? Host: "..(tohostname(user.sIP) or "n/a")..", IP: " ..user.sIP.."\r\n"
   info = info.."\t? Bem vindo ao "..frmHub:GetHubName()..".\r\n"
   info = info.."\t? Seu status no Hub: "..(GetProfileName(user.iProfile) or "N?o registrado").."\r\n"
   info = info.."\t? Voc? est? compartilhando "..share.." GB.\r\n"
   info = info.."\t? Usu?rios Online: "..frmHub:GetUsersCount()..".\r\n"
   info = info.."\t? There are "..getn(OnlineOPs).." Operators and "..getn(OnlineVIPs).." VIP's online.\r\n"
   info = info.."\t? Compartilhamento atual no Hub: "..hubshare.." GB.\r\n"
   info = info..":p2p:--------------------------------------------------------------------------------------------:p2p:\r\n"
   user:SendData(Bot, info.." |")
   Clear()
end

function OpenRegisterdUsersFile()
   readfrom("../RegisteredUsers.dat")
   VipsTable = nil
   Clear()
   VipsTable = {}
   while 1 do
      local line = read()
      local name, level
      if line == nil then
         readfrom()
         break
      end
      s,e,name,level = strfind(line,"(.+)|.+|(.+)")
      if tonumber(level) == 2 then
         VipsTable[name] = 1
      end
   end  
end

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

function NewUserConnected(user)
   if VipsTable[user.sName] then
      tinsert(OnlineVIPs, user.sName)
   end
   ShowWelcome(user)
end

function UserDisconnected(user)
   if VipsTable[user.sName] then
      for i=1, getn(OnlineVIPs) do
         if OnlineVIPs[i] then
            tremove(OnlineVIPs, i)
            break
         end
      end
   end
end

function OpConnected(user)
   tinsert(OnlineOPs, user.sName)
   ShowWelcome(user)
end

function OpDisconnected(user)
   for i=1,getn(OnlineOPs) do
      if OnlineOPs[i] == user.sName then
         tremove(OnlineOPs, i)
         break
      end
   end
end

function DataArrival(user, data)
   if( strsub(data, 1, 1) == "<" ) and user.bOperator then
      data=strsub(data,1,strlen(data)-1)
      s,e,cmd = strfind(data,"%b<>%s+(%S+)")
      user:SendData(Bot, cmd)
      if cmd == RELOAD then
         OpenRegisterdUsersFile()
         user:SendData(Bot, "VIPs reloaded|")
         return 1
      end
   end
end

plop
Title:
Post by: [BR]Luso on 17 November, 2003, 20:04:02
Looking Great Plop, tks for fast replay !! could u make that code on this one ? becouse i'm using another script with the same format..



-- original by nErBoS
-- modified by Varetas and [BR]Luso
-- facelift ideas by nightlitch and plop
-- counting online ops/vips by plop
-- nose job, mustache by plop
-- thx 2 tezlo for the fix of tohostname
-- greets 2 all users/scripters on the lua forum
-- works on 0.3.2.6+ (testdrive+)

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.." ::]=-")
   user:SendData(Bot, " ? Host: "..(tohostname(user.sIP) or "N/A")..", IP: " ..user.sIP)
   user:SendData(Bot, " ? Bem vindo(a) ao "..frmHub:GetHubName()..".")
   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, ":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.." ::]=-")
   user:SendData(Bot, " ? Host: "..(tohostname(user.sIP) or "N/A")..", IP: " ..user.sIP)
   user:SendData(Bot, " ? Bem vindo ao "..frmHub:GetHubName()..".")
   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, ":p2p:--------------------------------------------------------------------------------------------:p2p:")
end



CountOps() and vips, i tried but with erros ! :(
Thank U .. the credits on top
Sorry the english..