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

Help!!!


Jacquelinett
 Share

Recommended Posts

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 Long
Dim Minute As Long
Dim CurrentPeriod As Integer
Dim Buffer As clsBuffer

    Hour = Buffer.ReadLong
    Minute = Buffer.ReadLong
    CurrentPeriod = Buffer.ReadInteger

Set Buffer = Nothing

frmMain.lbltime.Caption = Hour & ":" & Minute

End Sub
```

Near the top
   ```
HandleDataSub(STimeOfDay) = GetAddress(AddressOf HandleTimeOfDay)
```
I also created STimeOfDay in ModEnumeration on both client and server

Server side:
```
Sub SendTimeOfDay(ByVal Index As Long)
Dim Buffer As clsBuffer
Dim Packet As String
Dim Hour As Long
Dim Minute As Long
Dim 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 = Nothing

End Sub

And in modServerLoop, I added this sub, as well as call this sub in the main game loop.
Private Sub UpdatePeriod()

Dim Index As Long

Select 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

Please use the code tags next time ;D You seem to be missing two lines:

Set Buffer = New clsBuffer
Buffer.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 Long
Dim Minute As Long
Dim CurrentPeriod As Integer
Dim Buffer As clsBuffer

Set Buffer = New clsBuffer
Buffer.WriteBytes Data()

Hour = Buffer.ReadLong
Minute = Buffer.ReadLong
CurrentPeriod = Buffer.ReadInteger

frmMain.lbltime.Caption = Hour & ":" & Minute

Set Buffer = Nothing
End Sub

```
Link to comment
Share on other sites

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

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...