Valhalla Legends Forums Archive | Battle.net Bot Development | Getting ping from module....

AuthorMessageTime
GoSu_KaOs
I got a problem with this. I need to get the ping, username, all that stuff from the module to Form1. My module looks like this:

[code]
Public Function DispatchMessage(ByVal databuf As String)

Dim EID As Long, Ping As Long, Username As String, message As String, Client As String, STATS As Long
EID = MakeLong(Mid$(databuf, 5, 4))
flags = MakeLong(Mid$(databuf, 9, 4))
Ping = MakeLong(Mid$(databuf, 13, 4))
Username = KillNull(Mid$(databuf, 29))
message = KillNull(Mid$(databuf, Len(Username) + 30))

If EID = lasteid And flags = lastflags And Ping = lastping And Username = lastusername And message = lastmessage Then Exit Function
lasteid = MakeLong(Mid$(databuf, 5, 4))
lastflags = MakeLong(Mid$(databuf, 9, 4))
lastping = MakeLong(Mid$(databuf, 13, 4))
lastusername = KillNull(Mid$(databuf, 29))
lastmessage = KillNull(Mid$(databuf, Len(Username) + 30))

Select Case EID

Case ID_JOIN
AddChat vbRed, Username & " has joined the channel with "  & Ping & "."

Case ID_USER
'blabla

Case ..ex.....
_______________________

[/code]

The problem is, I want to display the ping and username in Form1.
When I do this:

[code]
Private Sub cmdGetUsernameAndPing_Click()
AddC vbRed, Module2.DispatchMessage(Username)
AddC vbRed, Module2.DispatchMessage(Ping)
End Sub

'I also tryed this:

Private Sub cmdGetUsernameAndPing_Click()
AddC vbRed, Username
AddC vbRed, Ping
End Sub
[/code]

Neither way works. I just get a blank message.

What am I doin wrong?
April 18, 2005, 10:02 PM
The-FooL
In your first example, you can't call a function like that and expect it to return a variable from inside the function.  I have no idea what you think your doing.

As for the second example, if you work declare the variables in your module Global it should work.  But that really is not the way you should go about accomplishing whatever the hell it is your trying to do.
April 18, 2005, 10:06 PM
Yegg
I'm not sure how your code is supposed to work or what Form1 looks like, but can't you just declare the ping and the username, etc. as a public variable so it can be used it both the module and the form? Maybe you could even add them to ListBox's. Add a username to a list, its ping to a list, its flags to a list, etc. You would need a different ListBox for each piece of data, one for ping one for flags, for username, etc. FlagsList(0), PingList(0), UserList(0), etc. would all be for the same username. FlagsList(1), PingList(1), and so on would also be for the same username. I think you get the point. After the user has been added to Form1, if it is necessary you could just remove them from the list. Hope this helps.
April 18, 2005, 10:52 PM
GoSu_KaOs
[quote author=The-FooL link=topic=11320.msg109018#msg109018 date=1113861970]
In your first example, you can't call a function like that and expect it to return a variable from inside the function.  I have no idea what you think your doing.

As for the second example, if you work declare the variables in your module Global it should work.  But that really is not the way you should go about accomplishing whatever the hell it is your trying to do.
[/quote]

I'm trying to get the ping of the username that is in a listview. I wasnt clear int eh first post.
I need this: When I click on Command1, the ping of the selected username is shown. The username would be in a listview or textbox.
April 18, 2005, 11:25 PM
The-FooL
You won't be able to get the ping from the userjoin sub like that.  You will need to store the ping of the user in the list when you add them.  Then, in your getUsernameAndPing sub, find the selected user in the list and get the ping.
April 19, 2005, 1:38 AM
Networks
I am sorry, I just have to laugh at that...(chuckle). *sigh* Anyhow, I suggest you read a VB6 book or something because it's evident you don't know the language. I am not going to help you on this particular thing because you're going to end up coming back a million more times. So I suggest you learn your language.
April 19, 2005, 2:17 AM
GoSu_KaOs
If you get me a book named "Making a  bot for Battle.net" and I'll never come back here again. If you're not gonna help, don't post.
April 19, 2005, 1:20 PM
Yegg
Learning a language to make a bot is meaningless.
April 19, 2005, 1:42 PM
QwertyMonster
Gosu_kaos:

[code]
Case &HF
Ping = blah blah

Display me, vbGreen, Ping

[/code]

In your Form1. Simple.
April 19, 2005, 2:49 PM
HdxBmx27
Well, what you could do, Is simply store the Ping somewhere in the listview. AE the .tag attribute. Each object in a list view has it's own .Tag, jsut like it's own .Text. So start using it!
~-~(HDX)~-~
April 19, 2005, 3:09 PM
Quarantine
Or store the users in an array with other information (ping, flags, last talk time, etc..) which in the long run would prove to be more helpful.
April 19, 2005, 8:53 PM
Yegg
Correct me if I'm wrong. But wouldn't that be pretty similar to if you used a ListBox for the job? An array would be faster but earlier I suggested a ListBox and I guess he didn't do that.
April 19, 2005, 9:02 PM
LoRd
Once coded, a dynamic array would be much simpler, faster and better organized.
April 19, 2005, 9:31 PM
Quarantine
Yea, a listbox is nasty for storing data which constantly changes.


Consider the following

[code]
Public MyArr() as ArrStruct

Public Type ArrStruct
         Entry1 as String
         Entry2 as String
End Type

........


MyArr(SomeIndex).Entry1 = "Omgz"
[/code]
April 19, 2005, 10:43 PM

Search