PtokaX forum

Development Section => Your Developing Problems => Topic started by: kepp on 21 February, 2004, 22:51:55

Title: Syntax Error: attempt to perform arithmetic on a nil value ?
Post by: kepp on 21 February, 2004, 22:51:55
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
Title:
Post by: [NL]Pur on 21 February, 2004, 22:57:22
what do you use too get the share?
Title:
Post by: kepp on 21 February, 2004, 23:00:00
local s,e,share = strfind(MyI,"%$(%d+)%$")

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

Title:
Post by: kepp on 21 February, 2004, 23:09:58
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
Title:
Post by: Stravides on 21 February, 2004, 23:14:02
in testdrive 4 isnt the guest profile 5 not -1 ?
seem to remember some problem with dc and dc++ users ...
Title:
Post by: kepp on 21 February, 2004, 23:16:08
well, I dont know how you have your profiles..

i have the original!

-1 = Unreg 3 = reg 2 = vip 1 = op 0 = master
Title:
Post by: kepp on 21 February, 2004, 23:41:51
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
Title:
Post by: kepp on 21 February, 2004, 23:49:37
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
Title:
Post by: tezlo on 22 February, 2004, 02:14:29
whenever you add, substract, multiply or divide (by) a nil value
always check after a strfind.. thats most likely why you get the error
Title:
Post by: kepp on 22 February, 2004, 09:31:10
Thanks, makes it so much easier
Title:
Post by: [NL]Pur on 22 February, 2004, 12:31:39
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.
Title:
Post by: NightLitch on 22 February, 2004, 12:57:43
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
Title:
Post by: kepp on 22 February, 2004, 14:22:51
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