Valhalla Legends Archive

Programming => Battle.net Bot Development => Topic started by: OuTLawZGoSu on July 30, 2003, 07:15 PM

Title: Need help with this code...
Post by: OuTLawZGoSu on July 30, 2003, 07:15 PM
If username = Form4.txtMaster.Text Then
If Left((LCase(message)), 5) = (Form4.txtTrigger.Text & "say "Then
saymessage = (Len(message) - 5)
Send (message)
End If
End If

Everytime i type in .say asdf, the bot sais .say asdf.
i cant get how to fix that. Anyone Help?

L8terZ
Title: Re:Need help with this code...
Post by: DarkMinion on July 30, 2003, 07:38 PM
Because, you're sending the whole command...instead of everything after the ".say ", think about that.

Send(Mid(message, 6, Len(message) - 6))
Title: Re:Need help with this code...
Post by: Camel on July 30, 2003, 11:45 PM
Note that you don't need to pass the third paramater to Mid() unless you dont want the entire rest of the string.
Title: Re:Need help with this code...
Post by: Grok on July 31, 2003, 06:13 AM
Some more hints for you.  One way of setting up a command parser/handler.

   Dim sCommand As String
   Dim sParam As String, sParam1 As String, sParam2 As String
   Dim lPos As Long
   lPos = InStr(1, message, Form4.txtTrigger.Text, vbTextCompare)
   If lPos = 1 And Len(message) > 1 Then
       sCommand = LCase(Split(Mid(message, 2), " ", 2)(0))
       sParam = Split(Mid(message, 2), " ", 2)(1)
       sParam1 = IIf(InStr(sParam, " ") > 0, Split(sParam, " ", 2)(0), "")
       sParam2 = IIf(InStr(sParam, " ") > 0, Split(sParam, " ", 2)(1), "")
       Select Case sCommand
       Case "say"
           If Len(sParam) > 0 Then Call QueueToSendProc(sParam)
       Case "join"
           If Len(sParam) > 0 Then Call QueueToSendProc("/join " & sParam)
       Case "ban"
           If Len(sParam1) > 0 Then
               Call QueueToSendProc("/ban " & sParam1 & IIf(Len(sParam2) > 0, " " & sParam2, " " & txtDefaultBanMessage.Text))
           End If
       Case "kick"
           If Len(sParam1) > 0 Then
               Call QueueToSendProc("/kick " & sParam1 & IIf(Len(sParam2) > 0, " " & sParam2, " " & txtDefaultBanMessage.Text))
           End If
       End Select
   End If