• Welcome to Valhalla Legends Archive.
 

Need help with this code...

Started by OuTLawZGoSu, July 30, 2003, 07:15 PM

Previous topic - Next topic

OuTLawZGoSu

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

DarkMinion

Because, you're sending the whole command...instead of everything after the ".say ", think about that.

Send(Mid(message, 6, Len(message) - 6))

Camel

Note that you don't need to pass the third paramater to Mid() unless you dont want the entire rest of the string.

Grok

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