ironic but help with dc++ check
Moderator: Moderators
ironic but help with dc++ check
hiya, doing a dc++ check for slots -hubs
however can i get anyversion to run?????? NOPE can i helll
for some reason when it comes to checking slot against hubs
i get Microsoft VBScript runtime error: Overflow
for If (cdbl(sTmp)/iCHubs) < SlotHubs Then in otherwords
it wont calculate slots divided by hubs = less than slot per hub
here is full code for my dc++ checking
If NOT curUser.bOperator then 'if they aint an op
sDCI = sCurData
For x = 1 To 2
sDCI = AfterFirst(sDCI, "$")
Next
If CheckDcpp Then 'if allow DC++ box is ticked
sDCI = sCurData
For x = 1 To 2
sDCI = AfterFirst(sDCI, "$")
Next
If InStr(1, sDCI, "<++ V:") > 1 Then
sDCI = AfterFirst(sDCI, "<++ V:")
sDCI = AfterFirst(sDCI, "H:")
sTmp = BeforeFirst(sDCI, ">")
If InStr(1, sTmp, ",") Then sTmp = BeforeFirst(sTmp, ",")
iCHubs = CDbl(sTmp)
sDCI = AfterFirst(sDCI, "S:")
sTmp = BeforeFirst(sDCI, ">")
If InStr(1, sTmp, ",") Then sTmp = BeforeFirst(sTmp, ",")
If iCHubs > Mhubs Then
curUser.SendChatMessage CStr(botname), "Your in too many hubs the limit is " & Mhubs & ". Disconnect from some hubs and try again."
frmHub.DoEventsForMe
curUser.Disconnect
End If
End If
If (cdbl(sTmp)/iCHubs) < SlotHubs Then
curUser.SendChatMessage CStr(botname), "You have too few slots to connect here. You must have at least " & SlotHubs & " slots for each hub that you connect. Open some more slots or disconnect from some hubs and try again."
frmHub.DoEventsForMe
curUser.Disconnect
End If
End If
If InStr(1,sDCI,"<++ V:") > 1 Then
curUser.SendChatMessage cstr(botname), "An attempt to fake your description line was detected. Nice try lamer. Goodbye!"
frmHub.DoEventsForMe
curUser.Disconnect
End If
End If [/code][/quote]
however can i get anyversion to run?????? NOPE can i helll
for some reason when it comes to checking slot against hubs
i get Microsoft VBScript runtime error: Overflow
for If (cdbl(sTmp)/iCHubs) < SlotHubs Then in otherwords
it wont calculate slots divided by hubs = less than slot per hub
here is full code for my dc++ checking
If NOT curUser.bOperator then 'if they aint an op
sDCI = sCurData
For x = 1 To 2
sDCI = AfterFirst(sDCI, "$")
Next
If CheckDcpp Then 'if allow DC++ box is ticked
sDCI = sCurData
For x = 1 To 2
sDCI = AfterFirst(sDCI, "$")
Next
If InStr(1, sDCI, "<++ V:") > 1 Then
sDCI = AfterFirst(sDCI, "<++ V:")
sDCI = AfterFirst(sDCI, "H:")
sTmp = BeforeFirst(sDCI, ">")
If InStr(1, sTmp, ",") Then sTmp = BeforeFirst(sTmp, ",")
iCHubs = CDbl(sTmp)
sDCI = AfterFirst(sDCI, "S:")
sTmp = BeforeFirst(sDCI, ">")
If InStr(1, sTmp, ",") Then sTmp = BeforeFirst(sTmp, ",")
If iCHubs > Mhubs Then
curUser.SendChatMessage CStr(botname), "Your in too many hubs the limit is " & Mhubs & ". Disconnect from some hubs and try again."
frmHub.DoEventsForMe
curUser.Disconnect
End If
End If
If (cdbl(sTmp)/iCHubs) < SlotHubs Then
curUser.SendChatMessage CStr(botname), "You have too few slots to connect here. You must have at least " & SlotHubs & " slots for each hub that you connect. Open some more slots or disconnect from some hubs and try again."
frmHub.DoEventsForMe
curUser.Disconnect
End If
End If
If InStr(1,sDCI,"<++ V:") > 1 Then
curUser.SendChatMessage cstr(botname), "An attempt to fake your description line was detected. Nice try lamer. Goodbye!"
frmHub.DoEventsForMe
curUser.Disconnect
End If
End If [/code][/quote]
ashes to ashes, dust to dust, if the dope dont get you. The acid must
-
- Posts: 210
- Joined: 2003-01-23 17:24
- Location: Nevada
- Contact:
Slots divided by hubs is a tricky thing to do, because if it's an OP only connected to your hub, you'll end up with a division by 0 (since the dc++ tag will show them with H:0). Same if it's someone registered in the all the hubs they're connected to (whether they're an OP in these hubs or not, actually)
-----
Also, in case it is the whole code for your dc++ checking, you don't assign any value to Mhubs anywhere, so it will be an empty variable.
-----
Finally,
is exactly the same as :
-----
Also, in case it is the whole code for your dc++ checking, you don't assign any value to Mhubs anywhere, so it will be an empty variable.
-----
Finally,
Code: Select all
If NOT curUser.bOperator then 'if they aint an op
sDCI = sCurData
For x = 1 To 2
sDCI = AfterFirst(sDCI, "$")
Next
If CheckDcpp Then 'if allow DC++ box is ticked
sDCI = sCurData
For x = 1 To 2
sDCI = AfterFirst(sDCI, "$")
Next
Code: Select all
If CheckDcpp And Not curUser.bOperator Then
sDCI = sCurData
For x = 1 To 2
sDCI = AfterFirst(sDCI, "$")
Next
yeah that was a mistake
i know about the iDC thing, and it was fixed it was just cos i was chopping and pasting from another txt file were i had 4 diff versions of dc++ check going
i decided to do away with slots against hubs
and went with slot ratio
so for 1 hub u need 1 slot
however
lol max hubs aint working now
so i have peeps with like 100 hubs 100 slots, strange thing is
if it aint getting the hub amount, then this wouldent be working
but it is?????
lol
so
i know about the iDC thing, and it was fixed it was just cos i was chopping and pasting from another txt file were i had 4 diff versions of dc++ check going
i decided to do away with slots against hubs
and went with slot ratio
so for 1 hub u need 1 slot
however
lol max hubs aint working now
so i have peeps with like 100 hubs 100 slots, strange thing is
if it aint getting the hub amount, then this wouldent be working
but it is?????
lol
so
ashes to ashes, dust to dust, if the dope dont get you. The acid must
-
- Posts: 210
- Joined: 2003-01-23 17:24
- Location: Nevada
- Contact:
If at the time you check "If iCHubs > Mhubs", both variables are equal to 0. Then "If 0 > 0 " will always be False, and it will workso i have peeps with like 100 hubs 100 slots, strange thing is
if it aint getting the hub amount, then this wouldent be working
but it is?????
Also, remember that for comparison operators :
- If one expression is numeric and the other is a string then the numeric expression is less than the string expression.
- If one expression is Empty and the other is numeric, then a numeric comparison is performed, using 0 as the Empty expression.
- If one expression is Empty and the other is a string, then a string comparison is performed, using a zero-length string ("") as the Empty expression
As you can see, many cases can lead to this expression being false, even if you aren't getting the hub amount.
-----
How about you paste just 1 version of the checking script and we see from there ? (with the If/End If indented, it would be nice =)
If might be faster to do this...it's also easier to add new things )
Code: Select all
'Assuming you've parsed out the dc++ tag (called sTag)
'sTag = <++ V:*,M:*,H:*,S:*>
Dim aTag, ub
sTag = Mid$(sTag, 5)
sTag = Left$(sTag, InStr(1, sTag, ">") - 1)
aTag = Split(sTag, ",")
For i = 0 To 3
aTag(i) = Mid$(aTag(i), 3)
Next
'aTag(0) = Version
'aTag(1) = Mode
'aTag(2) = Hubs
'aTag(3) = Slots
ub = UBound(aTag)
If ub > 3 Then
For i = 4 To ub
Select Case Left(aTag(i), 1)
Case "L", "B"
'aTag(i) = Bandwidth limiter
End Select
Next
End If
-
- Posts: 5
- Joined: 2003-03-02 01:50
RegExps
Ripping off the last post a bit, this might be a more adaptable way to pull out tag info; the RegExps match the data pretty easily, rather than depending on the position of the information.
[/code]
Code: Select all
'Assuming you've parsed out the dc++ tag (called sTag)
'sTag = <++ V:*,M:*,H:*,S:*>
Dim slotsre, hubsre, numre
Set slotsre = new regexp
Set hubsre = new regexp
Set numre = new regexp
' isolate the tag with it's corresponding number
slotsre.Pattern = "S:[0-9]+[^0-9]" ' Hub "H:" tag
hubsre.Pattern = "H:[0-9]+[^0-9]" ' Slot "S:" tag
' ... etc ...
' isolate the numbers from the fields
numre.Pattern = "[0-9]+"
Dim numhubs, numslots
' apply the above-defined Regular Expressions to the description tag string
numhubs = CInt(numre.execute(hubsre.execute(sTag)(0).Value)(0).Value) + 1
numslots = CInt(numre.execute(slotsre.execute(sTag)(0).Value)(0).Value)
Dim DppMaxHubs, DppMinSlots, DppMaxSlots, sBotName
Sub Main()
DppMaxHubs = "5"
DppMinslots = "2"
dppmaxslots = "10"
sBotName = "Hub-Security"
End Sub
Sub DataArival(curUser, sCurData)
If InStr(1, LCase(sCurData), LCase("$GetINFO "+curUser.sName+" "+curUser.sName))>0 then
'EXTRACT USERS INFO
iTheirInfo = curUser.sMyInfoString
iTheirFileDescription = BeforeFirst(AfterFirst(AfterFirst(iTheirInfo,"$ALL ")," "),"$")
Dim dpphubs, dppslots, dppversion
If InStr(1, CStr(iTheirFileDescription), CStr("<++ V:"), vbTextCompare) = 0 Then
dppversion = 1.0091
dpphubs = "Neo-Modus"
dppslots = "DC"
Else
dppversion = BeforeFirst(AfterLast(CStr(iTheirFileDescription), "<++ V:"), ",")
dpphubs = BeforeFirst(AfterLast(CStr(iTheirFileDescription), "H:"), ",")
dppslots = BeforeFirst(AfterLast(CStr(iTheirFileDescription), "S:"), ">")
If InStr(1, CStr(dppslots), CStr("L:"), vbTextCompare) > 0 Or InStr(1, CStr(dppslots), CStr("B:"), vbTextCompare) > 0 Then
curUser.PrivateMessage sBotName, "Bandwith limiter clients not allowed in this hub."
frmHub.DoEventsForMe
curUser.Kick
Exit Sub
End If
If InStr(1, CStr(dppslots), CStr(","), vbTextCompare) > 0 Then
dppslots = BeforeFirst(CStr(dppslots), ",")
End If
If Int(dpphubs) > Int(DppMaxHubs) And ms = 0 Then
curUser.PrivateMessage sBotName, "" + CStr(DppMaxHubs) + " hubs max here. Your in " + CStr(dpphubs) + " hubs."
frmHub.DoEventsForMe
curUser.Kick
Exit Sub
End If
If Int(dpphubs) >= 1 Then
If (Int(dppslots) / Int(dpphubs)) < Int(DppMinSlots) Then
curUser.PrivateMessage sBotName, "" + CStr(DppMinSlots) + " slots per hub minimum here. Your only sharing " + CStr(Int(dppslots) / Int(dpphubs)) + " slots per hub."
frmHub.DoEventsForMe
curUser.Kick
Exit Sub
End If
End If
If Int(dppslots) > Int(DppMaxSlots) Then
curUser.PrivateMessage sBotName, "" + CStr(DppMaxSlots) + " slots maximum here. You have " + CStr((dppslots)) + " slots open."
frmHub.DoEventsForMe
curUser.Kick
Exit Sub
End If
End Sub
Function BeforeFirst(sIn, sFirst)
BeforeFirst = Left(sIn, InStr(1, sIn, sFirst) - 1)
End Function
Function AfterFirst(sIn, sFirst)
AfterFirst = Right(sIn, Len(sIn) - InStr(1, sIn, sFirst) - (Len(sFirst) - 1))
End Function
Public Function AfterLast(sFrom, sAfterLast)
If InStr(1, sFrom, sAfterLast) Then
AfterLast = Right(sFrom, Len(sFrom) - InStrRev(sFrom, sAfterLast) - (Len(sAfterLast) - 1))
Else
AfterLast = ""
End If
End Function
just threw that together...hope it works
Sub Main()
DppMaxHubs = "5"
DppMinslots = "2"
dppmaxslots = "10"
sBotName = "Hub-Security"
End Sub
Sub DataArival(curUser, sCurData)
If InStr(1, LCase(sCurData), LCase("$GetINFO "+curUser.sName+" "+curUser.sName))>0 then
'EXTRACT USERS INFO
iTheirInfo = curUser.sMyInfoString
iTheirFileDescription = BeforeFirst(AfterFirst(AfterFirst(iTheirInfo,"$ALL ")," "),"$")
Dim dpphubs, dppslots, dppversion
If InStr(1, CStr(iTheirFileDescription), CStr("<++ V:"), vbTextCompare) = 0 Then
dppversion = 1.0091
dpphubs = "Neo-Modus"
dppslots = "DC"
Else
dppversion = BeforeFirst(AfterLast(CStr(iTheirFileDescription), "<++ V:"), ",")
dpphubs = BeforeFirst(AfterLast(CStr(iTheirFileDescription), "H:"), ",")
dppslots = BeforeFirst(AfterLast(CStr(iTheirFileDescription), "S:"), ">")
If InStr(1, CStr(dppslots), CStr("L:"), vbTextCompare) > 0 Or InStr(1, CStr(dppslots), CStr("B:"), vbTextCompare) > 0 Then
curUser.PrivateMessage sBotName, "Bandwith limiter clients not allowed in this hub."
frmHub.DoEventsForMe
curUser.Kick
Exit Sub
End If
If InStr(1, CStr(dppslots), CStr(","), vbTextCompare) > 0 Then
dppslots = BeforeFirst(CStr(dppslots), ",")
End If
If Int(dpphubs) > Int(DppMaxHubs) And ms = 0 Then
curUser.PrivateMessage sBotName, "" + CStr(DppMaxHubs) + " hubs max here. Your in " + CStr(dpphubs) + " hubs."
frmHub.DoEventsForMe
curUser.Kick
Exit Sub
End If
If Int(dpphubs) >= 1 Then
If (Int(dppslots) / Int(dpphubs)) < Int(DppMinSlots) Then
curUser.PrivateMessage sBotName, "" + CStr(DppMinSlots) + " slots per hub minimum here. Your only sharing " + CStr(Int(dppslots) / Int(dpphubs)) + " slots per hub."
frmHub.DoEventsForMe
curUser.Kick
Exit Sub
End If
End If
If Int(dppslots) > Int(DppMaxSlots) Then
curUser.PrivateMessage sBotName, "" + CStr(DppMaxSlots) + " slots maximum here. You have " + CStr((dppslots)) + " slots open."
frmHub.DoEventsForMe
curUser.Kick
Exit Sub
End If
End Sub
Function BeforeFirst(sIn, sFirst)
BeforeFirst = Left(sIn, InStr(1, sIn, sFirst) - 1)
End Function
Function AfterFirst(sIn, sFirst)
AfterFirst = Right(sIn, Len(sIn) - InStr(1, sIn, sFirst) - (Len(sFirst) - 1))
End Function
Public Function AfterLast(sFrom, sAfterLast)
If InStr(1, sFrom, sAfterLast) Then
AfterLast = Right(sFrom, Len(sFrom) - InStrRev(sFrom, sAfterLast) - (Len(sAfterLast) - 1))
Else
AfterLast = ""
End If
End Function
just threw that together...hope it works