Need Help please with script
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

Need Help please with script

Started by electronic_Psycho, 31 March, 2007, 06:02:29

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

electronic_Psycho

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..


Madman

my guess are that you are sending the profile number to the function. You should send the profilename
We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p

electronic_Psycho

#2
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,,

CrazyGuy

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 :)

electronic_Psycho

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!

Madman

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?
We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p

electronic_Psycho

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.
-----

SMF spam blocked by CleanTalk