SA-MP Forums Archive
[HELP] Disable Chat to certain player, please. - 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)
+--- Thread: [HELP] Disable Chat to certain player, please. (/showthread.php?tid=286458)



[HELP] Disable Chat to certain player, please. - Avalanche! - 28.09.2011

So, if someone can help me I want to make a system to disable messages to a player.
ex: If I'm on Request Class, and people type messages in chat, I can read them, but I want to make a system that I can't read them.

Thanks a lot.


Re: [HELP] Disable Chat to certain player, please. - grand.Theft.Otto - 28.09.2011

Quote:
Originally Posted by Avalanche!
View Post
So, if someone can help me I want to make a system to disable messages to a player.
ex: If I'm on Request Class, and people type messages in chat, I can read them, but I want to make a system that I can't read them.

Thanks a lot.


Anyways, you're saying you want chat to be disabled when they are in Class Selection, but when they are spawned, you want it to be enabled ?


Re: [HELP] Disable Chat to certain player, please. - Avalanche! - 28.09.2011

Quote:
Originally Posted by grand.Theft.Otto
View Post


Anyways, you're saying you want chat to be disabled when they are in Class Selection, but when they are spawned, you want it to be enabled ?
I'm saying that who is on Request Class can't read what players type, but when he spawn, he can read normally.

sorry 4 my bad english. haha


Re: [HELP] Disable Chat to certain player, please. - brett7 - 29.09.2011

I don't think it is possible to stop a player being sent messages as far as i know although I could be wrong. You could try placing a solid colour textdraw over it.


Re: [HELP] Disable Chat to certain player, please. - Babul - 29.09.2011

usually the SendClientMessageToAll() gets used for sending a chat to all players. what you need, is an array holding all players, with a value to allow the chat output:
Code:
new AllowChat[MAX_PLAYERS];
then, instead of SendClientMessageToAll(), make a loop, checking if the AllowChat[playerid]==1 - if set to 0 (when logging in, ergo not set to 1 before spawning), then dont send the chat line. this will require a bit processing time due to the loop:
Code:
public OnPlayerText(playerid, text[]){
//SendClientMessageToAll(0xffffffff,text); //disabled this, and replaced by the following loop:
new MaxPlayers=GetMaxPlayers();
for(new id=0;id<MaxPlayers;id++)
{
	if(AllowChat[id]==1)// dont forget to set this to 1 when spawning!
	{
		SendClientMessage(id,0xffffffff,text);
	}
	return 1;
}
suppress chat on skin selection (i would use the OnPlayerConnect here aswell)
Code:
OnPlayerRequestClass(playerid, classid){
	//...
	AllowChat[playerid]=0;
	//...
}
to allow the chat after spawn:
Code:
OnPlayerSpawn(playerid, classid){
	//...
	AllowChat[playerid]=1;
	//...
}
not tested, its the concept idea only, but i hope you get how simple it works ^^


Re: [HELP] Disable Chat to certain player, please. - Scenario - 29.09.2011

Couldn't you redefine "SendClientMessageToAll" and make a custom function that will do the same thing as "SendClientMessageToAll" except it will exclude those in class selection via a variable?


Re: [HELP] Disable Chat to certain player, please. - brett7 - 29.09.2011

Now i think about it using something like
pawn Code:
stock SendClientMessageToAllEx(exception, color, const message[])
{
  for(new i; i<MAX_PLAYERS; i++)
  {
    if(IsPlayerConnected(i))
    {
      if(i != exception)
      {
        SendClientMessage(i, color, message);
      }
    }
  }
}
But using a variable which holds whether the player has spawned or not.