Valhalla Legends Forums Archive | Battle.net Bot Development | Greet Change Help plz

AuthorMessageTime
MaDDoG(DA1)
I need help getting my greet to change by command heres what im tring but it wont work. plz help.


[code]'####Greet
If Left(Message, Len(varBotTrigger) + 3) = varBotTrigger & "greet" Then
If username = varMaster Then Bot_Settings.txtGreet.Text = Mid(Message, 6)
If username = varMaster Then CleanSlateBot1.Send "Greet Message Changed"
If username = varMaster Then AddChat rtbChat, varUsername & ": Greet Changed" & vbNewLine, vbWhite
End If
'=================================================================================[/code]
January 19, 2005, 2:08 AM
R.a.B.B.i.T
Len("greet") != 3
January 19, 2005, 4:21 AM
HdxBmx27
If I may make a suggestion. If you are making more than 1 command, it would be better to use a select case. As such:
[code]
If Left(Message, Len(varBotTrigger)) then
  Dim CMD as string
  CMD = Split(Message & Space(1), Space(1))(0)
  CMD = Mid(CMD, Len(varBotTrigger) + 1)
  Select case LCase(CMD)
      'INSERT CASES HERE
  End Select
End If[/code]
This could be better, But Let me explain it to you. #1 the If statement, It checks to see if the bot's trigger is the 1st part of the message. Then The Split(), That Spits out the 1st word in the message, (determined by a space). Then the Mid() Cuts off the trigger from the CMD, then Select Case LCase(CMD) starts a select case of the LOWERCASE ver of the CMD, This makes it so that commands are case InSensitive.
Then you jsut add Cases between teh Select Case & End Select such as [code]Case "greet"
  If username = varMaster Then
      Bot_Settings.txtGreet.Text = Mid(Message, 6)
      CleanSlateBot1.Send "Greet Message Changed"
      AddChat rtbChat, varUsername & ": Greet Changed" & vbNewLine, vbWhite
  End If[/code]
note: "greet" is lower case, it must be lower case to work becase of the LCase(CMD).
note2: i combined your 3 if statements into 1
note3: cases dont need end case, just end select.

also as FoFo stated "greet" = 5 not 3
~-~(HDX)~-~
January 19, 2005, 4:50 AM
MaDDoG(DA1)
Thanks i will try it as soon as i get hom from school.
January 19, 2005, 2:10 PM

Search