PDA

View Full Version : [HELP] Disable Chat to certain player, please.


Avalanche!
28/09/2011, 10:45 PM
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.

grand.Theft.Otto
28/09/2011, 11:18 PM
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 ?

Avalanche!
28/09/2011, 11:45 PM
???

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

brett7
29/09/2011, 12:03 AM
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.

Babul
29/09/2011, 12:33 AM
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:

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:

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)

OnPlayerRequestClass(playerid, classid){
//...
AllowChat[playerid]=0;
//...
}

to allow the chat after spawn:

OnPlayerSpawn(playerid, classid){
//...
AllowChat[playerid]=1;
//...
}

not tested, its the concept idea only, but i hope you get how simple it works ^^

Scenario
29/09/2011, 12:40 AM
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?

brett7
29/09/2011, 12:43 AM
Now i think about it using something like

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.