/NOPM - Disable Received PMs For Player -
15outland - 24.09.2013
Hi,
So I am trying to add a "/nopm" command to my gamemode, where when the player enters "/nopm", they won't be able to receive PMs, and if someone tries to PM that person, they get a message saying that the player is not accepting PMS.
pawn Код:
// placed top of script
new NoPM[MAX_PLAYERS];
// In OnPlayerConnect
NoPM[playerid] == 0;
// placed along side other commands..
CMD:nopm(playerid, params[])
{
if(NoPM[playerid] == 1)
{
SendClientMessage(playerid, COLOR_WHITE, "You are now accepting PMs");
NoPM[playerid] == 0;
return 1;
}
else if(NoPM[playerid] == 0)
{
SendClientMessage(playerid, COLOR_WHITE, "You are no longer accepting PMs");
NoPM[playerid] == 1;
return 1;
}
}
// placed on bottom of script
public OnPlayerPrivmsg(playerid, recieverid, text[])
{
if(NoPM[recieverid] == 1)
{
SendClientMessage(playerid, COLOR_GREY, "This player has NO PM turned on, Try again later");
return 1;
}
return 0;
}
Problem is, when I type the command, it says - "You are no longer accepting PMs", but if I type it again, it just says that same thing over and over, and don't understand why.
Re: /NOPM - Disable Received PMs For Player -
CoaPsyFactor - 24.09.2013
If this is filterscript then problem is solved, you can't block private message from filterscript with returning 0 in OnPlayerPrivmsg.
Re: /NOPM - Disable Received PMs For Player -
15outland - 24.09.2013
Oh, I apologize. No, it isn't a Filterscript, it's actually integrated into the gamemode itself.
I haven't actually had the chance to see if the messages are actually getting blocked, but the problem I am experiencing as of now, once I type the command, and it goes "you are not accepting PMs now" - Once I type it again to allow PMs, it doesn't say "Your now accepting PMs" - It keeps going as if NoPM is constantly set to true, so it just says "your not accepting PMs now" every time I type the command.
Re: /NOPM - Disable Received PMs For Player -
15outland - 25.09.2013
anyone know?
Re: /NOPM - Disable Received PMs For Player -
Bit - 25.09.2013
OnPlayerPrivMsg is removed, and won't work in 0.3x servers. I think the whole thing is due to the removed function.
Re: /NOPM - Disable Received PMs For Player -
15outland - 25.09.2013
Oh, okay, I guess that's possible. I would have thought when typed out a second time, the status would've changed, at least for the player who typed the command, and states it is either accepting or not.
How would I counter this? Is there an alternative?
Re: /NOPM - Disable Received PMs For Player -
JamesH - 25.09.2013
Quote:
Originally Posted by 15outland
Oh, okay, I guess that's possible. I would have thought when typed out a second time, the status would've changed, at least for the player who typed the command, and states it is either accepting or not.
How would I counter this? Is there an alternative?
|
You can use "sscanf" or you can use "if" and "else".
I made it for you with sscanf so basicly when you type "/turnpm off" it turns it off,
and when you type "/turnpm on" it turns it on.
pawn Код:
COMMAND:turnpms(playerid, params[])
{
new tmp[15];
if( sscanf ( params, "s", tmp)) return SCP(playerid, "/turnpms on/off");
if(strcmp(tmp,"off",true)==0)//1 enable 0 = disable
{
if(NoPM[playerid] == 0) return SendClientMessage(playerid, WHITE, "already off");
NoPM[playerid] == 0;
SendClientMessage(playerid, WHITE, "PMS OFF");
}
if(strcmp(tmp,"on",true)==0)
{
if(NoPM[playerid] == 1) return SendClientMessage(playerid, WHITE, "already on");
NoPM[playerid] == 1;
SendClientMessage(playerid, WHITE, "PMS OFF");
}
return 1;
}
If you want the command to be 1 command like /turnpm and you want it to decet automaticly the varaible
you will need to use if(NoPM[playerid] == 1) and else.
Good luck
Re: /NOPM - Disable Received PMs For Player -
15outland - 25.09.2013
wow, thanks a lot man, I really appreciate that
By the way, I am little confused, which part of the code send a message to the player sending a PM to someone with NO PM on, saying the recipient has 'NO PM' turned on, and then blocks the message?
Re: /NOPM - Disable Received PMs For Player -
JamesH - 25.09.2013
Well that you can add in the command itself
pawn Код:
if(NoPM[ThePlayerYouPm] != 1) return SendClientMessage(playerid, color, "cant send pm he turned his pms off");
Re: /NOPM - Disable Received PMs For Player -
15outland - 25.09.2013
Yeah okay, sorry, thanks.