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

[EO 2.0] Party Chat Messages


Derryl
 Share

Recommended Posts

This tutorial is basically about making a party chat message system. I use /p for mine. So you will have to change the numbers in the "/p" code to fit the way you're chat messages work. Lets begin.

**Client Side**

At the bottom of "modClientTCP" add:

```
Public Sub SendPartyChatMsg(ByVal text As String)
    Dim Buffer As clsBuffer
    Set Buffer = New clsBuffer

    Buffer.WriteLong CPartyChatMsg
    Buffer.WriteString text

    SendData Buffer.ToArray()
    Set Buffer = Nothing
End Sub
```
In "modEnumerations", above:

```
' Make sure CMSG_COUNT is below everything else
```
Add:

```
CPartyChatMsg
```
In "modInput", in "Sub Handlekeypresses" under:

```
' Handle when the player presses the return key
    If KeyAscii = vbKeyReturn Then
```
Add:

```
' Party Msg
        If Left$(ChatText, 3) = "/p " Then
            ChatText = Mid$(ChatText, 4, Len(ChatText) - 3)

            If Len(ChatText) > 0 Then
                Call SendPartyChatMsg(ChatText)
            End If

            MyText = vbNullString
            frmMain.txtMyChat.text = vbNullString
            Exit Sub
        End If
```
And thats it for the client side. Again you will have to change the numbers in the above code if you want to use symbols to chat.

**Server Side**

In "modHandleData", in "Sub InitMessages" above the "End Sub" add:

```
HandleDataSub(CPartyChatMsg) = GetAddress(AddressOf HandlePartyChatMsg)
```
At the bottom of "modHandleData" add:

```
Sub HandlePartyChatMsg(ByVal Index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)
    Dim Buffer As clsBuffer

    Set Buffer = New clsBuffer
    Buffer.WriteBytes Data()
    PartyChatMsg Index, Buffer.ReadString, Pink
    Set Buffer = Nothing
End Sub
```
At the bottom of "modServerTCP" add:

```
Public Sub PartyChatMsg(ByVal Index As Long, ByVal Msg As String, ByVal Color As Byte)
Dim i As Long
Dim Member As Integer
Dim partyNum As Long

partyNum = tempPlayer(Index).inParty

    ' not in a party?
    If tempPlayer(Index).inParty = 0 Then
        Call PlayerMsg(Index, "You are not in a party.", BrightRed)
        Exit Sub
    End If

    For i = 1 To MAX_PARTY_MEMBERS
        Member = Party(partyNum).Member(i)
        ' is online, does exist?
        If IsConnected(Party(partyNum).Member(i)) And IsPlaying(Party(partyNum).Member(i)) Then
        ' yep, send the message!
            Call PlayerMsg(Member, "[Party] " & GetPlayerName(Index) & ": " & Msg, Color)
        End If
    Next
End Sub
```
In "modEnumerations", above:

```
' Make sure CMSG_COUNT is below everything else
```
Add:

```
CPartyChatMsg
```
And that's it. Goodluck.
Link to comment
Share on other sites

  • 2 weeks later...
  • 4 weeks later...

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