SA-MP Forums Archive
Will this send a message to only people who are silent? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Will this send a message to only people who are silent? (/showthread.php?tid=145947)



Will this send a message to only people who are silent? - Torran - 04.05.2010

pawn Код:
public OnPlayerText(playerid, text[])
{
    if(playerInSilent[playerid] == 1)
    {
      for(new i=0; i<MAX_PLAYERS; i++)
        {
          if(playerInSilent[i] == 1)
          {
            SendPlayerMessageToPlayer(i, playerid, text);
            return 0;
            }
        }
    }
    return 1;
}
Will that send a message to people who are only InSilent?
Because sometimes i cant speak, Sometimes others cant speak, Sometimes others cant see me speak, And sometimes i cant see them speak,

How would i do this? To send a message to all people who are silent IF im silent


Re: Will this send a message to only people who are silent? - dice7 - 04.05.2010

The message will be sent to all 'InSilent' players if the player who typed the message is also 'InSilent'


Re: Will this send a message to only people who are silent? - [HiC]TheKiller - 04.05.2010

Um,
pawn Код:
if(playerInSilent[i] == 1)
{
  SendPlayerMessageToPlayer(i, playerid, text);
  return 0; //Here is the problem ;).
}
It should be like this
pawn Код:
public OnPlayerText(playerid, text[])
{
    if(playerInSilent[playerid] == 1)
    {
      for(new i=0; i<MAX_PLAYERS; i++)
        {
          if(playerInSilent[i] == 1)
          {
            SendPlayerMessageToPlayer(i, playerid, text);
            }
        }
        return 0;
    }
    return 1;
}
If you return in a loop it will hault the loop there so only the lowest ID (First person in the loop) with PlayerIsSilent will see the message.


Re: Will this send a message to only people who are silent? - Torran - 04.05.2010

It works except when i talk.. Everytime i talk i cant see what i say but other silent room users can


Re: Will this send a message to only people who are silent? - [HiC]TheKiller - 05.05.2010

Quote:
Originally Posted by Joe Torran C
It works except when i talk.. Everytime i talk i cant see what i say but other silent room users can
Then just do this

pawn Код:
public OnPlayerText(playerid, text[])
{
    if(playerInSilent[playerid] == 1)
    {
      for(new i=0; i<MAX_PLAYERS; i++)
        {
          if(playerInSilent[i] == 1)
          {
            SendPlayerMessageToPlayer(i, playerid, text);
            SendClientMessage(playerid, COLOR, text);
            }
        }
        return 0;
    }
    return 1;
}
I don't see why it wouldn't work though, it's something with your SendPlayerMessageToPlayer function .