Author Topic: VectorNet implementation  (Read 724 times)

Vector

  • Administrator
  • Hero Member
  • *****
  • Posts: 550
    • View Profile
    • http://clanmage.phost.ws
VectorNet implementation
« on: December 04, 2008, 02:47:59 PM »
Create a winsock object named "sckVN" in frmMain. To add the rest:

Commands from in-bot:
Code: [Select]
/vn connect
/vn connect <server> <port>
/vn disconnect
/vn msg <text>

[size=]frmMain[/size]
Code: [Select]
Private Sub sckVN_DataArrival(ByVal bytesTotal As Long)
  Dim data As String, tempBuf As String, cType As Integer, nickName As String, nickText As String
  Dim ver As String, usersOnline As String, nullUBND As Integer, appendName As String
  Dim action As String, kicker As String, kicked As String
  
  sckVN.GetData data
  tempBuf = data
  If Len(data) > 1 Then data = Mid$(data, 2)
  
  Select Case Asc(Mid(tempBuf, 1, 1))
    Case 1:
             nickName = Split(data, Chr$(0))(0)
             cType = Split(data, Chr$(0))(1)
            
             Select Case cType
               Case 1: appendName = nickName & " (VectorNet client)"
               Case 2: appendName = nickName & " (StealthBot Plugin)"
               Case Else: appendName = nickName
             End Select
            
             AddChat vbCyan, "[VectorNet] " & appendName, vbWhite, " has joined VectorNet."
    Case 2:
             nickName = Split(data, Chr$(0))(0)
             nickText = Split(data, Chr$(0))(1)
            
             AddChat vbCyan, "[VectorNet] ", vbYellow, "<" & nickName & "> ", vbWhite, nickText
    Case 3:
             sckVN.SendData Chr$(&HB)
             sckVN.Close
             MsgBox ("You have been disconnected from the VectorNet server for having a duplicate name.")
    Case 4:
             nickName = data
            
             AddChat vbCyan, "[VectorNet] " & nickName, vbWhite, " has left VectorNet."
    Case 5:
             ver = Split(data, Chr$(0))(0)
             usersOnline = Split(data, Chr$(0))(1)
            
             If usersOnline = vbNullString Then
               vnstat = "No one is on VectorNet."
             Else
               vnstat = "Users online: " & usersOnline
             End If
              
             AddChat vbCyan, "[VectorNet] ", vbYellow, "Welcome to ", vbCyan, ver & ". ", vbWhite, vnstat
    Case 6:
             Dim srvMessage As String
            
             srvMessage = data
             AddChat vbCyan, "[VectorNet] ", vbRed, "[Server Message] ", vbWhite, srvMessage
    Case 7:
             action = Split(data, Chr$(0))(0)
             kicker = Split(data, Chr$(0))(1)
            
             Select Case action
               Case "kick"
                 action = "kicked"
               Case "ban"
                 action = "banned"
             End Select
            
             AddChat vbCyan, "[VectorNet] ", vbWhite, "You have been " & action & " from VectorNet by: ", vbYellow, kicker
             AddChat vbWhite, "Client disconnected."
             sckVN.Close
    Case 8:
             kicked = Split(data, Chr$(0))(0)
             action = Split(data, Chr$(0))(1)
             kicker = Split(data, Chr$(0))(2)
            
             Select Case action
               Case "kick"
                 action = "kicked"
               Case "ban"
                 action = "banned"
             End Select
            
             AddChat vbCyan, "[VectorNet] ", vbWhite, kicked, vbCyan, " was " & action & " by: ", vbWhite, kicker
    Case 10:
             MsgBox ("You have been banned from the VectorNet server.")
             AddChat vbCyan, "[VectorNet] ", vbWhite, "Disconnected."
             sckVN.SendData Chr$(&HB)
             sckVN.Close
  End Select
End Sub

[size=]Command Processor snippet[/size]

Code: [Select]
    Case "vn"
      Select Case LCase(cmd(1))
        Case "connect"
          If ucmd = 1 Then
            If frmMain.sckVN.State = sckConnected Then
              AddChat vbRed, "[VectorNet] You are already connected! Type /vn disconnect to disconnect."
            Else
              If frmMain.sckVN.State = sckConnected Then
                AddChat vbGreen, "[VectorNet] You are already connected. Type /vn disconnect first."
                Exit Sub
              End If
              frmMain.sckVN.Close
              vnServer = "VectorNet.no-ip.org"
              vnPort = 5501
              frmMain.sckVN.Connect "VectorNet.no-ip.org", 5501
              Do While frmMain.sckVN.State <> sckConnected: DoEvents: DoEvents: DoEvents: Loop
              frmMain.sckVN.SendData Chr$(&H1) & botUsername & 4
            End If
          ElseIf ucmd = 3 Then
            If frmMain.sckVN.State = sckConnected Then
              AddChat vbRed, "[VectorNet] You are already connected! Type /vn disconnect to disconnect."
            Else
              If Not IsNumeric(cmd(3)) Then
                AddChat vbRed, "[VectorNet] You have entered a port value that is not numeric."
              Else
                vnServer = cmd(2)
                vnPort = cmd(3)
                frmMain.sckVN.Connect cmd(2), cmd(3)
                Do While frmMain.sckVN.State <> sckConnected: DoEvents: DoEvents: DoEvents: Loop '
                frmMain.sckVN.SendData Chr$(&H1) & botUsername & Chr$(0) & 3
              End If
            End If
          Else
            AddChat vbRed, "[VectorNet] Too many arguments. Example: /vn connect <server> <port>"
          End If
        Case "disconnect"
          If frmMain.sckVN.State = sckClosed Then Exit Sub
          frmMain.sckVN.Close
          AddChat vbCyan, "[VectorNet] Connection to the VectorNet server closed."
        Case "msg"
          If frmMain.sckVN.State = sckConnected Then
            vnMessage = Split(message, cmd(1) & " ")(1)
            frmMain.sckVN.SendData Chr$(&H2) & botUsername & Chr$(0) & vnMessage
            AddChat vbCyan, "[VectorNet] ", vbLightBlue, "<", vbCyan, botUsername, vbLightBlue, "> ", vbWhite, vnMessage
          End If
      End Select

I also used 4 as the client type. Let me know when this gets implemented.

I figure this is the best way since I am unable to help you with it.
« Last Edit: December 04, 2008, 02:48:46 PM by Vector »
I am an Unofficial StealthBot Technician, an Unofficial StealthBot scripter, among other things. See my about page for more info.

Quote from: ArticWolve
Sorry I went down. Had internet problems with a cracker-jack-licensed driver hitting my internet pole (about 8 of them fell) and drooping my phone and electricity. Sorry ><

Rev77.net Plugins Manager

Proud host of Vector.no-ip.info | VectorJBLS.no-ip.org Status: [img]http://rev77.net/ServerCheck/check.asp?query=check&server=VectorJBLS.no-ip.org_status.png\" border=\"0\" class=\"linked-image\" /]

Shito-Ryu Karate-Do Genbu-Kai Rank: 8th Kyu (White belt, one stripe)

Rev77.Net Remote Support (Double-Click my name only if you were told to)

If the above link doesn't work, or if you use Vista, try this alternate link.

Noob ~Vector