SA-MP Forums Archive
I need help on Pm - 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: I need help on Pm (/showthread.php?tid=406799)



I need help on Pm - DerickClark - 11.01.2013

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

how u make a /dnd
?


Re: I need help on Pm - Infinity90 - 11.01.2013

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;
}



Re: I need help on Pm - LarzI - 11.01.2013

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.