Valhalla Legends Forums Archive | Battle.net Bot Development | Need help with this code...

AuthorMessageTime
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
July 31, 2003, 12:15 AM
DarkMinion
Because, you're sending the whole command...instead of everything after the ".say ", think about that.

Send(Mid(message, 6, Len(message) - 6))
July 31, 2003, 12:38 AM
Camel
Note that you don't need to pass the third paramater to Mid() unless you dont want the entire rest of the string.
July 31, 2003, 4:45 AM
Grok
Some more hints for you. One way of setting up a command parser/handler.
[code]
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
[/code]
July 31, 2003, 11:13 AM

Search