• Welcome to Valhalla Legends Archive.
 

A Userlist problem I'm having

Started by AntiSavior, July 14, 2004, 03:09 AM

Previous topic - Next topic

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..

MyndFyre

Quote from: AntiSavior on July 14, 2004, 03:09 AM
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..

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.


Select Case strToken
 Case ".find"
   If intAccess >= 70 Then
     ' do validated stuff here.
   End If
 Case ".seen"
  'etc.
 Case Else
  ' do nothing?
End Select
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.

Lenny

Yes, VB does skip over the rest if one returns true in both "If Then" blocks and "Select Case" statements...
The Bovine Revolution
Something unimportant

Live Battle.net:

WARNING: The preceding message may have contained content unsuitable for young children.

Adron

Quote from: Myndfyre on July 14, 2004, 03:31 AM
Quote from: AntiSavior on July 14, 2004, 03:09 AM
ElseIf intAccess >= 70 And Left((LCase(Message)), 5) = (strTrig & "find") Then

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.

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.

MyndFyre

#4
Quote from: Adron on July 14, 2004, 09:02 AM
Quote from: Myndfyre on July 14, 2004, 03:31 AM
Quote from: AntiSavior on July 14, 2004, 03:09 AM
ElseIf intAccess >= 70 And Left((LCase(Message)), 5) = (strTrig & "find") Then

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.

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.
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.  ;)
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: Myndfyre on July 14, 2004, 03:25 PM
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.  ;)

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


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