escfoe2 Posted December 11, 2011 Author Share Posted December 11, 2011 Well as I mentioned in a previous post. I am making a combination feature to my game that allows players to morph items together to create new things. Well here's my problem: I can't get the damn variables to be sent through the buffer. Im pretty much clueless on how the buffer works, everything else is fine though.THE SPECS:I have a type called Combo and it has 6 parts- ComboName as String 'Name- LevelReq as Long ' Level Required- Take1 as Long ' 1st item to take- Take2 as Long ' 2nd item to take- Give1 as Long ' 1st item to give- Give 2 as Long ' 2nd item to giveI cannot get it to send right through this sub below:```Public Sub SendSaveCombo(ByVal ComboNum As Long)Dim Buffer As clsBufferDim ComboSize As LongDim ComboData() As Byte ' If debug mode, handle error then exit out If Options.Debug = 1 Then On Error GoTo errorhandler Set Buffer = New clsBuffer ComboSize = LenB(Combo(ComboNum)) ReDim ComboData(ComboSize - 1) CopyMemory ComboData(0), ByVal VarPtr(Combo(ComboNum)), ComboSize Buffer.WriteLong CSaveCombo Buffer.WriteLong ComboNum Buffer.WriteBytes ComboData SendData Buffer.ToArray() Set Buffer = Nothing ' Error handler Exit Suberrorhandler: HandleError "SendSaveCombo", "modClientTCP", Err.Number, Err.Description, Err.Source, Err.HelpContext Err.Clear Exit SubEnd Sub```That sub is based off of SendSaveItem. When I look at the one for npcs, it's about the same too. I don't see what I'm doing wrong but the variables in the type Combo will not send to the server. This actually causes a fatal error in the server with what it DOES send. I have the variables set as the user changes values on the form. Everything is set to work right except for THIS. If anyone can give me any advice or information on this I would greatly appreciate it. Thanks in advance. Link to comment Share on other sites More sharing options...
Esmeyana Posted December 11, 2011 Share Posted December 11, 2011 You must have a CSaveCombo in the modEnumerations in the server project.after that a sub HandleSaveCombo in modHandleData in the server project, look how CSaveNPC and HandleSaveNPC is done in modhandledata in the server.EDIT:> causes a fatal error in the server with what it DOES send??? so you have a HandleSaveCombo in server side?How are you actually saving the data of the type "Combo"?because you can't go in the server and say "Combo(index).give1" without having a place to save it…You must have a folder in your "server\data files\" called Combo or something, and you have to do the modDatabase things... Link to comment Share on other sites More sharing options...
escfoe2 Posted December 12, 2011 Author Share Posted December 12, 2011 I have all of the enumerators and types already set on both ends. The issue is that the Client ends up sending blank data before it even gets to the server. I debugged it to find out why I was getting a fatal error with it. Turns out that's why. So on JoinGame the server sends all its little shit such as SendItems and of cource SendCombos. I already know the combos are empty because the server isn't getting anything to save. Like I said, as I explain this you will notice how the combos are set up just like the way items are handled. Now when you click the save button in the combo form, it calls ComboEditorOk. This then uses a For-Loop to call SendSaveCombo. This is the sub I mentioned previously in my last post that is supposed to send the variable data. It doesn't I don't understand why so I'll post all of my code below.The save button```Private Sub cmdSave_Click() ' If debug mode, handle error then exit out If Options.Debug = 1 Then On Error GoTo errorhandler Call ComboEditorOk ' Error handler Exit Suberrorhandler: HandleError "cmdSave_Click", "frmEditor_Combinations", Err.Number, Err.Description, Err.Source, Err.HelpContext Err.Clear Exit SubEnd Sub```ComboEditorOk```Public Sub ComboEditorOk()Dim i As Long ' If debug mode, handle error then exit out If Options.Debug = 1 Then On Error GoTo errorhandler For i = 1 To MAX_COMBOS If Combo_Changed(i) Then Call SendSaveCombo(i) End If Next Unload frmEditor_Combinations Editor = 0 ClearChanged_Combo ' Error handler Exit Suberrorhandler: HandleError "ComboEditorOk", "modGameEditors", Err.Number, Err.Description, Err.Source, Err.HelpContext Err.Clear Exit SubEnd Sub```SendSaveCombo, which is where it's not correctly sending the values```Public Sub SendSaveCombo(ByVal ComboNum As Long)Dim Buffer As clsBufferDim ComboSize As LongDim ComboData() As Byte ' If debug mode, handle error then exit out If Options.Debug = 1 Then On Error GoTo errorhandler Set Buffer = New clsBuffer ComboSize = LenB(Combo(ComboNum)) ReDim ComboData(ComboSize - 1) CopyMemory ComboData(0), ByVal VarPtr(Combo(ComboNum)), ComboSize Buffer.WriteLong CSaveCombo Buffer.WriteLong ComboNum Buffer.WriteBytes ComboData SendData Buffer.ToArray() Set Buffer = Nothing ' Error handler Exit Suberrorhandler: HandleError "SendSaveCombo", "modClientTCP", Err.Number, Err.Description, Err.Source, Err.HelpContext Err.Clear Exit SubEnd Sub```ComboRec, the type library I have both Client and Server-Side. This is in modTypes as it should be.```Public Combo(1 To MAX_COMBOS) As ComboRecPublic Type ComboRec ComboName As String LevelReq As Long Take1 As Long Take2 As Long Give1 As Long Give2 As LongEnd Type```I have all of my variables declared. MAX_COMBOS is declared both ends. I can't seem to finger out what the hell I did wrong here. :/ I put a break in the SendSaveCombo sub on the line that says "Set Buffer = Nothing" and used the 'Immediate' window to check the ComboData by typing "?ComboData" and pressed entered. Guess what I got….. "?? " Well, it had the separation symbols in it too that you can't see but It SHOULD have the comboname, levelreq, take1, take2, give1, and give2 values in it which it doesn't. Very frustrating... :mad: It'd be nice if Robin took a look-see. Im sure he's an expert when it comes to the buffer that HE made lol Thanks though for any and all help. I try to do the same whenever I can. Link to comment Share on other sites More sharing options...
escfoe2 Posted December 14, 2011 Author Share Posted December 14, 2011 If no one answers is it against the rules to bump the topic? I seriously need some sort of help with this. It's gotta be something simple that I'm overlooking :/ Link to comment Share on other sites More sharing options...
blkcrow Posted December 15, 2011 Share Posted December 15, 2011 the problem is here```ReDim ComboData(ComboSize - 1)```you delete everything in ComboDataput this instead```ReDim Preserve ComboData(ComboSize - 1)``` 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