Jacquelinett Posted August 22, 2011 Author Share Posted August 22, 2011 This is in modHandleData, at the bottom:```Sub HandleTimeOfDay(ByVal Index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)Dim Hour As LongDim Minute As LongDim CurrentPeriod As IntegerDim Buffer As clsBuffer Hour = Buffer.ReadLong Minute = Buffer.ReadLong CurrentPeriod = Buffer.ReadIntegerSet Buffer = NothingfrmMain.lbltime.Caption = Hour & ":" & MinuteEnd Sub```Near the top ```HandleDataSub(STimeOfDay) = GetAddress(AddressOf HandleTimeOfDay)```I also created STimeOfDay in ModEnumeration on both client and serverServer side:```Sub SendTimeOfDay(ByVal Index As Long)Dim Buffer As clsBufferDim Packet As StringDim Hour As LongDim Minute As LongDim CurrentPeriod As Integer Set Buffer = New clsBuffer Buffer.WriteLong Index Buffer.WriteLong STimeOfDay Buffer.WriteLong Hour Buffer.WriteLong Minute Buffer.WriteInteger CurrentPeriod SendDataToAll Buffer.ToArray Set Buffer = NothingEnd SubAnd in modServerLoop, I added this sub, as well as call this sub in the main game loop.Private Sub UpdatePeriod()Dim Index As LongSelect Case CurrentPeriod Case 0 'Midnight frmServer.lblCurrentPeriod.Caption = "Midnight" Case 1 'Dawn frmServer.lblCurrentPeriod.Caption = "Dawn" Case 2 'Morning frmServer.lblCurrentPeriod.Caption = "Morning " Case 3 'Noon frmServer.lblCurrentPeriod.Caption = "Noon " Case 4 'Afternoon frmServer.lblCurrentPeriod.Caption = "Afternoon " Case 5 'Night frmServer.lblCurrentPeriod.Caption = "Night "End Select Call SendTimeOfDay(Index)End Sub```It didn’t work. I tried to send the server time to the client but the label in the client didn’t change. Any suggestion? Link to comment Share on other sites More sharing options...
PD Posted August 22, 2011 Share Posted August 22, 2011 Please use the code tags next time ;D You seem to be missing two lines:Set Buffer = New clsBufferBuffer.WriteBytes Data()So try this out:```Sub HandleTimeOfDay(ByVal Index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)Dim Hour As LongDim Minute As LongDim CurrentPeriod As IntegerDim Buffer As clsBufferSet Buffer = New clsBufferBuffer.WriteBytes Data()Hour = Buffer.ReadLongMinute = Buffer.ReadLongCurrentPeriod = Buffer.ReadIntegerfrmMain.lbltime.Caption = Hour & ":" & MinuteSet Buffer = NothingEnd Sub``` Link to comment Share on other sites More sharing options...
Jacquelinett Posted August 22, 2011 Author Share Posted August 22, 2011 tried that, still didn't work at all. Plus now the button on the client doesn't work. Maybe because of the loop? Link to comment Share on other sites More sharing options...
Rithy58 Posted August 23, 2011 Share Posted August 23, 2011 Can't see the code cause I'm on my iPhone but there is a small bug in modEnum.If you go there, you'd see the Public HandleDataSub(…). This was suppose to create an amount of array according to the incoming packets. So for Client, it should be SMSG_Count while Server would be CMSG_Count.Sincerely,Rithy Link to comment Share on other sites More sharing options...
Jacquelinett Posted August 25, 2011 Author Share Posted August 25, 2011 Too bad, you are wrong, Ricky. That wasn't the problem. The problem is I forgot to add:Buffer.ReadBytes Data()Problem solved. 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