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

[EO] Admin Msg


Helladen
 Share

Recommended Posts

This simple will add an admin message system, basically I expanded what Origins had and added a client way of sending the message. By default you chat in admin by typing ` before your messages. You can use Ctrl + F to easily change this because the character is like never used. -,-

**Client:**

Find this:
```
        ' Broadcast message
        If left$(ChatText, 1) = "'" Then
            ChatText = Mid$(ChatText, 2, Len(ChatText) - 1)

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

            MyText = vbNullString
            frmMain.txtMyChat.text = vbNullString
            Exit Sub
        End If
```
Below it add this:
```
' Admin message
        If left$(ChatText, 1) = "`" Then
            If GetPlayerAccess(MyIndex) > 0 Then
                ChatText = Trim$(GetPlayerName(MyIndex) & ": " & Mid$(ChatText, 2, Len(ChatText) - 1))

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

                MyText = vbNullString
                frmMain.txtMyChat.text = vbNullString
                Exit Sub
            End If
        End If

```
Find this:
```
CBroadcastMsg
```
Below it add this:
```
CAdminMsg
```
Replace Private Sub AdminMsg or paste this below Public Sub BroadcastMsg:
```
Public Sub AdminMsg(ByVal text As String)
    Dim Buffer As clsBuffer
    Set Buffer = New clsBuffer

    Buffer.WriteLong CAdminMsg
    Buffer.WriteString text

    SendData Buffer.ToArray()
    Set Buffer = Nothing
End Sub
```
Find this:
```
HandleDataSub(SGlobalMsg) = GetAddress(AddressOf HandleGlobalMsg)
```
Below it add this:
```
HandleDataSub(SAdminMsg) = GetAddress(AddressOf HandleAdminMsg)
```
Below Private Sub HandleMapMsg add this or replace Private Sub HandleAdminMsg with this:
```
Private Sub HandleAdminMsg(ByVal Index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)
    Dim Buffer As clsBuffer
    Dim Msg As String
    Set Buffer = New clsBuffer
    Buffer.WriteBytes Data()
    Msg = Buffer.ReadString
    Index = Buffer.ReadLong
    Call AddText(Msg, BrightCyan)
End Sub
```
**Server:**

Find Public Sub InitMessages() and add this at the bottom before End Sub:
```
HandleDataSub(CAdminMsg) = GetAddress(AddressOf HandleAdminMsg)
```
Find Private Sub HandlePlayerMsg and add this below it:
```
Sub HandleAdminMsg(ByVal Index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)
    Dim Buffer As clsBuffer

    ' Prevent hacking
    If GetPlayerAccess(Index) < 1 Then Exit Sub

    Set Buffer = New clsBuffer
    Buffer.WriteBytes Data()
    Call AdminMsg(Buffer.ReadString)
    Set Buffer = Nothing
End Sub
```
Find Public Sub AdminMsg and replace it with this:
```
Public Sub AdminMsg(ByVal Msg As String)
    Dim Buffer As clsBuffer
    Dim I As Long
    Set Buffer = New clsBuffer

    Msg = Trim$("[Admin] " & Msg)

    Buffer.WriteLong SAdminMsg
    Buffer.WriteString Msg

    For I = 1 To MAX_PLAYERS
        If IsPlaying(I) And GetPlayerAccess(I) > 0 Then
            SendDataTo I, Buffer.ToArray
        End If
    Next

    Set Buffer = Nothing
End Sub
```
In Public Enum ServerPackets find:
```
SGlobalMsg
```
Below it add this:
```
SAdminMsg
```
In Public Enum ClientPackets find:
```
CBroadcastMsg
```
Below it add this:
```
CAdminMsg
```
Link to comment
Share on other sites

  • 3 months 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...