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

Sending new data regarding MapNpc's between client and server?


Zappy
 Share

Recommended Posts

Hey guys! I've ran into a bit of a jam that I can't really figure out. I need to communicate with the client regarding whether or not an npc or player is currently affected by a D.O.T, H.O.T, stun, etc.

However I'm not sure exactly what to be doing. I assumed I needed to go into "SendMapNpcto" and 'HandleMapData" and add "BufferReadLong/Writelong" to transmit the new variable, but it isn't reading properly… Anyone familiar with doing this sorta thing willing to give a quick lesson ![:)](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/smile.png)?

This is in the client

```

Private Sub HandleMapNpcData(ByVal Index As Long, ByRef data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)

Dim i As Long

Dim Buffer As clsBuffer

' If debug mode, handle error then exit out

If Options.Debug = 1 Then On Error GoTo errorhandler

Set Buffer = New clsBuffer

Buffer.WriteBytes data()

For i = 1 To MAX_MAP_NPCS

With MapNpc(i)

.num = Buffer.ReadLong

.x = Buffer.ReadLong

.y = Buffer.ReadLong

.Dir = Buffer.ReadLong

.Vital(HP) = Buffer.ReadLong

.StatusEffect = Buffer.ReadLong

End With

Next

' Error handler

Exit Sub

errorhandler:

HandleError "HandleMapNpcData", "modHandleData", Err.Number, Err.Description, Err.Source, Err.HelpContext

Err.Clear

Exit Sub

End Sub

```

This is in the server

```

Sub SendMapNpcsTo(ByVal Index As Long, ByVal mapnum As Long)

Dim packet As String

Dim i As Long

Dim Buffer As clsBuffer

Set Buffer = New clsBuffer

Buffer.WriteLong SMapNpcData

For i = 1 To MAX_MAP_NPCS

Buffer.WriteLong MapNpc(mapnum).NPC(i).Num

Buffer.WriteLong MapNpc(mapnum).NPC(i).x

Buffer.WriteLong MapNpc(mapnum).NPC(i).y

Buffer.WriteLong MapNpc(mapnum).NPC(i).Dir

Buffer.WriteLong MapNpc(mapnum).NPC(i).Vital(HP)

Buffer.WriteLong MapNpc(mapnum).NPC(i).StatusEffect

Next

SendDataTo Index, Buffer.ToArray()

Set Buffer = Nothing

End Sub

```
I have the same extra line in SendMapNpcsToMap or whatever.

I also have the StatusEffect variable declared in both NpcRec AND MapNpcRec, on both sides.
Link to comment
Share on other sites

You have the right idea. You need to read/write the same variable and in the same order. If you're writing this:

```
Buffer.WriteByte NPC.IsHoTed

Buffer.WriteLong NPCNum
```

Then you have to receive it on the other end like this:

```
NPC.IsHoTed = Buffer.ReadByte

Buffer.WriteLong NPCNum
```

Also if you posted your code it would be a lot easier to help you.
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...