• Welcome to Valhalla Legends Archive.
 

A newb at Programming

Started by Tubby, April 22, 2003, 05:33 PM

Previous topic - Next topic

Tubby

Hello,
   I have used many bots. I wanted to make my own. I dont know much about C++ or Visual basic. I wanted to start off with a simple chatbot. If anyone can give some advice on how to get started. If you are good with computer repair plz contact me on aim: TubbyNumNum

BD_Tubby

prairienetworks

#1
I find VB to be very easy, to get started with a bot try to get the source code for a basic/simple bot.  Someone made a sample bot (named "assbot") that has free code for VB, very effective and neat.  Take a look at it.  There is also one that Stealth made before his major bot days, called "AsdF" the source code is pasted below.  If you don't understand any of the below, take a course in VB (much easier then trying to understand a book about it).  Note:  This will only log onto public chat and is VERY basic, no commands or anything.  Very good to see how it was made though.  Good Luck.
Option Explicit
'Very basic CHAT bot, initial code by Stealth <[email protected]>
'Use and modification is permitted for any educational or personal purpose
'(c)2003 Stealth Networks
Private Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
'The above is an API call needed to easily read .INI config files.
Private gUsername As String
Private gPassword As String
Private gServer As String

Private Sub Form_Load()
   Shell "C:\windows\explorer.exe " & App.Path
   Dim s As String     'S is a junk variable, it's used over and over
   s = ReadINI("Setup", "Username", "config.ini") 'Read the INI file for the desired info
   If s <> "" Then gUsername = s Else GoTo LoadError 'If the config is blank then msgbox the error
   s = ReadINI("Setup", "Password", "config.ini")
   If s <> "" Then gPassword = s Else GoTo LoadError
   s = ReadINI("Setup", "Server", "config.ini")
   If s <> "" Then gServer = s Else GoTo LoadError
   
   'Configs have been loaded. Set the winsock's settings.
   
   wskBNet.RemoteHost = gServer            'Battle.Net/Warrnet server server
   wskBNet.RemotePort = 6112               'BNet/BNetD works on port 6112 exclusively
   wskBNet.Protocol = sckTCPProtocol       'TCP protocol for the winsocket
   Exit Sub                                'No error has occured, so don't run the code below this point.
LoadError:
   MsgBox "An error has occurred. Please check your config file."
   End
End Sub

Private Sub Form_Unload(Cancel As Integer)
   On Error Resume Next                    'Ignore errors
   wskBNet.Close                           'Close the winsocket
   Unload Me                               'Close the program
   End
End Sub

Private Sub mnuConnect_Click()
   If wskBNet.State = 0 Then               'State of 0 means disconnected.
       AddChat vbGreen, "Connecting..."
       wskBNet.Connect                     'Connect the socket
   Else
       Call mnuDisc_Click            'Disconnect it
       AddChat vbRed, "Disconnected."
       AddChat vbGreen, "Connecting..."
       wskBNet.Connect
   End If
End Sub

Private Sub mnuDisc_Click()
   wskBNet.Close                           'Close the winsock connection
   AddChat vbRed, "Disconnected."
End Sub

Private Sub mnuExit_Click()
   Unload Me                               'Closes the program
   End
End Sub

Private Sub rtbChat_Change()

End Sub

Private Sub txtSend_KeyPress(KeyAscii As Integer)
       'Someone pressed a key in the text box!
       If KeyAscii = 13 Then                           'If the Enter key is pressed
           If wskBNet.State = 7 Then                   'If the socket is connected
               wskBNet.SendData txtSend.Text & vbCrLf  'Send the text in the textbox
                                                       'with the necessary vbCrLf ending
               AddChat vbCyan, txtSend.Text
               txtSend.Text = ""                       'Clear the textbox
           Else
               AddChat vbRed, "You are not connected."
           End If
       End If
End Sub

Private Sub wskBNet_Connect()
   'The socket has connected to the server!
   wskBNet.SendData Chr(3) & Chr(4) & gUsername & vbCrLf & gPassword & vbCrLf
   'The Chr(3) and (4) protocol packets are sent, followed by the username and password.
   'If this were Starcraft you would send the 0x51 packet instead of chr(3) and (4).
   AddChat vbGreen, "Connected!"
End Sub

Private Sub wskBNet_DataArrival(ByVal bytesTotal As Long)
   'Data has arrived at the winsocket. I am displaying it unparsed.
   Dim s As String                         'Again, a throwaway variable
   wskBNet.GetData s, vbString             'Get the information as a string from the winsock buffer
   AddChat vbWhite, s                      'Display the information, raw as it arrives from the server.
End Sub

Private Sub wskBNet_Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
   'The socket has recieved an error.
   AddChat vbRed, "Error " & Number & ": " & Description   'Tell the user the error.
   Call mnuDisc_Click                'Disconnect the bot. This takes care of everything we need to do here.
   'Call mnuconnect_click()                 'If you want, un-comment the beginning part of this line to autoreconnect.
End Sub

'RTB ADDCHAT CONTROL, modified by Stealth to add timestamps automatically
Private Sub AddChat(ParamArray saElements() As Variant)
   If Len(rtbChat.Text) > 20000 Then
       Close #1
       Open (App.Path & "\clearedtext.txt") For Output As #1
       Print #1, "-: In case you missed something..." & vbCrLf
       Print #1, rtbChat.Text
       Close #1
       rtbChat.Text = ""
       AddChat vbYellow, "Chat window auto-cleared. Previous text stored in clearedtext.txt."
   End If
   
   Dim i As Integer
   On Error Resume Next
   With rtbChat
       .SelStart = Len(.Text)
       .SelLength = 0
       .SelColor = vbWhite
       .SelText = " [" & Time & "] "
       .SelStart = Len(.Text)
   End With
   For i = LBound(saElements) To UBound(saElements) Step 2
   With rtbChat
       .SelStart = Len(.Text)
       .SelLength = 0
       .SelColor = saElements(i)
       .SelText = saElements(i + 1) & Left$(vbCrLf, -2 * CLng((i + 1) = UBound(saElements)))
       .SelStart = Len(.Text)
   End With
   Next i
End Sub

'======================================================
'The ReadINI subroutine retrieves information from a .ini config file.
'This subroutine was part of ASSBOT and was coded by ickis with slight modification by Stealth.
Public Function ReadINI$(riSection$, riKey$, riFile$)
   Dim sRiBuffer$
   Dim sRiValue$
   Dim sRiLong$
   riFile = App.Path & "\" & riFile
   If Dir(riFile$) <> "" Then
       sRiBuffer = String(255, vbNull)
       sRiLong = GetPrivateProfileString(riSection, riKey, Chr(1), sRiBuffer, 255, riFile)
       If Left(sRiBuffer, 1) <> Chr(1) Then
           sRiValue = Left(sRiBuffer, sRiLong)
           ReadINI = sRiValue
       End If
   Else
       ReadINI = ""
   End If
End Function

tA-Kane

Are the code tags broke for you people, or something >:(
Macintosh programmer and enthusiast.
Battle.net Bot Programming: http://www.bash.org/?240059
I can write programs. Can you right them?

http://www.clan-mac.com
http://www.eve-online.com

Tubby

Are there any books that are good cuz i have NO knowledge of VB

Eternal

Tubby, there are plenty of books on Visual  Basic. Goto a book store and look under the programming section and you will see what I mean.

You should learn the basics of programming before even attempting to write a bot...they aren't straightforward.

Go get a book, sit down and learn it - then when you feel ready, write a bot. There's plenty of topics and tips on these boards to help, but they aren't really aimed at completely new programmers.

Hope it helps.

PS - The Complete Idiots Guide to VB6 is a good book...and I am not being sarcastic here.
^-----silly Brit
-----------------------------
www.brimd.com

Banana fanna fo fanna

I've said it before...DON'T start with VB. Python: batteries included.

Eternal

Bah! VB is a great place to start : )
^-----silly Brit
-----------------------------
www.brimd.com

MrRaza

Learn C
Learn C
Learn C
Learn C
Learn C
Learn C
Learn C
Learn C


Tubby

What program do u use to program in C?



I asked this in ur channel and i didnt understand it...i also got banned for saying VB is hard...im not whinning but it does look complicated to someone who has no programing knowledge

Eibro

Quote from: Tubby on April 24, 2003, 06:04 PM
What program do u use to program in C?



I asked this in ur channel and i didnt understand it...i also got banned for saying VB is hard...im not whinning but it does look complicated to someone who has no programing knowledge
There's plenty of free compilers out there... but I've only come across one IDE that's comparable to Microsoft's, that's Dev-C++: www.bloodshed.net. Also, if you prefer command line (which for some reason I doubt) there's DJGPP: http://www.delorie.com/djgpp/ or mingw (Which is the underlying compiler of the Dev-C++ IDE)
Eibro of Yeti Lovers.

Camel

yeah, it's important to point out that most compilers are just fancy bloated text editors that tell the compiler what to do 8)

Yoni

Quote from: Camel on April 24, 2003, 07:29 PM
yeah, it's important to point out that most compilers are just fancy bloated text editors that tell the compiler what to do 8)
The first compiler in that sentence is called an IDE, not a compiler

Banana fanna fo fanna

Quote from: Yoni on April 24, 2003, 07:56 PM
Quote from: Camel on April 24, 2003, 07:29 PM
yeah, it's important to point out that most compilers are just fancy bloated text editors that tell the compiler what to do 8)
The first compiler in that sentence is called an IDE, not a compiler
+1 to Camel for getting owned

Camel

Quote from: Yoni on April 24, 2003, 07:56 PM
Quote from: Camel on April 24, 2003, 07:29 PM
yeah, it's important to point out that most compilers are just fancy bloated text editors that tell the compiler what to do 8)
The first compiler in that sentence is called an IDE, not a compiler

allow me to rephrase:
yeah, it's important to point out that most "compilers" are in fact not compilers at all, they are just...

Etheran