• Welcome to Valhalla Legends Archive.
 

Profile Request [VB]

Started by Sonic, March 08, 2004, 01:45 PM

Previous topic - Next topic

Sonic

For some reason whenever I request another users profile, it sets my profile to theirs. I'm not exactly sure why either, here's my code.

Request Profile Menu:

Private Sub mnuGetProfile_Click()
    frmProfile.txtName.text = frmMain.lvChannel.SelectedItem.text
    RequestProfile (lvChannel.SelectedItem.text)
End Sub


RequestProfile()

Public Function RequestProfile(strUser As String)
With pbuffer
.InsertDWORD 1
.InsertDWORD 4
.InsertDWORD &H26
.InsertNTString strUser
.InsertNTString "Profile\Sex"
.InsertNTString "Profile\Age"
.InsertNTString "Profile\Location"
.InsertNTString "Profile\Description"
.sendPacket &H26
End With
End Function


Now when I actually WANT to save my profile I have this:

On frmProfile:

Public Sub cmdSave_Click()
   OtherCode.SetProfile (txtName.text)
   Unload Me
End Sub


SetProflie()

Public Sub SetProfile(ByVal username As String)
With pbuffer
   .InsertDWORD 1
   .InsertDWORD 4
   .InsertNTString username
   .InsertNTString "profile\sex"
   .InsertNTString "profile\age"
   .InsertNTString "profile\location"
   .InsertNTString "profile\description"
   .InsertNTString frmProfile.txtSex.text 'Sex
   .InsertNTString frmProfile.txtAge.text 'Age
   .InsertNTString frmProfile.txtLocation.text 'Location
   .InsertNTString frmProfile.rtbDescription.text 'Description
   .sendPacket &H27
End With
End Sub


Any Suggestions?

Kp

Quote from: Sonic on March 08, 2004, 01:45 PMAny Suggestions?

I don't see anything wrong with your code to cause what you describe, but I do see some minor inconsistencies relative to the real clients.  In particular, they do not capitalize any letters in the profile key names.  Also, the clients request 5 keys, not 4.  The first four keys are as you requested (though lowercase); the fifth one is an empty string.  Its purpose is unknown, but for maximum compatibility, you should request it too.
[19:20:23] (BotNet) <[vL]Kp> Any idiot can make a bot with CSB, and many do!

PaiD

Only thing I can see that might be a problem might be that you used StrUser. I think if you also named that as your name to login to bnet that might cause a problem. (I am just saying this b/c you said it always sends your profile)

Sonic

Nope, by name to login isn't strUser, it's varUser. Thanks Kp, I made all uppercase letters lowercase and added the extra key. As far as I can tell, it works.

Sonic

#4
eh, nevermind..still gives same error.  :(

Edit: Oddly enough, it's working again...except now it won't set the profile when I need it to.

Edit #2: OK, I must have written self-tampering code, since it is doing the orgin error again. I have no clue why it's fixing/breaking itself though.

Kp

Quote from: Sonic on March 08, 2004, 03:52 PMeh, nevermind..still gives same error.  :(

Yes, was rather surprised to see you say it was working.  The changes I suggested have nothing to do with solving the immediate problem, only with making your client more realistic to the server. :P  Perhaps you should put a msgbox or an AddChat in the subroutine(s) which send out the set-profile command, so you can see what's causing them to be triggered?  (Or if you're comfortable with a debugger, put a breakpoint on those routines and view the call stack.  If you don't understand that last sentence, you aren't comfortable with a debugger. :))
[19:20:23] (BotNet) <[vL]Kp> Any idiot can make a bot with CSB, and many do!

Sonic

Kp: Not sure if you read after my second edit. Anyway, so my code is all correct and you don't know why it would be giving this error?

Kp

Quote from: Sonic on March 08, 2004, 04:42 PM
Kp: Not sure if you read after my second edit. Anyway, so my code is all correct and you don't know why it would be giving this error?

I had not seen those edits until I returned just now.  I do not write VB code (and therefore read it only moderately well), so I won't say with total certainty your code is flawless, especially since I haven't seen all of it.  As I said in my prior post, you should try adding print messages in the various subroutines to locate what's causing the call that sets the profile.
[19:20:23] (BotNet) <[vL]Kp> Any idiot can make a bot with CSB, and many do!

Sonic

OK, I'm really suprised/embarrased I didn't see this earlier. On frmProfile, in Form_Unload I called cmdSave. I thought that it woudln't do anything unless you're on that name so I added it as a convience thing since I'd rather click the x than save. After I removed that..it worked. Thanks for helping me make it more client-like and stuff.