• Welcome to Valhalla Legends Archive.
 

[VB6] Bugged up Code

Started by Anubis, July 14, 2004, 05:23 PM

Previous topic - Next topic

Anubis

I'm attempting to make an "!own whatever*" function that's similar to Flawed Bot's "!own". I wrote up the code and a few days ago it worked great, but now it's not working. It gets to a point in the function and then just leaves the function and goes back to the previous function (the function that was called before DoOwn(), which was CSB_UserJoin()).

I have marked the line below with '#####<<< where the code is just stopping in the function. (It stops right after running the code on that line.)

Public Function DoOwn(Username, Optional Why = "")
On Error GoTo Err
'Dim OwnedAttempt
If Owning = 1 Then OwnedAttempt = 1: OwnedNext = Username: OwnedNextWhy = Why: Exit Function
Dim i As Integer, OwnMsg(3) As String, J As Integer, K
Owning = 1
frmMain.timQueue.Enabled = False '### Freeze the normal queue
Queue = 1 '#####<<<
RunAgain:
Pause 5000 '8000
Username = WCPrep(Username)
Next2:


Hopefully there's something I'm missing here...I'd hate to think I need to rewrite the function again =/

I have tried many different values for Username and it doesnt seem to change the result. Also, Queue is dclared as "Public Queue".

All help is appreciated. Thanks!

hismajesty

Eww, your tab key is being denied pleasure. :(

Anubis

Quote from: hismajesty[yL] on July 14, 2004, 05:58 PM
Eww, your tab key is being denied pleasure. :(

haha... I used the tab key a lot in that function, just not in thet part of it...;)

MyndFyre

What does "!own" do, specifically?
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

Anubis

Quote from: Myndfyre on July 14, 2004, 06:02 PM
What does "!own" do, specifically?

Basically, if you have a lot of users/bots join the channel with the same name (such as bob#500, bob#265, bob#600, ect) you can ban them 4 at a time by typing "!own bob*".

ChR0NiC

#5
Quote from: Anubis on July 14, 2004, 05:23 PM
Hopefully there's something I'm missing here...I'd hate to think I need to rewrite the function again =/

Such a function is not hard to write // rewrite.
That is.....if you bothered to learn the language correctly....

For example

Public Sub DoOwn(WildCard As String)

Dim UsersToBan() As String, BanCount As Integer
Dim Wildcard2 As String
Wildcard2 = Left(Wildcard, Len(Wildcard) - 1) 'To get rid of the *

For i = 1 To ChannelList.ListItems.Count 'I think
If Wildcard2 Like ChannelList.ListItems(i).text Then
UsersToBan(UBound) = ChannelList.ListItems(i).text
ReDim Preserve UsersToBan(UBound(UsersToBan) + 1)
End If
Next i

'So far you have added all the users that fit the wildcard description to an array
'Next you will ban all of them without flooding out

For i = 0 To UBound(UsersToBan)

Send "/ban " & UBound(UsersToBan)
BanCount = BanCount + 1

If BanCount => 4 Then
Pause 5000
BanCount = 0
End If

Next i

End Sub


Well again it's untested code and I wrote it in a hurry, but that should be what you are looking for, with your little "own" command that was made by Fleet, which I find isn't any faster due to the delay afterwards, compared to any efficient queue system.

MyndFyre

Quote from: ChR0NiC on July 15, 2004, 06:48 PM
Well again it's untested code and I wrote it in a hurry, but that should be what you are looking for, with your little "own" command that was made by Fleet, which I find isn't any faster due to the delay afterwards, compared to any efficient queue system.

I agree.  An efficient queue system should ban floods just as well as this "own" command, particularly if you either 1.) enable channel protection, which just walks down the list of users in the channel, or 2.) use wildcards to ban.
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

Adron

Quote from: Anubis on July 14, 2004, 05:23 PM
It gets to a point in the function and then just leaves the function and goes back to the previous function (the function that was called before DoOwn(), which was CSB_UserJoin()).

Do you happen to have "On Error Resume Next" in CSB_UserJoin? It sounds like you're handling an error you shouldn't be handling.

Anubis

#8
I went to retest the code again today and now it's not even reaching the load-detecting function.

If Username = LUser Then GoTo EndV
LUser = Username
frmMain.RoomList.ListItems.Add , , Username, , GetIconCode(Message, Flags)
frmMain.RoomList.ListItems(frmMain.RoomList.ListItems.Count).ListSubItems.Add , , , GetLagIcon(Ping, Flags)
frmMain.RoomList.ListItems(frmMain.RoomList.ListItems.Count).ListSubItems.Add , , Ping
frmMain.RoomList.ListItems(frmMain.RoomList.ListItems.Count).ListSubItems.Add , , Val(frmSettings.txtIdleKicks)
frmMain.lblChannel.Caption = msChannelName & " (" & frmMain.RoomList.ListItems.Count & ")"
lstProducts.AddItem Message 'It exits the function right after this
'And it exits the function even if I put GoTo EndV on this line
EndV:
If frmSettings.chkDingWhenUserJoins.Value = 1 Then Beep


So what fried now? heh

IIRC I had a problem similar to this before... I was using Microsoft Scripting Runtime for the FileSystemObject, and I used the object so many times in the project that I had to add another FileSystemObject (such as FSO and FSO2). Could it be that I have over-done the 'GoTo' labels?

And yes I got the idea from Flawed Bot, but I want to make my own instead of copy/pasting ;)


Edit: I found this new bug when I was checking with the 'On Error Resume Next's... I reset everything back to the way it was and has had no change.