PM Block
#1

Код:
if(strcmp("/pm", cmd, true) == 0)
{
tmp = strtok(cmdtext,idx);

if(!strlen(tmp) || strlen(tmp) > 5) {
SendClientMessage(playerid,COLOR_YELLOW,"Usage: /pm (id) (message)");
return 1;
}

new id = strval(tmp);
gMessage = strrest(cmdtext,idx);

if(!strlen(gMessage)) {
SendClientMessage(playerid,COLOR_YELLOW,"Usage: /pm (id) (message)");
return 1;
}

if(!IsPlayerConnected(id)) {
SendClientMessage(playerid,COLOR_YELLOW,"ERROR: Wrong player ID!");
return 1;
}
if(blocked[giveplayerid] > -1)
{
SendClientMessage(playerid, COLOR_GREY, "  That player is blocking PMs from everyone !");
return 1;
}
if(blocked[giveplayerid] > 1)
{
SendClientMessage(playerid, COLOR_GREY, "  That player has blocked you from PMing him/her !");
return 1;
}
if(playerid != id) {
GetPlayerName(id,iName,sizeof(iName));
GetPlayerName(playerid,pName,sizeof(pName));
format(Message,sizeof(Message),"PM Sent to %s(%d): %s",iName,id,gMessage);
SendClientMessage(playerid,COLOR_YELLOW,Message);
format(Message,sizeof(Message),"PM From %s(%d): %s",pName,playerid,gMessage);
SendClientMessage(id,COLOR_YELLOW,Message);
PlayerPlaySound(id,1085,0.0,0.0,0.0);

printf("PM: %s",Message);

}
else {
SendClientMessage(playerid,COLOR_YELLOW,"You cannot PM yourselfq");
}
return 1;
}
Won't let people send PM's at all. ideas?
Reply
#2

This is my /pm command works fine

Код:
// Personal Message
	if (strcmp("/pm", cmd, true) == 0)
	{
		tmp = strtok(cmdtext,idx);
		if(!strlen(tmp) || strlen(tmp) > 5)
		{
			SendClientMessage(playerid,COLOR_LIGHTBLUE,"* Usage: /pm [Player ID] [message]");
			return 1;
		}
		giveplayerid = strval(tmp);
		tmp = strtok(cmdtext, idx, strlen(cmdtext));
		if(!strlen(tmp))
		{
			SendClientMessage(playerid,COLOR_LIGHTBLUE,"* Usage: /pm [Player ID] [message]");
			return 1;
		}
		if(!IsPlayerConnected(giveplayerid))
		{
			format(string, sizeof(string), "* ID:%d Was not found on the server", giveplayerid);
			SendClientMessage(playerid, COLOR_BRIGHTRED, string);
			return 1;
		}
		if(playerid != giveplayerid)
		{
			GetPlayerName(giveplayerid,giveplayer,sizeof(giveplayer));
			GetPlayerName(playerid,playername,sizeof(playername));
			format(string,sizeof(string),"* You Sent %s (%d): %s",giveplayer,giveplayerid,tmp);
			SendClientMessage(playerid,COLOR_WHITE,string);
			format(string,sizeof(string),"* PM From %s (%d): %s",playername,playerid,tmp);
			SendClientMessage(giveplayerid,COLOR_DBLUE,string);
			PlayerPlaySound(giveplayerid,1085,0.0,0.0,0.0);
			format(string,sizeof(string),"PM From %s(%d) To %d(%d): %s ",playername,playerid,giveplayer,giveplayerid,tmp);
			printf("%s",string);
			return 1;
		}
		else {
			SendClientMessage(playerid,COLOR_WHITE,"* You cannot PM yourself");
		}
		return 1;
	}
if your going to copy that into your script you will proabably need to define a few variables

and for
Код:
if(blocked[giveplayerid] > -1)
{
SendClientMessage(playerid, COLOR_GREY, "  That player is blocking PMs from everyone !");
return 1;
}
if(blocked[giveplayerid] > 1)
{
SendClientMessage(playerid, COLOR_GREY, "  That player has blocked you from PMing him/her !");
return 1;
}
that is checking if both the id's are greater than either -1 or 1 it's still the same and in the way that you coded it... giveplayerid should be just id as you haven't defined giveplayerid in the command
Reply
#3

Here

Код:
if(blocked[giveplayerid] > -1)
{
SendClientMessage(playerid, COLOR_GREY, "  That player is blocking PMs from everyone !");
return 1;
}
if(blocked[giveplayerid] > 1)
{
SendClientMessage(playerid, COLOR_GREY, "  That player has blocked you from PMing him/her !");
return 1;
}
Do this

Код:
if(blocked[giveplayerid] == 1)
{
SendClientMessage(playerid, COLOR_GREY, "  That player is blocking PMs from everyone !");
return 1;
}
if(blocked[giveplayerid] == 1)
{
SendClientMessage(playerid, COLOR_GREY, "  That player has blocked you from PMing him/her !");
return 1;
}
Reply
#4

Quote:
Originally Posted by AdrianX9
Here

Код:
if(blocked[giveplayerid] > -1)
{
SendClientMessage(playerid, COLOR_GREY, "  That player is blocking PMs from everyone !");
return 1;
}
if(blocked[giveplayerid] > 1)
{
SendClientMessage(playerid, COLOR_GREY, "  That player has blocked you from PMing him/her !");
return 1;
}
Do this

Код:
if(blocked[giveplayerid] == 1)
{
SendClientMessage(playerid, COLOR_GREY, "  That player is blocking PMs from everyone !");
return 1;
}
if(blocked[giveplayerid] == 1)
{
SendClientMessage(playerid, COLOR_GREY, "  That player has blocked you from PMing him/her !");
return 1;
}
erm.. that's still the same thing
Reply
#5

Look here if(blocked[giveplayerid] > -1)

If blocked > -1, it says if giveplayerid blocked 0, 1, 2 or 3...etc it will say SendClientMessage(playerid, COLOR_GREY, " That player is blocking PMs from everyone !");


But if this is == 1 only if is 1, normally giveplayerid need to be 0, he must do a code to /blockpm.
Reply
#6

iLcke it works?
Reply
#7

Don't know. Testing, will edit post or something saying it worked
Reply
#8

double post cause ic an,


YouRock<3
Reply
#9

Thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)