Author | Message | Time |
---|---|---|
Hidden | Hey guys, i'm having a real problem with ping, for some reason it doesn't wanna work. I have tried using Search but I couldn't find anything on it. Here is the function and command: [code]Function TPing(ByVal Username As String) As Long Dim strChannel As ListItem, Ping As Long Dim intListEnd As Integer, strCompare As String, intChecked As Integer intListEnd = UserCount + 1 intChecked = 1 For intChecked = 1 To intListEnd Dim l As Boolean On Error Resume Next strCompare = lvChannel.ListItems.Item(intChecked) Call PrepareCheck(strCompare) Dim UserCheck As String UserCheck = LCase(Username) Call PrepareCheck(UserCheck) l = LCase(strCompare) Like UserCheck If l = True Then Ping = lbPing.List(intChecked - 1) TPing = Ping Exit Function End If End Function[/code] And Command: [code]ElseIf intAccess >= 60 And Left((LCase(Message)), 6) = Form2.txttrigger.Text & "ping " Then r = Right(Message, (Len(Message) - 6)) Dim ThePing As Long ThePing = TPing(r) If ThePing = 0 Then Send = "I can't see " & r & " in the channel, or their ping is 0ms." ElseIf ThePing > 0 Then Send = r & "'s last reported ping was " & ThePing & "ms" End If GoTo Meh[/code] So what m I doin wrong? :/ I got the ping to work when someone joins the channel tho, just can't get the bot to tell me one that I ask for. Some help plz. | January 11, 2005, 12:58 PM |
Kp | [quote author=Hidden link=topic=10167.msg94866#msg94866 date=1105448311] So what m I doin wrong? :/[/quote] Three things: 1) You're using VB. 2) You're using "On Error Resume Next" - this tends to hide mistakes in VB, iirc. 3) You didn't format your code, so it's a nuisance to read. | January 11, 2005, 4:14 PM |
The-Rabid-Lord | [quote author=Kp link=topic=10167.msg94868#msg94868 date=1105460068] 3) You didn't format your code, so it's a nuisance to read. [/quote] Thats the worst mistake I ever made. When I began programming I didnt format and now at college I have to and its a pain as it isnt natural :P FOrmat you code and it will save a heap of time :D | January 11, 2005, 5:13 PM |
R.a.B.B.i.T | [quote author=Hidden link=topic=10167.msg94866#msg94866 date=1105448311] Hey guys, i'm having a real problem with ping, for some reason it doesn't wanna work. I have tried using Search but I couldn't find anything on it. Here is the function and command: ... So what m I doin wrong? :/ I got the ping to work when someone joins the channel tho, just can't get the bot to tell me one that I ask for. Some help plz. [/quote]I'd also point out that you are using ElseIf-Blocks for commands, as opposed to a Select Case, and you're using a listview for storing the ping (directly on your channel list) as opposed to a separate, more manageable array (or better yet, an array of types, one index for each user storing all their information). | January 11, 2005, 5:23 PM |
CrAz3D | Why store everything twice? What if he wants to have alll the info displayed in the channellist, putting it into an array would just use more space & take him more time to do. BUT, I do acknowledge you can put more useful stuff into an array that you wouldn't want to sit there in a channellist (ie join time, last talk time, database flags, etc.) | January 11, 2005, 5:31 PM |
Arta | Because a list box is not a storage device. The list box should be an 'observer' - it should display data that is stored internally in some other form. Ideally, that data would only be resident in memory once, but if that is not possible, the sacrifice is worth it for the sake of organisation. What if you decide at some point down the linke that you'd like to store other about users? What if you decide to create a user database and would like to keep all user data centralised? Display elements should be used for displaying things, and storage devices should be used for storing things. | January 11, 2005, 6:05 PM |
CrAz3D | Makes sense, but would you be reloading the data from the array into the list everytime it was restored from the task bar & remove it when the list isn't showing?...is that really efficent? | January 11, 2005, 6:42 PM |
R.a.B.B.i.T | You don't have to clear and reload the listview every time the bot is sent and returns from the system tray, Visual BASIC automatically does this for you. | January 11, 2005, 10:20 PM |
Zakath | VB doesn't, Windows does. /quibble | January 11, 2005, 10:59 PM |
Hidden | [QUOTE=Kp]3) You didn't format your code, so it's a nuisance to read. [/QUOTE] Can u plz explain that concept to me? I've never done it before. | January 11, 2005, 11:51 PM |
The-Rabid-Lord | You just indent it. | January 12, 2005, 12:05 AM |
Hidden | [quote author=Meh link=topic=10167.msg94917#msg94917 date=1105488358] You just indent it. [/quote] Once again ur explenation crosses my Programming boundaries. Can u plz go into some detail with that? | January 12, 2005, 1:34 AM |
kamakazie | [quote author=Hidden link=topic=10167.msg94930#msg94930 date=1105493666] [quote author=Meh link=topic=10167.msg94917#msg94917 date=1105488358] You just indent it. [/quote] Once again ur explenation crosses my Programming boundaries. Can u plz go into some detail with that? [/quote] Example (notice the comment near the bottom): [code] Function TPing(ByVal Username As String) As Long Dim strChannel As ListItem, Ping As Long Dim intListEnd As Integer, strCompare As String, intChecked As Integer intListEnd = UserCount + 1 intChecked = 1 For intChecked = 1 To intListEnd Dim l As Boolean On Error Resume Next strCompare = lvChannel.ListItems.Item(intChecked) Call PrepareCheck(strCompare) Dim UserCheck As String UserCheck = LCase(Username) Call PrepareCheck(UserCheck) l = LCase(strCompare) Like UserCheck If l = True Then Ping = lbPing.List(intChecked - 1) TPing = Ping Exit Function End If Next intChecked 'AHH! No next in the code so this was a compile-time error. See how indenting allowed me to catch that? End Function [/code] | January 12, 2005, 2:13 AM |
HdxBmx27 | [code] Public Sub AddC(ParamArray saElements() As Variant) On Error Resume Next With rtbChat Dim H As Integer .SelStart = Len(.Text) .SelColor = vbWhite .SelText = GetTimeStamp '"[" & Time & "] " For H = LBound(saElements) To UBound(saElements) Step 2 .SelStart = Len(.Text) .SelLength = 0 .SelColor = saElements(H) .SelText = saElements(H + 1) & Left$(vbCrLf, -2 * CLng((H + 1) = UBound(saElements))) .SelStart = Len(.Text) Next H End With End Sub[/code] VS. [code] Public Sub AddC(ParamArray saElements() As Variant) On Error Resume Next With rtbChat Dim H As Integer .SelStart = Len(.Text) .SelColor = vbWhite .SelText = GetTimeStamp '"[" & Time & "] " For H = LBound(saElements) To UBound(saElements) Step 2 .SelStart = Len(.Text) .SelLength = 0 .SelColor = saElements(H) .SelText = saElements(H + 1) & Left$(vbCrLf, -2 * CLng((H + 1) = UBound(saElements))) .SelStart = Len(.Text) Next H End With End Sub[/code] Witch is easiyer to read AND understand the syntax? ~-~(HDX)~-~ Dang you Dxoigmn post while i was typing >.< | January 12, 2005, 2:14 AM |
R.a.B.B.i.T | Even better: [code] Public Sub AddC(ParamArray saElements() As Variant) On Error GoTo Handle_Err Dim H As Integer With rtbChat .SelStart = Len(.Text) .SelColor = vbWhite .SelText = GetTimeStamp '"[" & Time & "] " For H = LBound(saElements) To UBound(saElements) Step 2 .SelStart = Len(.Text) .SelLength = 0 .SelColor = saElements(H) .SelText = saElements(H + 1) & Left$(vbCrLf, -2 * CLng((H + 1) = UBound(saElements))) .SelStart = Len(.Text) Next H End With On Error GoTo 0 Exit Sub Handle_Err: MsgBox "Error #" & Err.Number & vbNewLine & _ Err.Description & vbNewLine & Err.Source & _ vbNewLine & Err.Scode & vbNewLine& Err.HelpFile & _ vbNewLine & Err.HelpContext, _ vbCritical + vbOKOnly, "Error!" End Sub[/code] vs. [code]Public Sub AddC(ParamArray saElements() As Variant) On Error Resume Next With rtbChat Dim H As Integer .SelStart = Len(.Text) .SelColor = vbWhite .SelText = GetTimeStamp '"[" & Time & "] " For H = LBound(saElements) To UBound(saElements) Step 2 .SelStart = Len(.Text) .SelLength = 0 .SelColor = saElements(H) .SelText = saElements(H + 1) & Left$(vbCrLf, -2 * CLng((H + 1) = UBound(saElements))) .SelStart = Len(.Text) Next H End With End Sub[/code] On Error Resume Next and no error handler...eww. | January 12, 2005, 2:26 AM |
Hidden | I've added a handle error, i did all i could understand from what u guys said. Can someone plz gimme a similar function that would make me realise my mistake or should I just give up and ask for it? :/ I tried, and still not working :( | January 12, 2005, 2:50 AM |
EviL_MarinE | Hm, well you can get it to give ping for when a user joins right? Now all you have to do is swap some things around and make it say it when you talk, i would have it like this [code] Dim Username as String Username = PublicModule.KillNull(Mid(Data, 29)) If Username = EviL_MarinE And Mid(strtext,1 ,5) = frmConfig.trigger.text & "ping " then [/code] If you dont see how i got Mid(Strtext,1, 5) then msg me Maybe your bot isnt agreeing with whar you have said for your username or "ping" bit. go over and check it [code] ElseIf intAccess >= 60 And Left((LCase(Message)), 6) = Form2.txttrigger.Text & "ping " Then [/code] That part Make sure its telling the right thing for the bot to see | January 12, 2005, 7:50 AM |
Hidden | The bot agrees since i don't get an error, i just get told that my ping is 0. which it isn't. I've tried to get around using the normal Ping function to get it, but i was unsuccessful. Now what u did marine, was redo my condition a bit differently. | January 12, 2005, 8:46 AM |
Arta | [quote author=CrAz3D link=topic=10167.msg94879#msg94879 date=1105468965] Makes sense, but would you be reloading the data from the array into the list everytime it was restored from the task bar & remove it when the list isn't showing?...is that really efficent? [/quote] I doubt it very much - not unless VB sucks even more than I think it does. You shouldn't ever have to entirely reload the list, unless you're clearing and repopulating it - like you would if you were moving channels. Normally, you'd just be reloading a single element, which would happen when a user joined your channel. | January 12, 2005, 12:08 PM |
Arta | Making assumptions like that is unwise. | January 12, 2005, 8:58 PM |
Zakath | Besides which, it's using it for a purpose for which it was not designed. While it may work in specific instances, as a principle that is not a good idea. | January 12, 2005, 10:50 PM |
Hidden | And throughout the 21 posts I have yet to get my answer or bot working :/ | January 13, 2005, 12:45 PM |
Adron | [quote author=CrAz3D link=topic=10167.msg94967#msg94967 date=1105540935] So why wouldn't it be acceptable (if storing JUST ping & username) to use the channellist as a sotrage device? This is assuming that you will not add things later on. [/quote] It's much slower to access than any other list. If you make a loop through the users, checking their names against some kind of pattern match, that loop will be slower if the list is stored in a listbox than if it's in a collection or an array. | January 13, 2005, 3:22 PM |
KkBlazekK | [quote author=S-1-5-<wtf.albuquerque.nm@comcast.com>-501 link=topic=10167.msg95079#msg95079 date=1105633807] I just "/w *USERNAME* Ping!" to find out their ping, that way it can be done in other channels also. The ping is returned to you after whispering someone, it's so PIMP like that. [/quote] The ping is also sent to you when you join, or they join a channel. It would save a message if you just stored it into an array then. | January 13, 2005, 10:23 PM |
Myndfyr | [quote author=S-1-5-<wtf.albuquerque.nm@comcast.com>-501 link=topic=10167.msg95121#msg95121 date=1105656122] That is why I mentioned the whole thing about other channels, that way I didn't look dumb like someone who doesn't read my whole post. If they don't join your channel, or visa versa, then you don't know their ping...therefore "/w " them. [/quote] The utility of such a function is questionable, though. If you have a bot specifically for pinging other users, then great; however, if you have one bot that's responsible for maintaining order in a channel, you can pretty quickly overload its queue by having a dozen users "ping" someone all at once. | January 13, 2005, 11:48 PM |
CrAz3D | The same can happen when using the "say" command. BTW, where did my post go to & why is it where ever it is? | January 14, 2005, 12:20 AM |
Hidden | Problem is that Ping cannot specify! Thats why u need the Tping. I can get the ping but I can't get who evers ping i want. So the bot doesn't read the username that i type like it does when someone joins a channel when i used the command. | January 14, 2005, 10:35 AM |
CrAz3D | This is my ping command [code]Case "ping" 'SendW pA(1) & "'s last reported ping was " & Form1.RoomList.FindItem(pA(1)).ListSubItems(2).text, strAccount Queue.AddQueue "/w " & pA(1) & " Ping!" Pinging = True [/code] This is my WhisperTo event code[code]Private Sub OnWhisperTo(ByVal Username As String, ByVal Flags As Long, ByVal Message As String, ByVal Ping As Integer) Chat True, True, WhispNLn, "«To: " & Username & "» " Chat False, False, WhispLn, Message If Pinging = True Then SendW Username & "'s ping is " & Ping, CommandName Pinging = False End If Form1.VBScript.Run "OnWhisperTo", Username, Flags, Message, Ping PL.PlugEvent "whisperto", Username, Message, Flags, Ping End Sub[/code] Pinging is a Public Boolean I have declared, CommandName is just something I use so I can have a whisperback command....instead of the [code]SendW Username &... [/code]You could just do [code]SEND Username & "'s ping is " & ping[/code] (Send would change depending upon how you send chat to bnet) I really REALLy hope this helps. This way lets you see other people's ping that are in other channels, & it will give you the correct ping for whomever. Just make sure that you use the boolean thing too. | January 14, 2005, 3:52 PM |
Kp | Perhaps this is an obvious question, but why're you trying so hard to incorporate a remotely queryable feature into the bot? Just modify your client to display the info natively, save you lots of trouble. Crazed: assuming your posts were the ones screwing up the tables, that's why they vanished. People were complaining about the table mislayout you caused. | January 14, 2005, 4:43 PM |
CrAz3D | Word, that's why I changed it...started to bug me too. Now my name has spaces so it isn't a continuous name. | January 14, 2005, 6:55 PM |