Don't know why this is happening now...
 

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

Don't know why this is happening now...

Started by NightLitch, 19 November, 2003, 21:33:33

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

NightLitch

Hey Guys!

This is my error message:

Syntax error: bad argument #1 to `strfind' (string expected, got nil) stack traceback:
    1:  function `strfind' [C]
    2:  function `doParseMyInfo' at line 550 [file
`...:\Programs\0.330.b15.18.dbg\scripts\GR8-Bot.lua']
    3:  function `LogUserInfo' at line 856 [file
`...:\Programs\0.330.b15.18.dbg\scripts\GR8-Bot.lua']
    4:  function `NewUserConnected' at line 111 [file
`...:\Programs\0.330.b15.18.dbg\scripts\GR8-Bot.lua']


this is the first function and I have marked line 550...

function doParseMyInfo( sMyInfo )
	local sClient = "u" -- undefined
--550->	local sIsDcPlusplus,c,sDTagInfo = strfind( sMyInfo, "^%$MyINFO %$ALL [^ ]+ [^$]*<%+%+ ([^$<>]+)>%$" )
	local sIsDCGUI,c,sGTagInfo = strfind( sMyInfo, "^%$MyINFO %$ALL [^ ]+ [^$]*]+)>%$" )
	local sIsNMDC2,c,sNTagInfo = strfind( sMyInfo, "^%$MyINFO %$ALL [^ ]+ [^$]*]+)>%$" )
	local sIsOther,c,sSpeed,sShare = strfind( sMyInfo, "^%$MyINFO %$ALL [^ ]+ [^$]*%$ $([^$]+)[^$]%$[^$]*%$%s*(%d+)%$" )
	local sTagInfo
	local iShare = tonumber( sShare )
	if sIsNMDC2 then
			sTagInfo = sNTagInfo
			sClient = "n" -- NMDC v2
	elseif sIsDCGUI then
		sTagInfo = sGTagInfo
		sClient = "g" -- dcgui
	elseif sIsDcPlusplus then
		sTagInfo = sDTagInfo
		local sIsOdc,c,sOdcTag = strfind( sMyInfo, "^%$MyINFO %$ALL [^ ]+ [^$]*")
		local sFakeInfo = strfind( sMyInfo,"<%+%+ V:.*><%+%+ V:.*>")
		if sFakeInfo then 
			sClient = "f" --Faking dc++ tag
		elseif sIsOdc then
			sClient = "o" -- oDC
		else
			sClient = "d" -- DC++
		end
	elseif sIsOther then
		local sIsMLDC = strfind( sMyInfo, "mld" )
		if sIsMLDC then
			sClient = "m"
		end
		if sSpeed and iShare then
			return sClient, iShare, sSpeed, nil
		else
			return sClient, nil, nil, nil
		end
	else
		sClient = "f"-- fake
		return sClient, nil, nil, nil
	end
	local tFlags = {}
	sTagInfo = sTagInfo..","
	gsub( sTagInfo, "(.):([^,]+),", function( letter, value ) %tFlags[letter] = value ; end )
	if not tFlags["H"] or not tFlags["S"] or not tFlags["V"] or not tFlags["M"]then
		sClient = "f" -- fake
		return sClient, nil, nil, nil
	end
	if sClient == "n" then
		tFlags["H"] = doGetHubNumber(tFlags["H"], 3)
	elseif sClient == "d" then
		tFlags["V"] = tonumber(tFlags["V"])
		if tFlags["V"] and tFlags["V"] < 0.24 then
			tFlags["H"] = doGetHubNumber(tFlags["H"], 1)
		else
			tFlags["H"] = doGetHubNumber(tFlags["H"], 3)
		end
		if tFlags["H"] < 0 then
			sClient = "f"
		end
	elseif sClient == "g" then
		tFlags["H"] = doGetHubNumber(tFlags["H"], 1)
	elseif sClient == "o" then
		iVersion = tonumber(tFlags["V"])
		if iVersion < 0.24 then
			tFlags["H"] = doGetHubNumber(tFlags["H"], 1)
		else
			tFlags["H"] = doGetHubNumber(tFlags["H"], 3)
		end
		local sIsOdc,c,sOdcTag = strfind(sMyInfo , "^%$MyINFO %$ALL [^ ]+ [^$]*")
		tFlags["V"]=sOdcTag
		if tFlags["H"] < 0 then
			sClient = "f"
		end
	end
	return sClient, iShare, sSpeed, tFlags
end


this is line 856 function

function LogUserInfo(curUser,data)
	local sIni = ""
	sIni = sIni .. "\r\nsInfo = {}"
	nick = curUser.sName
	sIni = sIni .. "\r\nsInfo.NICK = \""..strlower(nick).."\""
	sIni = sIni .. "\r\nsInfo.IP = \""..curUser.sIP.."\""
	local level = GetProfileName(curUser.iProfile)
	if level == nil then level = "Unreg"
	else
	end
	sIni = sIni .. "\r\nsInfo.LEVEL =  \""..level.."\""
--856->	local sClient, iShare, sSpeed, tFlags = doParseMyInfo(curUser.sMyInfoString)
	if sClient == "d" then -- dcpp
		if tFlags["V"] == nil then
			sIni = sIni .. "\r\nsInfo.CLIENT = \"DC++\""
			sIni = sIni .. "\r\nsInfo.VERSION = \"N/A\""
		else
			sIni = sIni .. "\r\nsInfo.CLIENT = \"DC++\""
			sIni = sIni .. "\r\nsInfo.VERSION = \""..tFlags["V"].."\""
		end
	elseif sClient == "o" then -- odc
		if tFlags["V"] == nil then
			sIni = sIni .. "\r\nsInfo.CLIENT = \"oDC\""
			sIni = sIni .. "\r\nsInfo.VERSION = \"N/A\""
		else
			sIni = sIni .. "\r\nsInfo.CLIENT = \"oDC\"" 
			sIni = sIni .. "\r\nsInfo.VERSION = \""..tFlags["V"].."\""
		end
	elseif sClient == "n" then --nmdcv2
		if tFlags["V"] == nil then
			sIni = sIni .. "\r\nsInfo.CLIENT = \"Neo Modus DC 2\""
			sIni = sIni .. "\r\nsInfo.VERSION = \"N/A\""
		else
			sIni = sIni .. "\r\nsInfo.CLIENT = \"Neo Modus DC 2\"" 
			sIni = sIni .. "\r\nsInfo.VERSION = \""..tFlags["V"].."\""
		end
	elseif sClient == "f" then --Probably fakers
		if tFlags["V"] == nil then
			sIni = sIni .. "\r\nsInfo.CLIENT = \"Fake Clients or Undefined Client\""
			sIni = sIni .. "\r\nsInfo.VERSION = \"N/A\""
		else
			sIni = sIni .. "\r\nsInfo.CLIENT = \"Fake Clients or Undefined Client\"" 
			sIni = sIni .. "\r\nsInfo.VERSION = \""..tFlags["V"].."\""
		end
	elseif sClient == "g" then --dcgui
		if tFlags["V"] == nil then
			sIni = sIni .. "\r\nsInfo.CLIENT = \"DC Gui\""
			sIni = sIni .. "\r\nsInfo.VERSION = \"N/A\""
		else
			sIni = sIni .. "\r\nsInfo.CLIENT = \"DC Gui\"" 
			sIni = sIni .. "\r\nsInfo.VERSION = \""..tFlags["V"].."\""
		end
	elseif sClient == "u" then --Klients without tags
		if tFlags["V"] == nil then
			sIni = sIni .. "\r\nsInfo.CLIENT = \"Neo Modus DC 1 or Client Without TAG\""
			sIni = sIni .. "\r\nsInfo.VERSION = \"N/A\""
		else
			sIni = sIni .. "\r\nsInfo.CLIENT = \"Neo Modus DC 1 or Client Without TAG\"" 
			sIni = sIni .. "\r\nsInfo.VERSION = \""..tFlags["V"].."\""
		end
	end
	if tFlags["S"] == nil then
		sIni = sIni .. "\r\nsInfo.SLOTS = \"N/A\""
	else
		sIni = sIni .. "\r\nsInfo.SLOTS = \""..tFlags["S"].."\""
	end
	if tFlags["H"] == nil then
		sIni = sIni .. "\r\nsInfo.HUBS = \"N/A\""
	else
		sIni = sIni .. "\r\nsInfo.HUBS = \""..tFlags["H"].."\""
	end
	if sSpeed == nil then
		sIni = sIni .. "\r\nsInfo.SPEED = \"N/A\""
	else
		sIni = sIni .. "\r\nsInfo.SPEED = \""..sSpeed.."\""
	end
	if tFlags["M"] == nil then
		sIni = sIni .. "\r\nsInfo.MODE = \"N/A\""
	else
		if tFlags["M"] == "A" then
			sIni = sIni .. "\r\nsInfo.MODE = \"Active\""
		else
			sIni = sIni .. "\r\nsInfo.MODE = \"Passive\""
		end
	end
	local i,j,temp = strfind(curUser.sMyInfoString, "$(%d+)%$")
	Share = format("%0.2f", tonumber(temp)/gb)
	sIni = sIni .. "\r\nsInfo.SHARE = \""..Share.." GB\""
	local _,_, Normals,Regs,Ops = strfind(curUser.sMyInfoString,"H:(%d+)/(%d+)/(%d+)")
	if curUser.iProfile == -1 then
		Normal = "Yes"
	else 
		Normal = "No"
	end
	if curUser.iProfile == 3 then
		Reg = "Yes"
	else
		Reg = "No"
	end	
	if curUser.iProfile == 2 then
		Vip = "Yes"
	else
		Vip = "No"
	end
	if curUser.iProfile == 1 then
		Op = "Yes"
	else
		Op = "No"
	end	
	if curUser.iProfile == 5 then
		Master = "Yes"
	else
		Master = "No"
	end
	if Normals~=nil and Regs~=nil and Ops~=nil then 
	sIni = sIni .. "\r\nsInfo.NORMALHUBS = \""..Normals.."\""
	sIni = sIni .. "\r\nsInfo.REGGEDHUBS = \""..Regs.."\""
	sIni = sIni .. "\r\nsInfo.OPERATHUBS = \""..Ops.."\""
	end
	sIni = sIni .. "\r\nsInfo.NORMALUSER = \""..Normal.."\""
	sIni = sIni .. "\r\nsInfo.REGGEDUSER = \""..Reg.."\""
	sIni = sIni .. "\r\nsInfo.VIPPEDUSER = \""..Vip.."\""
	sIni = sIni .. "\r\nsInfo.OPERATUSER = \""..Op.."\""
	sIni = sIni .. "\r\nsInfo.MASTERUSER = \""..Master.."\""

	--// Write to File
	writeto(SAVEINFO..""..curUser.sName..".txt") 
	write(sIni)
	writeto()
end

And 111 is just above function being loaded in NewUserConnected...

plz what could be wrong here... It's complaining on the marked
lines... why?? what is wrong...?

/NL
//NL

[ES]latinmusic

Hard to say since all the code is not posted. Anyway:
Forget line 856.
You are probably calling the function in wrong way so you are getting a nil value.
Your error lines, i mean:
Syntax error: bad argument #1 to `strfind' (string expected, got nil) stack traceback:
1: function `strfind' [C]

normal occurs when you make a little mistake like for instance:
You line is:
strfind( sMyInfo, *****)
and should be:
strfind( sData, ***** ) or strfind( data, ***** ) or strfind( args, ***** ) or whatever.
I hope this comment could be usefull, but i'm not sure at all, anyway perhaps this comment give you a few ideas.

NightLitch

the thing is...

It works without a problem on my hub with above codes...

But not on SErver-hub...


why I ask...

This is the way I call the function in Dataarrival
if(strsub(data, 1, 7) == "$MyINFO" and curUser.bOperator == nil) then
		if DCCHECK == "enable" then
			local sClient, iShare, sSpeed, tFlags = doParseMyInfo(data)

works great no prob. there...

Here's in NewUserConnected
local sClient, iShare, sSpeed, tFlags = doParseMyInfo(curUser.sMyInfoString)

But I get hung up on this line:

   local sIsDcPlusplus,c,sDTagInfo = strfind( sMyInfo, "^%$MyINFO %$ALL [^ ]+ [^$]*<%+%+ ([^$<>]+)>%$" )


is some data is nill:ed when checking DC++/oDC tags...

and it work great with my old script....

/NL
//NL

plop

are you running 0.3.3.0 nl ???
if so insert above line 550 a check for nil on the sMyInfo.
if nil then send an error.
it happens here 2 that on the beta the info string is sudenly gone.
allready posted about this in the beta treatd.

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

Optimus

Yups me having same problem here also. with the MyInfoString

Verry wierd. It only happens with the Latest BETA'S (12 and l8ter)

I even have blocked them off with ~= nil but some times it suddenly is there again.

It was alway's running ok. Please let's hope he's gone fix that. Don't like errors

NightLitch

Ok, Thx Guys... Good nowing you're here and helping me... :-D

This is what LUA Forum is all about... Helping and caring...

Thx /NL
//NL

plop

it's seems it's not there in the start but just 2 late.
[12:39] <-Bure-> Hello [TGA]plop. your are signing in classified as user, with a DSL connection! 
[12:39]  The minimum share for your class is set to: 0 Gb. 
[12:39]  You are currently sharing 87.65 Gb. 
[12:39]  The minimum number of open slots required for your class is set to: 1 
[12:39]  The maximum number of open slots required for your class is set to: 25 
[12:39]  You currently have 3 open slot(s). 
[12:39]  The minimum amount of upload bandwidth in kb/s required for your class is set to: 10 
[12:39]  You currently are sharing with a maximum kb/s upload restriction of: unlimited 
[12:39]  You are using Dc++ version 0.241 
[12:39]  You currently signed on to 3 hub(s) 
[12:39]  1 hub(s) as user, 0 hub(s) as registered user, 2 hub(s) as operator 
[12:39]  The maximum amount of hubs allowed is 25 
[12:39]  You may be in maximum 3 hub(s)
if it wouldn't be there @ all this wouldn't be shown @ all.
but as you can see it's there, while it does send out a load of errors that the string is not found.
for the moment i'm ignoring the error as dispite the error it is working like i want.
on testdrive it doesn't give any errors @ all.

optimus i had it from the 1st beta.

nl running a hub is caring for your users, for me scripting is the same.
the scripts take care of the users 2 in multiple way's.
making sure users folow the rules and helping them get the stuff they want.
the hub's share data, the forum shares information.

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

Optimus

Ok Plop IC, so there seems to be something wrong in the beta releases. let's hope it's gone be fixed soon. me was spending time looking for those errors. but it's just waste off time.

Fingers crossed, *lol*

NightLitch

Yeah speak of wasted time... :-p

Have tried 3-4 days to get this working but the same...

BUT how can I do a bypass then if NIL???

above ParseMyInfo is done by Skrollster and I don't wanna mess up the code... :-/

So give me a plain example how I can do it... If you guys
Have the time...

/NL
//NL

plop

place this on the 1st line of the function.
if sMyInfo then
but it will have the result that the function whill be skiped if it is nil @ that moment, while it can pop backup a milisec later.
you could parse the info string again if it is nil but it can result in a endless loop.

here is a simple function 2 check if the info string is there.
trigger it on a couple places in your script.
function CheckIfTagIsAvail(user)
   if user.sMyInfoString then
     s,e,tag = strfind(user.sMyInfoString, "<%S+%s*([!-z]*)>%$")
     user:SendPM(Bot, tag..date("%X"))
   else
      user:SendPM(Bot, "lost info string "..date("%X"))
   end
end
if it's found it sends the tag + time in pm, if not it shows the time and not found.
with something like this i found what was going on.

just been reading a bit on how the lua api works and if i get it right a stack is used 2 pass stuff from ptokax 2 the lua vm (and ofcourse the other way around).
if the info string is not in the stack there is an error (nil).
in this case 2 me it looks that the info string enters the stack 2 late or is unstable.

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

SMF spam blocked by CleanTalk