Hello,
GospodinX, there are some ways to do this, the first and easiest, is usal a Boolean variable to store the correct value with the player, as the example below:
PHP код:
new bool:BlockPMCheck[MAX_PLAYERS];
If you want to block the PM of any other player, when writing the command / blockpm you should change this value to
true;
So when a player sends a PM, just make sure that the player's variable that will receive the message is either
true or
false, EX:
PHP код:
if(BlockPMCheck[targetid] == false)
{
//Then the message will be sent
}
else
{
//Otherwise you are informed that the player has blocked the PM.
SendClientMessage(playerid, RED, "Player has blocked PM");
}
This is the simple way, and will block for all players, now if you want to block a specific person, then you just store the ID of the person you want to lock in the variable, let's look at the example:
You write
/blockpm 19 (id 19 for example)
Now the variable need not be more Boolean because it will store integer values, not just logical values;
PHP код:
new BlockPmID[MAX_PLAYERS]; //then you define the variable globally
As stated in the example above with id 19, when giving the command just save this value in the variable, that is, our variable
(BlockPmID) will be equal to 19.
Now you just need to check if the ID of the player who sent the PM is equal to or different from the ID stored in the variable:
PHP код:
if(BlockPmID[targetid] == GetPlayerID(playerid))
{
//If equal, you are informed that the player has blocked the PM.
SendClientMessage(playerid, RED, "Player has blocked you.");
}
else
{
//Otherwise, the message is sent.
}
OBS№ = The problem arises when GM is reset, or you Re-login in the server, because your variables are restored, so you have to lock again, but you can use
DOF2 to store the names of blocked players, so you do not have to lock all of them again when you are on the server,
CLICK HERE.
OBSІ = You can work with Arrays to store multiple ID's, I advise you to read about,
CLICK HERE.
OBSі = You can use too
ZCMD or
SSCANF for a better management of codes,
CLICK HERE.
The logic and concept are simple, I hope you have understood.