[QUESTION] Muting players?

Started by EK.IceFlake, Jan 23, 2015, 08:20 AM

Previous topic - Next topic

EK.IceFlake

I recently tried muting players with:
[instance].IsMuted = true;
and with
[instance].Muted = true;
both of these cause an error (Member variable not found).
Any function to mute?

MatheuS

#1
Muted <-array(GetMaxPlayers(),0);

function onPlayerJoin( player )
{
              Muted[player.ID] = 0;
}

else if( cmd =="mute" )
{
  local p = FindPlayer( text );
          if ( !p )
  {
  MessagePlayer("[#FF0000]Error: Unknown Player.", player );
  return;
  }
else if ( !text ) MessagePlayer("[#FF0000][Syntax] - /" + cmd + " <PlayerNAME/ID>", player );
            else
{
                          Muted[ p.ID ] = true;
}
}

function onPlayerChat( player, message )
{
          if( Muted[ player.ID ] == true )
          {
           MessagePlayer("You are muted", player );
           return 0;
          }
}

This is an example ;)
if( !sucess ) tryAgain();
Thanks to the VCMP community. It was the happiest period of my life.

Thijn

@MatheuS
1. You should check for text first before trying to FindPlayer it. While it may work, it isn't pretty.
2. You are Mutated? lol.

MatheuS

@Thijn
1. You should check for text first before trying to FindPlayer it. While it may work, it isn't pretty.
I think he will not use it all that I put, I tried to explain to him how it should be

2. You are Mutated? lol.

Fixed!
if( !sucess ) tryAgain();
Thanks to the VCMP community. It was the happiest period of my life.

Thijn

Still best to give a good example then.

EK.IceFlake

Quote from: MatheuS on Jan 23, 2015, 09:26 AMMuted <-array(GetMaxPlayers(),0);

function onPlayerJoin( player )
{
              Muted[player.ID] = 0;
}

else if( cmd =="mute" )
{
  local p = FindPlayer( text );
          if ( !p )
  {
  MessagePlayer("[#FF0000]Error: Unknown Player.", player );
  return;
  }
else if ( !text ) MessagePlayer("[#FF0000][Syntax] - /" + cmd + " <PlayerNAME/ID>", player );
            else
{
                          Muted[ p.ID ] = true;
}
}

function onPlayerChat( player, message )
{
          if( Muted[ player.ID ] == true )
          {
           MessagePlayer("You are muted", player );
           return 0;
          }
}

This is an example ;)
thanks