Valhalla Legends Archive

Programming => Battle.net Bot Development => Topic started by: blinkdude on July 15, 2003, 12:24 AM

Title: If statement help
Post by: blinkdude on July 15, 2003, 12:24 AM
My if statement is wrong i know :/ i trying to see who has flags "2" in the channel and gives them the "OP" icon

Private Sub CleanSlateBot1_UserInChannel(ByVal Username As String, ByVal Flags As Long, ByVal Message As String, ByVal Ping As Long, ByVal Product As String, StatUpdate As Boolean, SimulatedEvent As Boolean)

Dim MyItem As ListItem
Set MyItem = ListView1.ListItems.Add()

If Username(Flags) = 2 Then
MyItem.SmallIcon = 1

MyItem.Text = Username
MyItem.SubItems(1) = Ping & " ms"
Else
Select Case Product
Case "WAR3": MyItem.SmallIcon = 13
Case "D2DV": MyItem.SmallIcon = 12
Case "STAR": MyItem.SmallIcon = 8
Case "D2XP": MyItem.SmallIcon = 12
Case "SEXP": MyItem.SmallIcon = 11
Case "W2BN": MyItem.SmallIcon = 9
Case "TAHC": MyItem.SmallIcon = 10
Case "W3XP": MyItem.SmallIcon = 10
End Select
MyItem.Text = Username
MyItem.SubItems(1) = Ping & " ms"


End If
End Sub
Title: Re:If statement help
Post by: blinkdude on July 15, 2003, 12:30 AM
n/m i got it :/

Private Sub CleanSlateBot1_UserInChannel(ByVal Username As String, ByVal flags As Long, ByVal Message As String, ByVal Ping As Long, ByVal Product As String, StatUpdate As Boolean, SimulatedEvent As Boolean)

Dim MyItem As ListItem
Set MyItem = ListView1.ListItems.Add()
If LCase(flags) = 2 Then
MyItem.SmallIcon = 1

MyItem.Text = Username
MyItem.SubItems(1) = Ping & " ms"
Else
Select Case Product
Case "WAR3": MyItem.SmallIcon = 13
Case "D2DV": MyItem.SmallIcon = 12
Case "STAR": MyItem.SmallIcon = 8
Case "D2XP": MyItem.SmallIcon = 12
Case "SEXP": MyItem.SmallIcon = 11
Case "W2BN": MyItem.SmallIcon = 9
Case "TAHC": MyItem.SmallIcon = 10
Case "W3XP": MyItem.SmallIcon = 10
End Select
MyItem.Text = Username
MyItem.SubItems(1) = Ping & " ms"

End If

End Sub
Title: Re:If statement help
Post by: Soul Taker on July 15, 2003, 12:42 AM
Why are you lcasing() a long?
Also, remove the two instances of

MyItem.Text = Username
MyItem.SubItems(1) = Ping & " ms"

and put it once outside the if statement.
And I strongly urge you use a bitwise comparison to determine the icon from flags.
Title: Re:If statement help
Post by: blinkdude on July 15, 2003, 12:45 AM
yes it takes a while to ban and my code is sloopy but it works :/ ... ip banning is so fun... :)
Title: Re:If statement help
Post by: Soul Taker on July 15, 2003, 12:47 AM
If you don't use a bitwise comparison, someone without UDP support will be able to dodge your IP bans.