I need help on Pm
#3

Well, it's quite simple, really.

First make a global bool to store information if the certain playerid is DnD or not:
pawn Код:
g_IsDnD[ MAX_PLAYERS ]; //The array is to be to set for individual players
Then you have to make sure it's set to false when players disconnects, so that it won't stay activated after a player leaves and another one joins with the same playerid
pawn Код:
//OnPlayerDisconnect
g_IsDnD[ playerid ] = false;
Now you may create your command, which should simply toggle the g_IsDnD variable; something like this:
pawn Код:
CMD:dnd(playerid, params[]) //zcmd
{
    if( g_IsDnD[ playerid ] )
    {
        g_IsDnD[ playerid ] = false;
    }
    else
    {
        g_IsDnD[ playerid ] = true;
    }
    return true;
}
Now, for the OnPlayerPrivMsg callback, simply insert this piece of code:
pawn Код:
//OnPlayerPrivMsg
if( g_IsDnD[ recieverid ] ) //you want to check if the reciever is DnD, not the sender(playerid)
{
    return false; //return the callback to not execute more code - make it false to not send the message
}
And there you have it.
Reply


Messages In This Thread
I need help on Pm - by DerickClark - 11.01.2013, 17:40
Re: I need help on Pm - by Infinity90 - 11.01.2013, 17:44
Re: I need help on Pm - by LarzI - 11.01.2013, 17:49

Forum Jump:


Users browsing this thread: 1 Guest(s)