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

Mute Player!


abhi2011
 Share

Recommended Posts

Hey Guys this is my first tutorial. I know that there is a Mute player already but that one is the the form of a Command Button. So here is how to make a right click option.

~~~SERVER SIDE ONLY~~~
Go to server.vbp and in the server form (frmserver) press 'ctrl+E'. This should bring up the menu editor.
Now choose a spot to add the Mute option. It should have that '….' thing before the caption. You should not add it you have to press enter on either of the give captions. Then type the name as 'mnuMute' and caption as whatever you want.

Now the coding.

Open the code of frmserver and find
```
Sub mnuDisconnectPlayer_Click()
```After the end sub before
```
Sub mnuBanPlayer_click()
```Add this
```
Sub mnuMute_Click()
    Dim Name As String
    Name = frmServer.lvwInfo.SelectedItem.SubItems(3)

    If Not Name = "Not Playing" Then
        Call ToggleMute(FindPlayer(Name))
    End If
End Sub
```
In modDatabase after
```
Public Sub LoadOptions()
```Add End Sub
```
Public Sub ToggleMute(ByVal index As Long)
    ' exit out for rte9
    If index <= 0 Or index > MAX_PLAYERS Then Exit Sub

    ' toggle the player's mute
    If Player(index).isMuted = 1 Then
        Player(index).isMuted = 0
        ' Let them know
        PlayerMsg index, "You have been unmuted and can now talk in global.", BrightGreen
        TextAdd GetPlayerName(index) & " has been unmuted."
    Else
        Player(index).isMuted = 1
        ' Let them know
        PlayerMsg index, "You have been muted and can no longer talk in global.", BrightRed
        TextAdd GetPlayerName(index) & " has been muted."
    End If

    ' save the player
    SavePlayer index
End Sub
```
In modHandleData find
```
Private Sub HandleBroadcastMsg(ByVal index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)
```
In the sub there will be
```
msg = Buffer.ReadString
```Under that add
```
If Player(index).isMuted Then
        PlayerMsg index, "You have been muted and cannot talk in global.", BrightRed
        Exit Sub
    End If

```
In modTypes in 'Public Sub PlayerRec' just before End Type below
```
Dir As Byte
```Add
```
isMuted As Byte
```
Well that is it! Also the mute will work only in Global! Ill find a way to mute in Map too!
Credits: Riiicardo for showing me the tut ;)
Robin:For making it


abhi2011
Link to comment
Share on other sites

  • 4 weeks later...
@abhi2011:

> Ill find a way to mute in Map too!

For the map can't you just go:
```
If isMuted = 0 Then
    Call AddLog("Map #" & GetPlayerMap(index) & ": " & GetPlayerName(index) & " says, '" & Msg & "'", PLAYER_LOG)
        Call SayMsg_Map(GetPlayerMap(index), index, Msg, QBColor(White))
    End If

```Wouldn't that work? :/
Link to comment
Share on other sites

```
If Player(index).isMuted Then
        PlayerMsg index, "You have been muted and cannot talk in global.", BrightRed
        Exit Sub
    End If
```
You just need to add that same block of code to all the handlemsg subs server side easy.
Link to comment
Share on other sites

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