20.06.2012, 13:47
Hello! I'm wondering if there are any ways to disable the chat for a certain player? For example if a player writes /disablechat they would not be able to see anything that other players write. How can I do this?
new AllowChat[MAX_PLAYERS];
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;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/disablechat", cmdtext, true) == 0)
{
if(AllowChat[playerid] == 1)
{
AllowChat[playerid]=0;
}
else
{
AllowChat[playerid]=1;
}
return 1;
}
return 0;
}
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 0; // You also need to return 0 here so that it doesn't continue and show their text anyway
}
return 1;
}
pawn Code:
|
Alternative way:
Press F1 while in-game you will get some shortcuts key. Which has chat disabling key which you want. I think its F9. |