Helladen Posted November 27, 2010 Author Share Posted November 27, 2010 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 = NothingEnd 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 = NothingEnd 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 = NothingEnd 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 More sharing options...
Yxxe Posted November 27, 2010 Share Posted November 27, 2010 Nice. A good way of displaying admin notices etc. ;) Link to comment Share on other sites More sharing options...
kibbelz Posted December 1, 2010 Share Posted December 1, 2010 i think there already is a admin message in eo just press -message Link to comment Share on other sites More sharing options...
Robin Posted December 1, 2010 Share Posted December 1, 2010 That's an emote. Link to comment Share on other sites More sharing options...
aaaron Posted March 27, 2011 Share Posted March 27, 2011 @Helladen:> Find Public Sub HandlePlayerMsg and add this below it:I only could find "Private Sub HandlePlayerMsg." Link to comment Share on other sites More sharing options...
bloodless Posted March 27, 2011 Share Posted March 27, 2011 @K722:> I only could find "Private Sub HandlePlayerMsg."yeh but it still worked fine :) Link to comment Share on other sites More sharing options...
Helladen Posted March 27, 2011 Author Share Posted March 27, 2011 I fixed the typo thanks. Private means that it can only be called within the module/form/etc it is in. Public means it is global, it can be called anywhere. Link to comment Share on other sites More sharing options...
Alatar Posted March 27, 2011 Share Posted March 27, 2011 Nice addition :) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now