SA-MP Forums Archive
Dont disturb mode. - 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: Dont disturb mode. (/showthread.php?tid=470405)



Dont disturb mode. - Alex_Obando - 17.10.2013

Hey guys,

I would like to know what would be the function to
DISABLE chat for a player so when you do /dnd the playerid will not recieve ANY global chat messages while the chat keeps going for the other players

/dndoff = ChatEnable = 1 (then the player can now see the global chat)


Re: Dont disturb mode. - Campbell- - 17.10.2013

Return 0 in OnPlayerText() and use SendClientMessage() and foreach in combination with an if-statement instead.


Respuesta: Dont disturb mode. - Alex_Obando - 17.10.2013

Example please?


Re: Dont disturb mode. - xVIP3Rx - 17.10.2013

Here you go
pawn Код:
new Chat[MAX_PLAYERS];

public OnPlayerConnect(playerid)
{
    Chat[playerid] = 1;
    return 1;
}

CMD:dnd(playerid, params[])
{
    if(Chat[playerid] == 1)
    {
        SendClientMessage(playerid, -1, "You turned mainchat off");
        Chat[playerid] = 0;
    }
    else if(Chat[playerid] == 0)
    {
        SendClientMessage(playerid, -1, "You turned mainchat on");
        Chat[playerid] = 1;
    }
    return 1;
}

public OnPlayerText(playerid, text[])
{
    foreach(Player, i)
    {
        if(Chat[i] == 1)
        {
            SendClientMessage(i, -1, text);
        }
    }
    return 0;
}
Try it, And use a loop through all players instead of you don't have foreach include