crzyone9584 Posted January 9, 2011 Author Share Posted January 9, 2011 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 More sharing options...
Alatar Posted January 9, 2011 Share Posted January 9, 2011 So you're saying it's showing something like this:> [000 ] -?Maybe you're missing something. Put msgboxes with the variables before that line, to make sure you're sending the data properly. Link to comment Share on other sites More sharing options...
crzyone9584 Posted January 9, 2011 Author Share Posted January 9, 2011 i had it working in [EO]. I'm just now getting to putting it into the Engine bought from Robin. Everything sends and receives fine. Its adding the text to the list box on the frmShortMail. It shows nothing. It won't even show the [000 ] - Link to comment Share on other sites More sharing options...
westin444 Posted January 9, 2011 Share Posted January 9, 2011 try just adding a test string.```frmShortMail.lstMail.AddItem "TestString"```put that in the form load for frmShortMail. Not as part of the packet sub. if it shows, then the problems in the packet part, otherwise its some setting. Link to comment Share on other sites More sharing options...
crzyone9584 Posted January 9, 2011 Author Share Posted January 9, 2011 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 StringDim sender As StringDim Amount As LongDim BoxType As StringDim Buffer As clsBufferSet Buffer = New clsBufferBuffer.WriteBytes Data()sender = Buffer.ReadStringAmount = Buffer.ReadLongsubject = Buffer.ReadStringBoxType = Buffer.ReadStringIf BoxType = "Inbox" ThenIf Amount <= 9 ThenfrmShortMail.lstMail.AddItem "[000" & Amount & "]" & " " & subject & " - " & senderElseIf Amount >= 9 And Amount <= 99 ThenfrmShortMail.lstMail.AddItem "[00" & Amount & "]" & " " & subject & " - " & senderElseIf Amount > 99 ThenfrmShortMail.lstMail.AddItem "[0" & Amount & "]" & " " & subject & " - " & senderElsefrmShortMail.lstMail.AddItem "[" & Amount & "]" & " " & subject & " - " & senderEnd IfElseIf BoxType = "Outbox" ThenIf Amount <= 9 ThenfrmShortMail.lstOutBox.AddItem "[000" & Amount & "]" & " " & subject & " - " & senderElseIf Amount >= 9 And Amount <= 99 ThenfrmShortMail.lstOutBox.AddItem "[00" & Amount & "]" & " " & subject & " - " & senderElseIf Amount > 99 ThenfrmShortMail.lstOutBox.AddItem "[0" & Amount & "]" & " " & subject & " - " & senderElsefrmShortMail.lstOutBox.AddItem "[" & Amount & "]" & " " & subject & " - " & senderEnd IfEnd 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 More sharing options...
EclipseCommunity Posted January 10, 2011 Share Posted January 10, 2011 I'd have to get at your code to check properly. I had a similar problem before and it was something fairly simple. Link to comment Share on other sites More sharing options...
crzyone9584 Posted January 10, 2011 Author Share Posted January 10, 2011 I figure it is something easily over looked. I just can't seem to remember how I got it to work in [EO]. Link to comment Share on other sites More sharing options...
westin444 Posted January 10, 2011 Share Posted January 10, 2011 Not sure what this would do, never stood the difference anyways: Use call before you call AddItem and put parentheses around the arguments. Link to comment Share on other sites More sharing options...
Robin Posted January 10, 2011 Share Posted January 10, 2011 @314piwm:> Not sure what this would do, never stood the difference anyways: Use call before you call AddItem and put parentheses around the arguments.There is absolutely no difference at all. Link to comment Share on other sites More sharing options...
EclipseCommunity Posted January 10, 2011 Share Posted January 10, 2011 Using "Call" is just a more professional way to program. The only purpose I see for it is to make code look tidier, and I suppose it helps if several people are working on the same source code. Link to comment Share on other sites More sharing options...
Robin Posted January 10, 2011 Share Posted January 10, 2011 @Xlithan:> Using "Call" is just a more professional way to program.lolwat. It's a vb6 thing. You won't use it in most languages. Link to comment Share on other sites More sharing options...
crzyone9584 Posted January 12, 2011 Author Share Posted January 12, 2011 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 clsBufferSet Buffer = New clsBufferBuffer.WriteLong CCheckShortMailBuffer.WriteString MyInboxBuffer.WriteString BoxTypeSendData Buffer.ToArray()Set Buffer = NothingEnd Sub>! Public Sub GetShortMailMessage(ByVal MyName As String, ByVal ListedMsg As Long, ByVal BoxType As String)Dim Buffer As clsBufferSet Buffer = New clsBufferBuffer.WriteLong CGetShortMailMessageBuffer.WriteString MyNameBuffer.WriteLong ListedMsgBuffer.WriteString BoxTypeSendData Buffer.ToArray()Set Buffer = NothingEnd Sub>! Public Sub DeleteShortMail(ByVal MyName As String, ByVal DltMsgNum As Long, ByVal BoxType As String)Dim Buffer As clsBufferSet Buffer = New clsBufferBuffer.WriteLong CDeleteShortMailBuffer.WriteString MyNameBuffer.WriteLong DltMsgNumBuffer.WriteString BoxTypeSendData Buffer.ToArray()Set Buffer = NothingEnd Sub>! Public Sub CHeckCharShortMail(ByVal sender As String, ByVal Receiver As String, ByVal subject As String, ByVal message As String)Dim Buffer As clsBufferSet Buffer = New clsBufferBuffer.WriteLong CCHeckCharShortMailBuffer.WriteString senderBuffer.WriteString ReceiverBuffer.WriteString subjectBuffer.WriteString messageSendData Buffer.ToArray()Set Buffer = NothingEnd Sub```ModEnumerationsclient 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 StringDim sender As StringDim amount As LongDim BoxType As StringDim Buffer As clsBufferSet Buffer = New clsBufferBuffer.WriteBytes Data()sender = Buffer.ReadStringamount = Buffer.ReadLongsubject = Buffer.ReadStringBoxType = Buffer.ReadString>! If BoxType = "Inbox" ThenIf amount <= 9 ThenlstMail.AddItem "[000" & amount & "]" & " " & subject & " - " & senderElseIf amount >= 9 And amount <= 99 ThenlstMail.AddItem "[00" & amount & "]" & " " & subject & " - " & senderElseIf amount > 99 ThenlstMail.AddItem "[0" & amount & "]" & " " & subject & " - " & senderElselstMail.AddItem "[" & amount & "]" & " " & subject & " - " & senderEnd IfElseIf BoxType = "Outbox" ThenIf amount <= 9 ThenfrmShortMail.lstOutBox.AddItem "[000" & amount & "]" & " " & subject & " - " & senderElseIf amount >= 9 And amount <= 99 ThenfrmShortMail.lstOutBox.AddItem "[00" & amount & "]" & " " & subject & " - " & senderElseIf amount > 99 ThenfrmShortMail.lstOutBox.AddItem "[0" & amount & "]" & " " & subject & " - " & senderElsefrmShortMail.lstOutBox.AddItem "[" & amount & "]" & " " & subject & " - " & senderEnd IfEnd 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 StringSet Buffer = New clsBufferBuffer.WriteBytes Data()>! sender = Buffer.ReadStringsubject = Buffer.ReadStringbody = Buffer.ReadStringeither = Buffer.ReadStringSet Buffer = Nothing>! If either = "Inbox" ThenfrmShortMail.txSender.text = senderfrmShortMail.txtinboxsubject.text = subjectfrmShortMail.txtBody2.text = bodyElseIf either = "Outbox" ThenfrmShortMail.txtsentto.text = senderfrmShortMail.txtbodysent.text = bodyEnd If End SubSub HandleNewShortMail(ByVal Index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)Dim Buffer As clsBufferDim mail As LongSet Buffer = New clsBufferBuffer.WriteBytes Data()mail = Buffer.ReadLongSet Buffer = Nothing>! If mail = 1 Then'TODO add something to show new mailElseIf mail = 2 Then'TODO add something to show no new mailEnd If```Server Side EditsmodPlayer function Join Game```'Short Mail System Call SetMail(index) Call CheckUnreadMail(index, GetPlayerName(index))```modEnumerationsclient``` '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 clsBufferSet buffer = New clsBufferbuffer.WriteLong SCheckShortMailbuffer.WriteString senderbuffer.WriteLong numberbuffer.WriteString subjectbuffer.WriteString BoxTypeSendDataTo index, buffer.ToArray()Set buffer = NothingEnd Sub>! Sub SendOutBox(ByVal index As Long, ByVal sent As String, ByVal number As Long, ByVal subject As String)Dim buffer As clsBufferSet buffer = New clsBufferbuffer.WriteLong SSendOutBoxbuffer.WriteString sentbuffer.WriteLong numberbuffer.WriteString subjectSendDataTo index, buffer.ToArray()Set buffer = NothingEnd Sub>! Sub SendUnreadMail(ByVal index As Long, ByVal mail As Long)Dim buffer As clsBufferSet buffer = New clsBufferbuffer.WriteLong SCheckCharShortMailbuffer.WriteLong mailSendDataTo index, buffer.ToArray()Set buffer = NothingEnd 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 clsBufferSet buffer = New clsBufferbuffer.WriteLong SGetShortMailMessagebuffer.WriteString senderbuffer.WriteString subjectbuffer.WriteString bodybuffer.WriteString eitherSendDataTo index, buffer.ToArray()Set buffer = NothingEnd 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 SystemSub HandleCheckShortMail(ByVal index As Long, ByRef Data() As Byte, ByVal StartAddR As Long, ByVal ExtraVar As Long)Dim MyInbox As StringDim either As StringDim FileName As StringDim Inbox As LongDim buffer As clsBufferSet buffer = New clsBufferbuffer.WriteBytes Data()MyInbox = buffer.ReadStringeither = buffer.ReadStringIf 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 IfEnd Sub>! Sub HandleDeleteShortMail(ByVal index As Long, ByRef Data() As Byte, ByVal StartAddR As Long, ByVal ExtraVar As Long)Dim MyName As StringDim DltMsgNum As LongDim either As StringDim FileName As StringDim NewAmount As LongDim buffer As clsBufferSet buffer = New clsBufferbuffer.WriteBytes Data()MyName = buffer.ReadStringDltMsgNum = buffer.ReadLongeither = buffer.ReadStringSet 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 StringDim ListedMsg As LongDim either As StringDim FileName As StringDim Inbox As LongDim buffer As clsBufferSet buffer = New clsBufferbuffer.WriteBytes Data()MyName = buffer.ReadStringListedMsg = buffer.ReadLongeither = buffer.ReadStringSet buffer = Nothing>! If either = "Inbox" ThenFileName = 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 LoopCall CheckUnreadMail(index, MyName)ElseIf either = "Outbox" ThenFileName = 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 StringDim Inbox As LongDim total As Long>! If GetPlayerName(index) <> msgsender ThenCall HackingAttempt(index, "Email Modification")Exit SubEnd 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 IfElse 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 SubEnd IfEnd Sub>! Sub CheckUnreadMail(ByVal index As Long, ByVal MyInbox As String)Dim Unread As LongDim Inbox As StringDim FileName As StringFileName = 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 IfEnd Sub>! Sub SetMail(ByVal index As Long)Dim FileName As StringDim Filename2 As StringFileName = 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 IfEnd 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 StringDim Inbox As LongDim total As Long>! If GetPlayerName(index) <> msgsender Then Call HackingAttempt(index, "EmailModification") Exit SubEnd 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 IfEnd Sub>! ``` Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now