Syntax Error: attempt to perform arithmetic on a nil value ?
 

Syntax Error: attempt to perform arithmetic on a nil value ?

Started by kepp, 21 February, 2004, 22:51:55

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

kepp

i get that error when i check Minimum share of a user...

here's a part of the procedure

ENABLESHARE = 1

MASTERMINSHARE 		= 0 * gb
OPMINSHARE 		= 0 * gb
VIPMINSHARE 		= 3 * gb
REGMINSHARE 		= 5 * gb
UNREGMINSHARE 		= 5 * gb

--and then in NewUserConnected()

	if ((ENABLESHARE==1)) then
		if tonumber(share)==nil then
			user:Disconnect()
		end
		if user.iProfile == -1 then
			if (tonumber(share) < UNREGMINSHARE) then
				UNREGMINSHARE = UNREGMINSHARE/1024/1024/1024
				user:SendPM(BOT,"You have not met the minimum share of "..format("%0.2f",UNREGMINSHARE).." GB")
				user:Disconnect()
		elseif user.iProfile == 3 then
			if (tonumber(share) < REGMINSHARE) then
				REGMINSHARE = REGMINSHARE/1024/1024/1024
				user:SendPM(BOT,"You have not met the minimum share of "..format("%0.2f",REGMINSHARE).." GB")
				user:Disconnect()
		elseif user.iProfile == 2 then
			if (tonumber(share) < VIPMINSHARE) then
				VIPMINSHARE = VIPMINSHARE/1024/1024/1024
				user:SendPM(BOT,"You have not met the minimum share of "..format("%0.2f",VIPMINSHARE).." GB")
				user:Disconnect()
					end
				end
			end
		end
	end

I can't seem to locate the problem :S
Please help, and comment out what's wrong, If there is something wrong that is :S

Thanks
Guarding    

[NL]Pur

what do you use too get the share?

kepp

#2
local s,e,share = strfind(MyI,"%$(%d+)%$")

I've also tried to make a if nil statement, but it won't work :(

Guarding    

kepp

it is weird though, When i try to connect with share or without It's working fine!

it seems that it triggers at some clients only
Guarding    

Stravides

#4
in testdrive 4 isnt the guest profile 5 not -1 ?
seem to remember some problem with dc and dc++ users ...
Stravides
For RPG Books, Mp3 & Videos
We host trivia  and the ever failing Smeagolbot

kepp

well, I dont know how you have your profiles..

i have the original!

-1 = Unreg 3 = reg 2 = vip 1 = op 0 = master
Guarding    

kepp

ok, i think i have found the problem

My infostring....   look at the share between $$
[23:39] 127.0.0.1:1657 > $MyINFO $ALL kepp2 <.P><++ V:0.306,M:P,H:2/0/0,S:8>$ $LAN(T1)$$19486511144$|

now, here's one from mldc

[23:38] 82.224.1.112:62381 > $MyINFO $ALL nylugj mldc client$ $DSL$$  11534336$|

a little gap...?? he
Guarding    

kepp

#7
ok, that didn't work either... ARGGHH

*EDIT*

ok, It has nothing to do with this procedure

i noticed that when i disable the min share in PtokaX i get this!

Syntax Error: attempt to perform arithmetic on a nil value

It's like looking for a nail in space!

So my question is, What does the error mean in plain english?
Can you give me an example(s) of why you get them?

Thanks
Guarding    

tezlo

whenever you add, substract, multiply or divide (by) a nil value
always check after a strfind.. thats most likely why you get the error

kepp

Thanks, makes it so much easier
Guarding    

[NL]Pur

i'm using atm this now too get the share out of the myinfo:

local s,e,share = strfind(user.sMyInfoString,"[$]+[^$]+[$]+[^$]+[$]+[^$]+[$]+[^$]+[$]+([^$]+)")
   
not mine btw :), i put the output with SendToAll on the
main, and i saw that about 80% is giving back the share
and the other 20% of the logging in clients return the mail adress.

This giving a error when using tonumber on a mailadress :(

i'm now not sure what the  correct regexp is and which clients are not holding too the protocol.

NightLitch

I use this one but now I get both the Speed & share

local _,_,vSpeed,sShare = strfind( MyInfo, "^%$MyINFO %$ALL [^ ]+ [^$]*%$ $([^$]+)[^$]%$[^$]*%$%s*(%d+)%$" )
   local vShare = tonumber(sShare)
 


And I find no problem with this one. but then again, have had many errors with many things ;-)

/NL
//NL

kepp

yes, i looked at yours too, Seems a bit too big though!! :P

well, the problem was not in the that procedure at all!

i use

s,e,share = strfind(user.sMyInfoString,"%$%s*(%d+)%$")

Since i found out about the space in mldc
Guarding    

SMF spam blocked by CleanTalk