Party Only Chat

Okay this is my first tutorial or whatever you can say because this is just a little change from some code 😛

*tested on eclipse the final frontier

*difficult: Very Easy
(deathkeeper said :lol: )

Client Side

open modEnumeration and add this


CSayParty

below


CSayMsg

then find in modClientTCP


Public Sub SayMsg(ByVal text As String)
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.WriteLong CSayMsg
    buffer.WriteString text
    SendData buffer.ToArray()
    Set buffer = Nothing

    ' Error handler
    Exit Sub
ErrorHandler:
    HandleError "SayMsg", "modClientTCP", Err.Number, Err.Description, Err.Source, Err.HelpContext
    Err.Clear
    Exit Sub
End Sub

below that add this


Public Sub PartyMsg(ByVal text As String)
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.WriteLong CSayParty
    buffer.WriteString text
    SendData buffer.ToArray()
    Set buffer = Nothing

    ' Error handler
    Exit Sub
ErrorHandler:
    HandleError "PartyMsg", "modClientTCP", Err.Number, Err.Description, Err.Source, Err.HelpContext
    Err.Clear
    Exit Sub
End Sub

then open modInput and search for


' Say message
        If Len(chatText) > 0 Then
            Call SayMsg(MyText)
        End If

below that add this


'Party Message
        If Left$(chatText, 1) = "~" Then
            chatText = Mid$(chatText, 2, Len(chatText) - 1)

            If Len(chatText) > 0 Then
                Call PartyMsg(chatText)
            End If

            MyText = vbNullString
            UpdateShowChatText
            Exit Sub
        End If

Server Side

open modEnumerations

then below


CSayMsg

add this


CSayParty

open modHandleData

below


HandleDataSub(CSayMsg) = GetAddress(AddressOf HandleSayMsg)

add this


HandleDataSub(CSayParty) = GetAddress(AddressOf HandlePartyMsg)

still at modHandleData, search for this sub


Private Sub HandleSayMsg

below that sub add this sub


Public Sub HandlePartyMsg(ByVal index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)
    Dim Msg As String, s As String
    Dim partynum As Long, i As Long
    Dim buffer As clsBuffer
    Set buffer = New clsBuffer
    buffer.WriteBytes Data()
    Msg = buffer.ReadString

    ' Prevent hacking
    For i = 1 To Len(Msg)

        If AscW(Mid$(Msg, i, 1)) < 32 Or AscW(Mid$(Msg, i, 1)) > 126 Then
            Exit Sub
        End If

    Next

    If Not TempPlayer(index).inParty > 0 Then
        PlayerMsg index, "You need to be in a party to talk in Party Chat!", BrightRed
        Exit Sub
    End If

    s = "[Party]" & GetPlayerName(index) & ": " & Msg
    partynum = TempPlayer(index).inParty
    PartyMsg partynum, "[Party] " & GetPlayerName(index) & " : " & Msg, Blue
    Call TextAdd(Msg)
    Call AddLog(s, PLAYER_LOG)
    Set buffer = Nothing
End Sub

Done…

Saw one of these earlier on, but it’s nice to see you come up with a useful tutorial! Keep up the good work ^_^

There is a tutorial for this. But since this a first timer, keep up the good work!

And also, just a suggestion: To make your code look a bit more neater, you could group together variable declaration.

eg:

dim var1 as string, var2 as string
dim num1 as long, num2 as byte

etc


    Dim Msg As String
    Dim s As String
    Dim partynum As Long
    Dim i As Long

can also make bit shorter like


    Dim Msg, s As String
    Dim partynum, i As Long

Thanks for tutorial 😉


    Dim Msg As String
    Dim s As String
    Dim partynum As Long
    Dim i As Long

can also make bit shorter like


    Dim Msg, s As String
    Dim partynum, i As Long

Thanks for tutorial 😉

You cannot and should not do that.

All variables in VB should be declared with a type. It is not a necessity by a coding efficiency. It also prevents logical errors from taking place. In Domino’s “example” his Msg and partynum variables are not string, longs but rather variants.

It should be

dim msg as string, s as string
dim partnum as long, i as long

Saw one of these earlier on, but it’s nice to see you come up with a useful tutorial! Keep up the good work ^_^

There is a tutorial for this. But since this a first timer, keep up the good work!

And also, just a suggestion: To make your code look a bit more neater, you could group together variable declaration.

eg:

dim var1 as string, var2 as string
dim num1 as long, num2 as byte

etc

my mistake, sorry… 😞


    Dim Msg As String
    Dim s As String
    Dim partynum As Long
    Dim i As Long

can also make bit shorter like


    Dim Msg, s As String
    Dim partynum, i As Long

Thanks for tutorial 😉

i think that will cause an error, if i’m sure that is vb.net script :huh:

but thanks for everyone who tell me to simply this code :wub:

nice tutor

Umm isnt there already a party chat, with “/p” ?? o.O

lol, i though eo had party chat xD But if not then this is helpful. 🙂

Umm isnt there already a party chat, with “/p” ?? o.O

lol, i though eo had party chat xD But if not then this is helpful. 🙂

just like what i said, tested on eclipse the final frontier :lol:

in this engine there is no party chat with /p command 😉

CMIIW 😛

Hello! i have a question:

How to do not appear bubblechat  on the map??? [Final Frontier]

Thanks for help.

Have not yet implemented this yet. but i definitely will.

Apparently on export UpdateShowChatText is not defined.

Grand.

Log in to reply