PtokaX forum

Archive => Archived 5.1 boards => Help with scripts => Topic started by: electronic_Psycho on 31 March, 2007, 06:02:29

Title: Need Help please with script
Post by: electronic_Psycho on 31 March, 2007, 06:02:29
Hello.. and Good Morning  ;D

i have problem with one of my script.

i Need help please..

i got this error
--------------
:26: bad argument #1 to 'pairs' (table expected, got nil)
------------

i past here part of script.. 26' line.

if someone know what the problem is... please help ..  ???
------------------------------------------
--// Profile Counter
     
function ProfileCounter(profile)
   
      local table, count = GetUsersByProfile(profile),0
      for i,User in pairs(table) do
      

       if GetItemByName(User) then
            count = count + 1

       end

     end

     return count
end

-------

Thanks..

Title: Re: Need Help please with script
Post by: Madman on 31 March, 2007, 10:06:57
my guess are that you are sending the profile number to the function. You should send the profilename
Title: Re: Need Help please with script
Post by: electronic_Psycho on 31 March, 2007, 17:24:20
Hello and Thanks "Madman" and "Mutor"

i Tried To put the line that Mutor past here' but the same error..
---
.lua:26: bad argument #1 to 'pairs' (table expected, got nil
----

i Change the line to this >

---
kb = 1024
mb = kb*kb
gb = kb*kb*kb
tb = kb*kb*kb*kb

function NewUserConnected(user)
Message(user)
end

function OpConnected(user)
Message(user)
end

--// Profile Counter
     
function ProfileCounter(profile)

      local table, count = GetUsersByProfile(GetProfileName(profile)),0
      for i,User in pairs(table) do


if GetItemByName(User) then
   count = count + 1

end

     end

     return count
end

function Message(user)
if user.sMyInfoString then
local disp = ""
doGetProfile = GetProfileName(user.iProfile) or "Not registerd"
hubshare = string.format("%0.2f", frmHub:GetCurrentShareAmount()/(1024)/(1024)/(1024)/(1024))
local _,_,share = string.find(user.sMyInfoString, "^%$MyINFO %$ALL [^ ]+ [^$]*%$ $[^$]+[^$]%$[^$]*%$%s*(%d+)%$" )
if share then
minshare = string.format("%0.2f", tonumber(share)/gb).." GB"
else
minshare = "Corrupt"
end
end

------

what it could be ?

i not a scripter,,, basic know on that ..  :-X

Please Help..

tnx allot,,
Title: Re: Need Help please with script
Post by: CrazyGuy on 31 March, 2007, 23:22:03
It's hard to see because your code doesn't show where you actually call upon that function
My guess would be that the error occurs when handling unregistered users.
As the profile resolving will return nil for them, table will remain nil

You can solve it by declaring table first


function ProfileCounter(profile)
      local table = {}
      local count = 0
      table = GetUsersByProfile(GetProfileName(profile))
      for i,User in pairs(table) do


if GetItemByName(User) then
   count = count + 1

end

     end

     return count
end



Hope that helps :)
Title: Re: Need Help please with script
Post by: electronic_Psycho on 01 April, 2007, 01:57:32
Hello and Thanks allot "CrazyGuy" for trying help me  :)

i post the line that u give me but the same error show up again. only in diffrent line. 28' this time

but the same error.

----
:28: bad argument #1 to 'pairs' (table expected, got nil)
-----

i post here all the script [original] maybe its help to see all the problem ..

------------------------------------------------------------------------------------------------
----//   Loggin by TiMeTrAVelleR Fixed By Optimus //-------------[infected-System]
----------------------------- Converted to Lua 5 by jiten------------------------
----//  Mor status & edit by: ElecTronic??.Psycho! //----------------
------------------------------------------------------------------------------------------------
----// Set here your bot name

sBotName = ".???iN-System???."

kb = 1024
mb = kb*kb
gb = kb*kb*kb
tb = kb*kb*kb*kb

function NewUserConnected(user)
   Message(user)
end

function OpConnected(user)
   Message(user)
end

--// Profile Counter
     
function ProfileCounter(profile)
   
      local table, count = GetUsersByProfile(profile),0
      for i,User in pairs(table) do
      

       if GetItemByName(User) then
            count = count + 1

       end

     end

     return count
end

function Message(user)
   if user.sMyInfoString then
   local disp = ""
      doGetProfile = GetProfileName(user.iProfile) or "Not registerd"
      hubshare = string.format("%0.2f", frmHub:GetCurrentShareAmount()/(1024)/(1024)/(1024)/(1024))
      local _,_,share = string.find(user.sMyInfoString, "^%$MyINFO %$ALL [^ ]+ [^$]*%$ $[^$]+[^$]%$[^$]*%$%s*(%d+)%$" )
      if share then
         minshare = string.format("%0.2f", tonumber(share)/gb).." GB"
      else
         minshare = "Corrupt"
      end
   end

border1 = "01"
border2 = "02"
disp = "\r\n\r\n"..border1.."\r\n"

disp = disp.."03\r\n"

disp = disp.."04\r\n"

disp = disp.."05\r\n"

disp = disp.."06\r\n"

disp = disp.."07\r\n"

disp = disp.."08\r\n"

disp = disp.."09\r\n"
disp = disp.."Welcome:  "..user.sName.."\r\n"

disp = disp.."Your  Status is: "..doGetProfile .."\r\n"

disp = disp.."Your IP is:  "..user.sIP.."\r\n"
disp = disp.."Your Share is: "..minshare.."\r\n"
disp = disp.."Hub MinShare is: 20 ' GB!\r\n"
disp = disp.."Hub MinSlots is: 3 ' oPen Slot's..\r\n"

disp = disp.."Actual Share in the Hub is :. ".. hubshare.." TiB\r\n"

disp = disp.."There are Now: "..frmHub: GetUsersCount().." of "..frmHub:GetMaxUsers().." users Online. .\r\n"
disp = disp.."There are : "..ProfileCounter("Netfounder").." [Hub-oWner] - "..ProfileCounter("Master").." [Master's] - "..ProfileCounter ("Operator").." [oP's] - "..ProfileCounter("Moderator").." [-S-Vip's] - "..ProfileCounter("Vip").." [Vip's] - "..ProfileCounter("reg").." [reg's] online .  . .\r\n"

disp = disp.."Hub Share oNly!: "..frmHub: GetHubDescr().."\r\n"

disp = disp.."10\r\n"..border2.."\r\n"

   user:SendData(sBotName, disp)

end
Thanks allot to all of you!  :)

i need very much that script..

i renew my hub to latest px > PX 0.3.5.2g1 and LV 3.1

in other px i dont have this problem. i use with px 3.5.1 and RCv10.023

i hope that someone can help me..
Thanks allot!
Title: Re: Need Help please with script
Post by: Madman on 01 April, 2007, 09:30:17

disp = disp.."There are : "..ProfileCounter("Netfounder").." [Hub-oWner] - "..ProfileCounter("Master").." [Master's] - "..ProfileCounter ("Operator").." [oP's] - "..ProfileCounter("Moderator").." [-S-Vip's] - "..ProfileCounter("Vip").." [Vip's] - "..ProfileCounter("reg").." [reg's] online .  . .\r\n"


I think here is the problem. Do you have all those profiles?
Title: Re: Need Help please with script
Post by: electronic_Psycho on 01 April, 2007, 15:19:15
Hello and Thanks "Madman" Thanks to all of you.

i find The problem.

Other script made the problem  :-[

Thanks Again.

Have a good Day.
---
Electronic PsyCho.
-----