Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[EO2.0]Adding Email in frmMenu


PVJsquad
 Share

Recommended Posts

**Intro**
This guide may be not so important, but there may be a need for other programs such as sending an email to that user, here I just added it's email, so in addition to delivery Username and Password I also sent email data and put it into your account,

**Thank's**
Previously, I thank to **abhi2011** and **Deathbeam** to convert these systems to be more useful
http://www.touchofdeathforums.com/smf2/index.php/topic,79963.0.html
http://www.touchofdeathforums.com/smf2/index.php/topic,79964.0.html

**CLIENT SIDE**

**Client Work**
in **frmMenu** i add the text **txtREmail** in **picRegister**
![](http://www.freemmorpgmaker.com/files/imagehost/pics/45863b7a7989d9d74809ec890dbcdec3.bmp)

**Client Side**

in **frmMenu** in **txtRAccept** replace this code
```
Private Sub txtRAccept_Click()
    Dim Name As String
    Dim Password As String
    Dim PasswordAgain As String
    Dim Email As String

    ' If debug mode, handle error then exit out
    If Options.Debug = 1 Then On Error GoTo errorhandler

    Name = Trim$(txtRUser.text)
    Password = Trim$(txtRPass.text)
    PasswordAgain = Trim$(txtRPass2.text)
    Email = Trim$(txtREmail.text)

    If isLoginLegal(Name, Password) Then
        If Password <> PasswordAgain Then
            Call MsgBox("Passwords don't match.")
            Exit Sub
        End If

        If Not isStringLegal(Name) Then
            Exit Sub
        End If

        Call MenuState(MENU_STATE_NEWACCOUNT)
    End If

    ' Error handler
    Exit Sub
errorhandler:
    HandleError "txtRAccept_Click", "frmMenu", Err.Number, Err.Description, Err.Source, Err.HelpContext
    Err.Clear
    Exit Sub
End Sub
```
in **modGeneral** in **Public Sub MenuState** this code **Case MENU_STATE_NEWACCOUNT** replace with
```
Case MENU_STATE_NEWACCOUNT
            frmMenu.Visible = False
            frmMenu.picCredits.Visible = False
            frmMenu.picLogin.Visible = False
            frmMenu.picCharacter.Visible = False
            frmMenu.picRegister.Visible = False

            If ConnectToServer(1) Then
                Call SetStatus("Connected, sending new account information...")
                Call SendNewAccount(frmMenu.txtRUser.text, frmMenu.txtRPass.text, frmMenu.txtREmail.text)
            End If
```
in **modClientTCP** in **Public Sub SendNewAccount**
replace the sub
```
Public Sub SendNewAccount(ByVal Name As String, ByVal Password As String,ByVal Email As String)
Dim Buffer As clsBuffer

    ' If debug mode, handle error then exit out
    If Options.Debug = 1 Then On Error GoTo errorhandler

    Set Buffer = New clsBuffer
    Buffer.WriteLong CNewAccount
    Buffer.WriteString Name
    Buffer.WriteString Password
    Buffer.WriteString Email
    SendData Buffer.ToArray()
    Set Buffer = Nothing

    ' Error handler
    Exit Sub
errorhandler:
    HandleError "SendNewAccount", "modClientTCP", Err.Number, Err.Description, Err.Source, Err.HelpContext
    Err.Clear
    Exit Sub
End Sub
```

**SERVER SIDE**
in **modHandleData** in **Private Sub HandleNewAccount**
will replace that
```
Private Sub HandleNewAccount(ByVal index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)
    Dim Buffer As clsBuffer
    Dim Name As String
    Dim Password As String
    Dim Email As String
    Dim i As Long
    Dim n As Long

    If Not IsPlaying(index) Then
        If Not IsLoggedIn(index) Then
            Set Buffer = New clsBuffer
            Buffer.WriteBytes Data()
            ' Get the data
            Name = Buffer.ReadString
            Password = Buffer.ReadString
            Email = Buffer.ReadString

            ' Prevent hacking
            If Len(Trim$(Name)) < 3 Or Len(Trim$(Password)) < 3 Or Len(Trim$(Email)) < 3 Then
                Call AlertMsg(index, "Your account name must be between 3 and 12 characters long. Your password must be between 3 and 20 characters long.")
                Exit Sub
            End If

            ' Prevent hacking
            If Len(Trim$(Name)) > ACCOUNT_LENGTH Or Len(Trim$(Password)) > NAME_LENGTH Then
                Call AlertMsg(index, "Your account name must be between 3 and 12 characters long. Your password must be between 3 and 20 characters long.")
                Exit Sub
            End If

            ' Prevent hacking
            For i = 1 To Len(Name)
                n = AscW(Mid$(Name, i, 1))

                If Not isNameLegal(n) Then
                    Call AlertMsg(index, "Invalid name, only letters, numbers, spaces, and _ allowed in names.")
                    Exit Sub
                End If

            Next

            ' Check to see if account already exists
            If Not AccountExist(Name) Then
                Call AddAccount(index, Name, Password, Email)
                Call TextAdd("Account " & Name & " has been created.")
                Call AddLog("Account " & Name & " has been created.", PLAYER_LOG)

                ' Load the player
                Call LoadPlayer(index, Name)

                ' Check if character data has been created
                If LenB(Trim$(Player(index).Name)) > 0 Then
                    ' we have a char!
                    HandleUseChar index
                Else
                    ' send new char crap
                    If Not IsPlaying(index) Then
                        Call SendNewCharClasses(index)
                    End If
                End If

                ' Show the player up on the socket status
                Call AddLog(GetPlayerLogin(index) & " has logged in from " & GetPlayerIP(index) & ".", PLAYER_LOG)
                Call TextAdd(GetPlayerLogin(index) & " has logged in from " & GetPlayerIP(index) & ".")
            Else
                Call AlertMsg(index, "Sorry, that account name is already taken!")
            End If

            Set Buffer = Nothing
        End If
    End If

End Sub
```
in **modDatabase** replace
```
Sub AddAccount(ByVal index As Long, ByVal Name As String, ByVal Password As String,ByVal Email As String)
    Dim i As Long

    ClearPlayer index

    Player(index).Login = Name
    Player(index).Password = Password
    Player(index).Email = Email

    Call SavePlayer(index)
End Sub
```
and in **modTypes**
in **playerRec**
I Add
```
Email As String * 255
```
Its Simple and you can add another than **Email**
Link to comment
Share on other sites

  • 2 weeks later...
@DarkScythe57:

> found somthing wrong. for the first task it says to replace this code. with wat do we replace this code with?

find the this code **Private Sub txtRAccept_Click()** in **frmMenu**
and replace this sub with this code
```
Private Sub txtRAccept_Click()
    Dim Name As String
    Dim Password As String
    Dim PasswordAgain As String
    Dim Email As String

    ' If debug mode, handle error then exit out
    If Options.Debug = 1 Then On Error GoTo errorhandler

    Name = Trim$(txtRUser.text)
    Password = Trim$(txtRPass.text)
    PasswordAgain = Trim$(txtRPass2.text)
    Email = Trim$(txtREmail.text)

    If isLoginLegal(Name, Password) Then
        If Password <> PasswordAgain Then
            Call MsgBox("Passwords don't match.")
            Exit Sub
        End If

        If Not isStringLegal(Name) Then
            Exit Sub
        End If

        Call MenuState(MENU_STATE_NEWACCOUNT)
    End If

    ' Error handler
    Exit Sub
errorhandler:
    HandleError "txtRAccept_Click", "frmMenu", Err.Number, Err.Description, Err.Source, Err.HelpContext
    Err.Clear
    Exit Sub
End Sub
```
Link to comment
Share on other sites

  • 4 weeks later...
  • 1 month later...
i found a way to send e-mail from vb6 [http://www.freevbcode.com/ShowCode.asp?ID=109](http://www.freevbcode.com/ShowCode.asp?ID=109), i try to implement it to your system

I found a better and simplier way throught Winsock

```
Dim UserName$, UserMail$, MailRecipiant$, MailBody$, SockData$

Private Sub Command1_Click()
UserName = "YourUserName_or_Addr"
UserMail = "Your Name "
MailRecipiant = UserMail
MailBody = "The message goes here"
Winsock1.LocalPort = 0
Winsock1.RemoteHost = "smtp-server"
Winsock1.RemotePort = 25
Winsock1.Connect
End Sub

Private Sub Winsock1_Connect()
Label1 = "Sending message..."
Winsock1.SendData "EHLO " & UserName & vbCrLf
If Not WaitFor("250") Then GoTo 100
Winsock1.SendData "MAIL FROM: " & UserMail & vbCrLf
If Not WaitFor("250") Then GoTo 100
Winsock1.SendData "RCPT TO: " & MailRecipiant & vbCrLf
If Not WaitFor("250") Then GoTo 100
Winsock1.SendData "DATA" & vbCrLf
If Not WaitFor("354") Then GoTo 100
Winsock1.SendData MailBody & vbCrLf & "." & vbCrLf
If Not WaitFor("250") Then GoTo 100
Winsock1.SendData "QUIT" & vbCrLf
If Not WaitFor("221") Then GoTo 100
Label1 = "Message sent"
GoTo 200
100
Label1 = SockData
200
Winsock1.Close
End Sub

Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Winsock1.GetData SockData
End Sub

Private Sub Winsock1_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)
Label1 = "Error: " & Description
SockData = "Error"
Winsock1.Close
End Sub

Private Function WaitFor(SockResponse As String) As Boolean
Do While Left(SockData, 3) <> SockResponse And Left(SockData, 3) <> "220" And Left(SockData, 3) <> "250"
  DoEvents
  If Left(SockData, 3) > "400" Then Exit Function
Loop
WaitFor = 1
SockData = ""
End Function

```
I think this will be easy to integrate to eclipse. Just some modification must be made. Read from textboxes and so…
Link to comment
Share on other sites

  • 1 month later...
I thank to **abhi2011** and **Deathbeam** to convert these systems to be more useful

after doing the tutorial above, I recommend to visit this thread
http://www.touchofdeathforums.com/smf2/index.php/topic,79963.0.html
http://www.touchofdeathforums.com/smf2/index.php/topic,79964.0.html
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...