I need help on Pm
#1

if you type /dnd
Ppl cannot pming you it's block players from pming

how u make a /dnd
?
Reply
#2

Setup a variable.
pawn Код:
//top of script
new IsPlayerDND[MAX_PLAYERS];
On your pm cmd add
pawn Код:
if(IsPlayerDND[target variable...] == 0)
{
Then for /dnd
pawn Код:
CMD:dnd(playerid,params[])
{
IsPlayerDND[playerid] = 1;
return 1;
}
Reply
#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


Forum Jump:


Users browsing this thread: 1 Guest(s)