MapChat server Listener

In EO2 (Robin’s final version thingy), I want to make the server listen to Map Chat. This is so I can moderate my game since there’s like 100 maps and all I hear is Global. If anyone knows how or a good tutorial, please help me. Thanks in advance!

EG, it would put in server like “[Map#1] Scratso: Message” for example.

Edit:Thanks, Mod Matt!


Private Sub HandleSayMsg(ByVal index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)
    Dim Msg As String
    Dim 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)
        ' limit the ASCII
        If AscW(Mid$(Msg, i, 1)) < 32 Or AscW(Mid$(Msg, i, 1)) > 126 Then
            ' limit the extended ASCII
            If AscW(Mid$(Msg, i, 1)) < 128 Or AscW(Mid$(Msg, i, 1)) > 168 Then
                ' limit the extended ASCII
                If AscW(Mid$(Msg, i, 1)) < 224 Or AscW(Mid$(Msg, i, 1)) > 253 Then
                    Mid$(Msg, i, 1) = ""
                End If
            End If
        End If
    Next

    Call AddLog("Map #" & GetPlayerMap(index) & ": " & GetPlayerName(index) & " says, '" & Msg & "'", PLAYER_LOG)
    Call SayMsg_Map(GetPlayerMap(index), index, Msg, QBColor(White))

    Set Buffer = Nothing
End Sub

That’s the sub that handles saying messages. Not too far from there is a sub that handles global messages. You’ll find all you need there.

“Variable not defined” and it points at the top line

I’d need to see what you wrote to figure out what went wrong 😜


' 


Private Sub HandleSayMsg(ByVal index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)
    Dim Msg As String
    Dim 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)
        ' limit the ASCII
        If AscW(Mid$(Msg, i, 1)) < 32 Or AscW(Mid$(Msg, i, 1)) > 126 Then
            ' limit the extended ASCII
            If AscW(Mid$(Msg, i, 1)) < 128 Or AscW(Mid$(Msg, i, 1)) > 168 Then
                ' limit the extended ASCII
                If AscW(Mid$(Msg, i, 1)) < 224 Or AscW(Mid$(Msg, i, 1)) > 253 Then
                    Mid$(Msg, i, 1) = ""
                End If
            End If
        End If
    Next

    Call AddLog("Map #" & GetPlayerMap(index) & ": " & GetPlayerName(index) & " says, '" & Msg & "'", PLAYER_LOG)
    Call SayMsg_Map(GetPlayerMap(index), index, Msg, QBColor(White))
    Call AddText("[Map " & GetPlayerMap(index) & "]" & GetPlayerName(index) & ":" & Msg)

    Set Buffer = Nothing
End Sub

I added the line:

    Call AddText("[Map " & GetPlayerMap(index) & "]" & GetPlayerName(index) & ":" & Msg)

I believe EO 2.0 uses TextAdd instead of AddText

Oh. i’ll try that then.

I believe EO 2.0 uses TextAdd instead of AddText

It worked! Thank you 😄

You’re welcome ^_^

Log in to reply