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

[WN]Short Mail System(Like Email)


crzyone9584
 Share

Recommended Posts

I have everything working except the filling of two list boxes. All data is sent from the server to the client okay. The problem I'm having is the fact it doesn't fill the list boxes for the inbox and outbox. The idea is from the mail system from EE 2.7 but heavily modified for my needs, along with the needs of the [WN] Engine in Robin's Shop.

Here is the code to fill the list box.

```
frmShortMail.lstMail.AddItem "[000" & Amount & "]" & " " & subject & " - " & sender

```
Thats the only piece of code that is not working. Amount, subject, and sender are all filled with information. The list box is just not filling up with the information that it should be. Any ideas?
Link to comment
Share on other sites

That works just fine. Problem is all the packets are being received correctly, read, and put into a variable. Here is the entire sub.

```
'Short Mail System
    Sub HandleCheckShortMail(ByVal Index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)
Dim subject As String
Dim sender As String
Dim Amount As Long
Dim BoxType As String
Dim Buffer As clsBuffer
Set Buffer = New clsBuffer
Buffer.WriteBytes Data()
sender = Buffer.ReadString
Amount = Buffer.ReadLong
subject = Buffer.ReadString
BoxType = Buffer.ReadString

If BoxType = "Inbox" Then
If Amount <= 9 Then
frmShortMail.lstMail.AddItem "[000" & Amount & "]" & " " & subject & " - " & sender
ElseIf Amount >= 9 And Amount <= 99 Then
frmShortMail.lstMail.AddItem "[00" & Amount & "]" & " " & subject & " - " & sender
ElseIf Amount > 99 Then
frmShortMail.lstMail.AddItem "[0" & Amount & "]" & " " & subject & " - " & sender
Else
frmShortMail.lstMail.AddItem "[" & Amount & "]" & " " & subject & " - " & sender
End If
ElseIf BoxType = "Outbox" Then
If Amount <= 9 Then
frmShortMail.lstOutBox.AddItem "[000" & Amount & "]" & " " & subject & " - " & sender
ElseIf Amount >= 9 And Amount <= 99 Then
frmShortMail.lstOutBox.AddItem "[00" & Amount & "]" & " " & subject & " - " & sender
ElseIf Amount > 99 Then
frmShortMail.lstOutBox.AddItem "[0" & Amount & "]" & " " & subject & " - " & sender
Else
frmShortMail.lstOutBox.AddItem "[" & Amount & "]" & " " & subject & " - " & sender
End If
End If
    End Sub
```
everything is filled. Its just not populating the list boxes.

It gets to
```
frmShortMail.lstMail.AddItem "[000" & Amount & "]" & " " & subject & " - " & sender
```
Then it just doesnt actually fill.
Link to comment
Share on other sites

I've re started this and still can't seem to get it to work. Maybe someone could figure out whats wrong with this. As I have stated earlier, every thing works except adding the things to the list box. I've also attached my frm.

Client Side edits - this feature is ported from ES and works fine other than adding items to the listbox.

>! modclientTCP
```
' Short Mail System
>! Public Sub CheckShortMail(ByVal MyInbox As String, ByVal BoxType As String)
Dim Buffer As clsBuffer
Set Buffer = New clsBuffer
Buffer.WriteLong CCheckShortMail
Buffer.WriteString MyInbox
Buffer.WriteString BoxType
SendData Buffer.ToArray()
Set Buffer = Nothing
End Sub
>! Public Sub GetShortMailMessage(ByVal MyName As String, ByVal ListedMsg As Long, ByVal BoxType As String)
Dim Buffer As clsBuffer
Set Buffer = New clsBuffer
Buffer.WriteLong CGetShortMailMessage
Buffer.WriteString MyName
Buffer.WriteLong ListedMsg
Buffer.WriteString BoxType
SendData Buffer.ToArray()
Set Buffer = Nothing
End Sub
>! Public Sub DeleteShortMail(ByVal MyName As String, ByVal DltMsgNum As Long, ByVal BoxType As String)
Dim Buffer As clsBuffer
Set Buffer = New clsBuffer
Buffer.WriteLong CDeleteShortMail
Buffer.WriteString MyName
Buffer.WriteLong DltMsgNum
Buffer.WriteString BoxType
SendData Buffer.ToArray()
Set Buffer = Nothing
End Sub
>! Public Sub CHeckCharShortMail(ByVal sender As String, ByVal Receiver As String, ByVal subject As String, ByVal message As String)
Dim Buffer As clsBuffer
Set Buffer = New clsBuffer
Buffer.WriteLong CCHeckCharShortMail
Buffer.WriteString sender
Buffer.WriteString Receiver
Buffer.WriteString subject
Buffer.WriteString message
SendData Buffer.ToArray()
Set Buffer = Nothing
End Sub
```
ModEnumerations
client side packets
```
'Short Mail System
    CCheckShortMail ' Used for checking if you have any mail
    CDeleteShortMail ' Used for deleting Short mail
    CGetShortMailMessage ' Used to get the the message from the server
    CCHeckCharShortMail ' Used to send email
```server ones
```
'Short Mail System
    SCheckShortMail ' Used for checking if you have any mail
    SDeleteShortMail ' Used for deleting Short mail
    SGetShortMailMessage ' Used to get the the message from the server
    SCheckCharShortMail ' Used to send email
    SCheckOutboxMail
```ModHandledata
```
'Short Mail System
    HandleDataSub(SCheckShortMail) = GetAddress(AddressOf HandleCheckShortMail)
    HandleDataSub(SDeleteShortMail) = GetAddress(AddressOf HandleDeleteShortMail)
    HandleDataSub(SGetShortMailMessage) = GetAddress(AddressOf HandleGetShortMailMessage)
    HandleDataSub(SCheckCharShortMail) = GetAddress(AddressOf HandleNewShortMail)
>! 'Short Mail System
    Sub HandleCheckShortMail(ByVal Index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)
Dim subject As String
Dim sender As String
Dim amount As Long
Dim BoxType As String
Dim Buffer As clsBuffer
Set Buffer = New clsBuffer
Buffer.WriteBytes Data()
sender = Buffer.ReadString
amount = Buffer.ReadLong
subject = Buffer.ReadString
BoxType = Buffer.ReadString
>! If BoxType = "Inbox" Then
If amount <= 9 Then
lstMail.AddItem "[000" & amount & "]" & " " & subject & " - " & sender
ElseIf amount >= 9 And amount <= 99 Then
lstMail.AddItem "[00" & amount & "]" & " " & subject & " - " & sender
ElseIf amount > 99 Then
lstMail.AddItem "[0" & amount & "]" & " " & subject & " - " & sender
Else
lstMail.AddItem "[" & amount & "]" & " " & subject & " - " & sender
End If
ElseIf BoxType = "Outbox" Then
If amount <= 9 Then
frmShortMail.lstOutBox.AddItem "[000" & amount & "]" & " " & subject & " - " & sender
ElseIf amount >= 9 And amount <= 99 Then
frmShortMail.lstOutBox.AddItem "[00" & amount & "]" & " " & subject & " - " & sender
ElseIf amount > 99 Then
frmShortMail.lstOutBox.AddItem "[0" & amount & "]" & " " & subject & " - " & sender
Else
frmShortMail.lstOutBox.AddItem "[" & amount & "]" & " " & subject & " - " & sender
End If
End If
>!     End Sub
    Sub HandleDeleteShortMail(ByVal Index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)

    End Sub
    Sub HandleGetShortMailMessage(ByVal Index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)
    Dim Buffer As clsBuffer
    Dim sender As String
    Dim subject As String
    Dim body As String
    Dim either As String
Set Buffer = New clsBuffer
Buffer.WriteBytes Data()
>! sender = Buffer.ReadString
subject = Buffer.ReadString
body = Buffer.ReadString
either = Buffer.ReadString
Set Buffer = Nothing
>! If either = "Inbox" Then
frmShortMail.txSender.text = sender
frmShortMail.txtinboxsubject.text = subject
frmShortMail.txtBody2.text = body
ElseIf either = "Outbox" Then
frmShortMail.txtsentto.text = sender
frmShortMail.txtbodysent.text = body
End If
    End Sub

Sub HandleNewShortMail(ByVal Index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)
Dim Buffer As clsBuffer
Dim mail As Long
Set Buffer = New clsBuffer
Buffer.WriteBytes Data()
mail = Buffer.ReadLong
Set Buffer = Nothing
>! If mail = 1 Then
'TODO add something to show new mail
ElseIf mail = 2 Then
'TODO add something to show no new mail
End If
```
Server Side Edits
modPlayer function Join Game
```
'Short Mail System
    Call SetMail(index)
    Call CheckUnreadMail(index, GetPlayerName(index))
```
modEnumerations
client
```
'Short Mail System
    CCheckshortMail ' Used for checking if you have any mail
    CDeleteShortMail ' Used for deleting Short mail
    CGetShortMailMessage ' Used to get the the message from the server
    CCHeckCharShortMail ' Used to send email
```server
```
'Short Mail System
    SCheckShortMail ' Used for checking if you have any mail
    SDeleteShortMail ' Used for deleting Short mail
    SGetShortMailMessage ' Used to get the the message from the server
    SCheckCharShortMail ' Used to send email
    SSendOutBox ' Used to send outbox mail to user
```modServerTCP
```
'Short Mail System
>! Sub SendInbox(ByVal index As Long, ByVal sender As String, ByVal number As Long, ByVal subject As String, ByVal BoxType As String)
Dim buffer As clsBuffer
Set buffer = New clsBuffer
buffer.WriteLong SCheckShortMail
buffer.WriteString sender
buffer.WriteLong number
buffer.WriteString subject
buffer.WriteString BoxType
SendDataTo index, buffer.ToArray()
Set buffer = Nothing
End Sub
>! Sub SendOutBox(ByVal index As Long, ByVal sent As String, ByVal number As Long, ByVal subject As String)
Dim buffer As clsBuffer
Set buffer = New clsBuffer
buffer.WriteLong SSendOutBox
buffer.WriteString sent
buffer.WriteLong number
buffer.WriteString subject
SendDataTo index, buffer.ToArray()
Set buffer = Nothing
End Sub
>! Sub SendUnreadMail(ByVal index As Long, ByVal mail As Long)
Dim buffer As clsBuffer
Set buffer = New clsBuffer
buffer.WriteLong SCheckCharShortMail
buffer.WriteLong mail
SendDataTo index, buffer.ToArray()
Set buffer = Nothing
End Sub
>! Sub MsgBodyMail(ByVal index As Long, ByVal sender As String, ByVal subject As String, ByVal body As String, ByVal either As String)
Dim buffer As clsBuffer
Set buffer = New clsBuffer
buffer.WriteLong SGetShortMailMessage
buffer.WriteString sender
buffer.WriteString subject
buffer.WriteString body
buffer.WriteString either
SendDataTo index, buffer.ToArray()
Set buffer = Nothing
End Sub
```modHandleData
```
'Short Mail System
    HandleDataSub(CCheckshortMail) = GetAddress(AddressOf HandleCheckShortMail)
    HandleDataSub(CDeleteShortMail) = GetAddress(AddressOf HandleDeleteShortMail)
    HandleDataSub(CGetShortMailMessage) = GetAddress(AddressOf HandleGetShortMailMessage)
    HandleDataSub(CCHeckCharShortMail) = GetAddress(AddressOf HandleCheckCharShortMail)
>! 'Short Mail System
Sub HandleCheckShortMail(ByVal index As Long, ByRef Data() As Byte, ByVal StartAddR As Long, ByVal ExtraVar As Long)
Dim MyInbox As String
Dim either As String
Dim FileName As String
Dim Inbox As Long
Dim buffer As clsBuffer
Set buffer = New clsBuffer
buffer.WriteBytes Data()
MyInbox = buffer.ReadString
either = buffer.ReadString
If either = "Inbox" Then
        FileName = App.Path & "\data\Mail\" & MyInbox & ".txt"
        Inbox = GetVar(FileName, "INBOX", "amount")
        Do While Inbox >= 1
            If GetVar(FileName, Val(Inbox), "Number") > 0 Then
                Call SendInbox(index, GetVar(FileName, Val(Inbox), "Sender"), GetVar(FileName, Val(Inbox), "Number"), GetVar(FileName, Val(Inbox), "Subject"), "Inbox")
            End If
            Inbox = Inbox - 1
        Loop
        Call CheckUnreadMail(index, MyInbox)
    ElseIf either = "Outbox" Then
        FileName = App.Path & "\data\Mail\Outbox\" & MyInbox & ".txt"
        Inbox = GetVar(FileName, "OUTBOX", "amount")
        Do While Inbox >= 1
            If GetVar(FileName, Val(Inbox), "Number") > 0 Then
                Call SendInbox(index, GetVar(FileName, Val(Inbox), "Sent"), GetVar(FileName, Val(Inbox), "Number"), GetVar(FileName, Val(Inbox), "Subject"), "Outbox")
            End If
            Inbox = Inbox - 1
        Loop
    End If
End Sub
>!     Sub HandleDeleteShortMail(ByVal index As Long, ByRef Data() As Byte, ByVal StartAddR As Long, ByVal ExtraVar As Long)
Dim MyName As String
Dim DltMsgNum As Long
Dim either As String
Dim FileName As String
Dim NewAmount As Long
Dim buffer As clsBuffer
Set buffer = New clsBuffer
buffer.WriteBytes Data()
MyName = buffer.ReadString
DltMsgNum = buffer.ReadLong
either = buffer.ReadString
Set buffer = Nothing
>! If either = "Inbox" Then
        FileName = App.Path & "\data\Mail\" & MyName & ".txt"

        Call PutVar(FileName, Val(DltMsgNum), "Number", 0)
        Call PutVar(FileName, Val(DltMsgNum), "Read", 0)
        Call PutVar(FileName, Val(DltMsgNum), "Sender", vbNullString)
        Call PutVar(FileName, Val(DltMsgNum), "Subject", vbNullString)
        Call PutVar(FileName, Val(DltMsgNum), "Body", vbNullString)
        Call CheckUnreadMail(index, MyName)
    ElseIf either = "Outbox" Then
        FileName = App.Path & "\data\Mail\Outbox\" & MyName & ".txt"

        Call PutVar(FileName, Val(DltMsgNum), "Number", 0)
        Call PutVar(FileName, Val(DltMsgNum), "Sent", vbNullString)
        Call PutVar(FileName, Val(DltMsgNum), "Subject", vbNullString)
        Call PutVar(FileName, Val(DltMsgNum), "Body", vbNullString)
    End If
>!     End Sub

    Sub HandleGetShortMailMessage(ByVal index As Long, ByRef Data() As Byte, ByVal StartAddR As Long, ByVal ExtraVar As Long)
Dim MyName As String
Dim ListedMsg As Long
Dim either As String
Dim FileName As String
Dim Inbox As Long
Dim buffer As clsBuffer
Set buffer = New clsBuffer
buffer.WriteBytes Data()
MyName = buffer.ReadString
ListedMsg = buffer.ReadLong
either = buffer.ReadString
Set buffer = Nothing
>! If either = "Inbox" Then
FileName = App.Path & "\data\Mail\" & MyName & ".txt"
Inbox = GetVar(FileName, "INBOX", "amount")
Do While Inbox >= 1
            If GetVar(FileName, Val(ListedMsg), "Number") = Inbox Then
                Call MsgBodyMail(index, GetVar(FileName, Val(ListedMsg), "Sender"), GetVar(FileName, Val(ListedMsg), "Subject"), GetVar(FileName, Val(ListedMsg), "Body"), either)
                Call PutVar(FileName, Val(ListedMsg), "Read", 0)
                Exit Do
            End If
            Inbox = Inbox - 1
        Loop
Call CheckUnreadMail(index, MyName)
ElseIf either = "Outbox" Then
FileName = App.Path & "\data\Mail\Outbox\" & MyName & ".txt"
        Inbox = GetVar(FileName, "OUTBOX", "amount")
        Do While Inbox >= 1
            If GetVar(FileName, Val(ListedMsg), "Number") = Inbox Then
                Call MsgBodyMail(index, GetVar(FileName, Val(ListedMsg), "Sent"), GetVar(FileName, Val(ListedMsg), "Subject"), GetVar(FileName, Val(ListedMsg), "Body"), either)
                Exit Do
            End If
            Inbox = Inbox - 1
        Loop
    End If
    End Sub

    Sub HandleCheckCharShortMail(ByVal index As Long, ByRef Data() As Byte, ByVal StartAddR As Long, ByVal ExtraVar As Long)
    Dim sender As String
    Dim Reciever As String
    Dim subject As String
    Dim message As String

    Dim buffer As clsBuffer
    Set buffer = New clsBuffer
    buffer.WriteBytes Data()
    sender = buffer.ReadString
    Reciever = buffer.ReadString
    subject = buffer.ReadString
    message = buffer.ReadString
    Set buffer = Nothing

    If FindChar(Reciever) = True Then
    Call SendMail(index, sender, Reciever, subject, message)
    Else
    Call PlayerMsg(index, "That Player Does Not Exist!", BrightRed)
    End If
    End Sub

    Sub SendMail(ByVal index As Long, ByVal msgsender As String, ByVal msgReciever As String, ByVal msgSubject As String, ByVal msgBody As String)
Dim FileName As String
Dim Inbox As Long
Dim total As Long
>! If GetPlayerName(index) <> msgsender Then
Call HackingAttempt(index, "Email Modification")
Exit Sub
End If
>! FileName = App.Path & "\data\Mail\" & msgReciever & ".txt"
If Not FileExist("\data\Mail\") Then
    Call PutVar(FileName, "Inbox", "amount", 1)
    Call PutVar(FileName, "Inbox", "total", 1)
    Call PutVar(FileName, 1, "Number", 1)
    Call PutVar(FileName, 1, "Read", 1)
    Call PutVar(FileName, 1, "Sender", msgsender)
    Call PutVar(FileName, 1, "Subject", msgSubject)
    Call PutVar(FileName, 1, "Body", msgBody)
    If FindPlayer(msgReciever) <> index Then
            Call CheckUnreadMail(FindPlayer(msgReciever), msgReciever)
        Else
            Call CheckUnreadMail(index, msgsender)
        End If
Else
    Inbox = GetVar(FileName, "INBOX", "amount")
    total = GetVar(FileName, "INBOX", "total")

    If Inbox = 9999 Or total = 9999 Then
        Exit Sub
    End If

    Call PutVar(FileName, Inbox + 1, "Number", total + 1)
    Call PutVar(FileName, Inbox + 1, "Read", 1)
    Call PutVar(FileName, Inbox + 1, "Sender", msgsender)
    Call PutVar(FileName, Inbox + 1, "Subject", msgSubject)
    Call PutVar(FileName, Inbox + 1, "Body", msgBody)
    Call PutVar(FileName, "INBOX", "amount", Inbox + 1)
    Call PutVar(FileName, "INBOX", "total", total + 1)
            If FindPlayer(msgReciever) <> index Then
            Call CheckUnreadMail(FindPlayer(msgReciever), msgReciever)
        Else
            Call CheckUnreadMail(index, msgsender)
        End If
    Call SendMail2(index, msgsender, msgReciever, msgSubject, msgBody)
    Exit Sub
End If
End Sub
>! Sub CheckUnreadMail(ByVal index As Long, ByVal MyInbox As String)
Dim Unread As Long
Dim Inbox As String
Dim FileName As String
FileName = App.Path & "\data\Mail\" & MyInbox & ".txt"
Inbox = GetVar(FileName, "INBOX", "amount")
>! Do While Inbox >= 1
        If GetVar(FileName, Val(Inbox), "Read") = 1 Then
                Unread = Unread + 1
        End If
        Inbox = Inbox - 1
    Loop
    If Unread > 0 Then
    Call SendUnreadMail(index, 1)
    Else
    Call SendUnreadMail(index, 2)
    End If
End Sub
>! Sub SetMail(ByVal index As Long)
Dim FileName As String
Dim Filename2 As String
FileName = App.Path & "\data\Mail\Outbox\" & GetPlayerName(index) & ".txt"
If Not FileExist("\data\Mail\Outbox\" & GetPlayerName(index) & ".txt") Then
    Call PutVar(FileName, "OUTBOX", "amount", 1)
    Call PutVar(FileName, "OUTBOX", "total", 1)
    Call PutVar(FileName, 1, "Number", 1)
    Call PutVar(FileName, 1, "Sent", "Ovan")
    Call PutVar(FileName, 1, "Subject", "Registard")
    Call PutVar(FileName, 1, "Body", "Ovan, I'm done registering. Where should we meet?")
End If
    Filename2 = App.Path & "\data\Mail\" & GetPlayerName(index) & ".txt"
If Not FileExist("\data\Mail\" & GetPlayerName(index) & ".txt") Then
    Call PutVar(Filename2, "Inbox", "amount", 1)
    Call PutVar(Filename2, "Inbox", "total", 1)
    Call PutVar(Filename2, 1, "Number", 1)
    Call PutVar(Filename2, 1, "Read", 1)
    Call PutVar(Filename2, 1, "Sender", "Administrator")
    Call PutVar(Filename2, 1, "Subject", "Welcome to The World")
    Call PutVar(Filename2, 1, "Body", "Welcome to the world " & GetPlayerName(index) & ". Please enjoy your stay.")
    End If
End Sub
>! Sub SendMail2(ByVal index As Long, ByVal msgsender As String, ByVal msgReciever As String, ByVal msgSubject As String, ByVal msgBody As String)
Dim FileName As String
Dim Inbox As Long
Dim total As Long
>! If GetPlayerName(index) <> msgsender Then
    Call HackingAttempt(index, "EmailModification")
    Exit Sub
End If
>! FileName = App.Path & "\data\Mail\Outbox\" & msgsender & ".txt"
If Not FileExist("\data\Mail\Outbox\" & msgsender & ".txt") Then
    Call PutVar(FileName, "OUTBOX", "amount", 1)
    Call PutVar(FileName, "OUTBOX", "total", 1)
    Call PutVar(FileName, 1, "Number", 1)
    Call PutVar(FileName, 1, "Sent", msgReciever)
    Call PutVar(FileName, 1, "Subject", msgSubject)
    Call PutVar(FileName, 1, "Body", msgBody)
Else
    Inbox = GetVar(FileName, "OUTBOX", "amount")
    total = GetVar(FileName, "OUTBOX", "total")

    If Inbox = 9999 Or total = 9999 Then
        Exit Sub
    End If
    Call PutVar(FileName, Inbox + 1, "Number", total + 1)
    Call PutVar(FileName, Inbox + 1, "Sent", msgReciever)
    Call PutVar(FileName, Inbox + 1, "Subject", msgSubject)
    Call PutVar(FileName, Inbox + 1, "Body", msgBody)
    Call PutVar(FileName, "OUTBOX", "amount", Inbox + 1)
    Call PutVar(FileName, "OUTBOX", "total", total + 1)
End If
End Sub
>! ```
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...