Valhalla Legends Forums Archive | Battle.net Bot Development | A Userlist problem I'm having

AuthorMessageTime
AntiSavior
I've got my bot set to add/remove people to my userlist and whatnot.. But when I load it the bot listens to everyone as if everyone is on my userlist with full access.. Somethings wrong with code btu I can't seem to figure out what

ElseIf intAccess >= 70 And Left((LCase(Message)), 5) = (strTrig & "find") Then

Thats what my commands start out as, and I've got intAccess = 300 -- Probably need mroe information on this but this is my first bot heh, so bare with me..
I've got a Public Sub (GetAccess) and all that good stuff..
July 14, 2004, 8:09 AM
Myndfyr
[quote author=AntiSavior link=board=17;threadid=7700;start=0#msg70317 date=1089792577]
I've got my bot set to add/remove people to my userlist and whatnot.. But when I load it the bot listens to everyone as if everyone is on my userlist with full access.. Somethings wrong with code btu I can't seem to figure out what

ElseIf intAccess >= 70 And Left((LCase(Message)), 5) = (strTrig & "find") Then

Thats what my commands start out as, and I've got intAccess = 300 -- Probably need mroe information on this but this is my first bot heh, so bare with me..
I've got a Public Sub (GetAccess) and all that good stuff..
[/quote]

I'm not sure how VB evaluates if-then expressions, but is there a chance that you have a command before this one that says something like, "If intAccess >= 25 And (some other subexpression) Then..."? If so, you might be be triggering the If intAccess >= value check in that block of code, and since something has already evaluated to true, you're skipping over the rest of the if statements.

The best thing to do is to get the command from the message, by perhaps splitting the message by spaces, and doing a Select Case on the first token of your message string. Then, for each case, check to see whether or not the user has appropriate access.

So, I'm not sure how to split in VB, but you could do something like this. Assume you have the first token in strToken.

[code]
Select Case strToken
Case ".find"
If intAccess >= 70 Then
' do validated stuff here.
End If
Case ".seen"
'etc.
Case Else
' do nothing?
End Select
[/code]
July 14, 2004, 8:31 AM
Lenny
Yes, VB does skip over the rest if one returns true in both "If Then" blocks and "Select Case" statements...
July 14, 2004, 8:48 AM
Adron
[quote author=Myndfyre link=board=17;threadid=7700;start=0#msg70319 date=1089793889]
[quote author=AntiSavior link=board=17;threadid=7700;start=0#msg70317 date=1089792577]
ElseIf intAccess >= 70 And Left((LCase(Message)), 5) = (strTrig & "find") Then
[/quote]

I'm not sure how VB evaluates if-then expressions, but is there a chance that you have a command before this one that says something like, "If intAccess >= 25 And (some other subexpression) Then..."? If so, you might be be triggering the If intAccess >= value check in that block of code, and since something has already evaluated to true, you're skipping over the rest of the if statements.
[/quote]

Like in every other language I know, it will only skip the rest of the if statements if the whole condition is true. So unless he has another if statement that doesn't match against message not being strTrig & "find", there's no problem.
July 14, 2004, 2:02 PM
Myndfyr
[quote author=Adron link=board=17;threadid=7700;start=0#msg70334 date=1089813756]
[quote author=Myndfyre link=board=17;threadid=7700;start=0#msg70319 date=1089793889]
[quote author=AntiSavior link=board=17;threadid=7700;start=0#msg70317 date=1089792577]
ElseIf intAccess >= 70 And Left((LCase(Message)), 5) = (strTrig & "find") Then
[/quote]

I'm not sure how VB evaluates if-then expressions, but is there a chance that you have a command before this one that says something like, "If intAccess >= 25 And (some other subexpression) Then..."? If so, you might be be triggering the If intAccess >= value check in that block of code, and since something has already evaluated to true, you're skipping over the rest of the if statements.
[/quote]

Like in every other language I know, it will only skip the rest of the if statements if the whole condition is true. So unless he has another if statement that doesn't match against message not being strTrig & "find", there's no problem.
[/quote]
Yeah, that was what I wasn't sure about. Thanks for the clarification, Adron.

Although, it still doesn't negate what I said about the rest of the construction. ;)
July 14, 2004, 8:25 PM
Adron
[quote author=Myndfyre link=board=17;threadid=7700;start=0#msg70382 date=1089836756]
Yeah, that was what I wasn't sure about. Thanks for the clarification, Adron.

Although, it still doesn't negate what I said about the rest of the construction. ;)
[/quote]

Absolutely not. I quoted the part I commented on, the rest was fine ;)

July 14, 2004, 10:47 PM
AntiSavior
Blah, sorry Adron, and Myndfyre lol I found the problem.. It had ntohing to do with my code, It just wasnt going to my Sub "GetAccess" I had, to check to see if the user is in the userlist first..
So basically all I had to do was "Call GetAccess" before any of my commands.. ;)

Thanks for the help though guys
July 14, 2004, 11:42 PM

Search