Disable PM
#1

Hi. I have problem with my pm script. The problem is that, I already disabled my pm. So I will not receive any pm from any players. But I still received their pm even I disabled receiving pm's. Here is the script..

Код:

SetPVarInt(playerid, "PMEnabled", 1) <------ OnPlayerConnect

CMD:pm(playerid,params[])
{
	if(PmDialog == 1)
	{
        new id;
        if(sscanf(params, "u", id)) return SendClientMessage(playerid, lighterblue, "Usage: /pm <PlayerID/Part of Nick>");
		if(IsPlayerConnected(id))
		{
		    if(GetPVarInt(playerid, "PMEnabled") == 0)
      		{
      			pInfo[playerid][Clicked] = id;
	     		format(Jstring,sizeof(Jstring),"PM To %s(ID: %d) Type you message:", GetName(id), id);
				return ShowPlayerDialog(playerid,DIALOG_PRIVATE_MESSAGE,DIALOG_STYLE_INPUT,"Private Message",Jstring,"Send","Cancel");
			}
			return GameTextForPlayer(playerid, "~n~~n~~r~Player Disabled PM", 3000, 5);
		}
		else return ShowMessage(playerid, red, 2);
	}
	else
	{
        new id,Message[128];
        if(sscanf(params, "us[128]",id, Message)) return SendClientMessage(playerid, lighterblue, "Usage: /pm <PlayerID/Part of Nick> <Message>");
		if(IsPlayerConnected(id))
		{
  			if(GetPVarInt(playerid, "PMEnabled") == 0)
  			{
             	return OnPrivateMessage(playerid, id, Message);
			}
			return GameTextForPlayer(playerid, "~n~~n~~r~Player Disabled PM", 3000, 5);
		}
		else return ShowMessage(playerid, red, 2);
	}
}

CMD:pms(playerid, params[])
{
    if(GetPVarInt(playerid, "PMEnabled") == 1)
    {
        SetPVarInt(playerid, "PMEnabled", 0);
        GameTextForPlayer(playerid, "~y~PM ~r~Disabled", 2000, 3);
    }
    else
    {
		SetPVarInt(playerid, "PMEnabled", 1);
        GameTextForPlayer(playerid, "~y~PM ~g~Enabled", 2000, 3);
    }
    return 1;
}
Reply
#2

pawn Код:
if(GetPVarInt(id, "PMEnabled") == 0) //Change to this
Before you were checking if the sender had PM enabled not the receiver.
Does this work?
Reply
#3

pawn Код:
CMD:pm(playerid,params[])
{
    if(PmDialog == 1)
    {
        new id;
        if(sscanf(params, "u", id)) return SendClientMessage(playerid, lighterblue, "Usage: /pm <PlayerID/Part of Nick>");
        if(!IsPlayerConnected(id)) return ShowMessage(playerid, red, 2);
        if(GetPVarInt(id, "PMEnabled") == 1) return GameTextForPlayer(playerid, "~n~~n~~r~Player Disabled PM", 3000, 5);
       
        pInfo[playerid][Clicked] = id;
        format(Jstring,sizeof(Jstring),"PM To %s(ID: %d) Type you message:", GetName(id), id);
        ShowPlayerDialog(playerid,DIALOG_PRIVATE_MESSAGE,DIALOG_STYLE_INPUT,"Private Message",Jstring,"Send","Cancel");
    }
    else
    {
        new id,Message[128];
        if(sscanf(params, "us[128]",id, Message)) return SendClientMessage(playerid, lighterblue, "Usage: /pm <PlayerID/Part of Nick> <Message>");
        if(!IsPlayerConnected(id)) return ShowMessage(playerid, red, 2);
        if(GetPVarInt(id, "PMEnabled") == 1) return GameTextForPlayer(playerid, "~n~~n~~r~Player Disabled PM", 3000, 5);

        OnPrivateMessage(playerid, id, Message);
    }
    return 1;
}

CMD:pms(playerid, params[])
{
    if(GetPVarInt(playerid, "PMEnabled") == 1)
    {
        SetPVarInt(playerid, "PMEnabled", 0);
        GameTextForPlayer(playerid, "~y~PM ~r~Disabled", 2000, 3);
    }
    else
    {
        SetPVarInt(playerid, "PMEnabled", 1);
        GameTextForPlayer(playerid, "~y~PM ~g~Enabled", 2000, 3);
    }
    return 1;
}
Reply
#4

Quote:
Originally Posted by knackworst
Посмотреть сообщение
pawn Код:
if(GetPVarInt(id, "PMEnabled") == 0) //Change to this
Before you were checking if the sender had PM enabled not the receiver.
Does this work?
Quote:
Originally Posted by ]Rafaellos[
Посмотреть сообщение
pawn Код:
CMD:pm(playerid,params[])
{
    if(PmDialog == 1)
    {
        new id;
        if(sscanf(params, "u", id)) return SendClientMessage(playerid, lighterblue, "Usage: /pm <PlayerID/Part of Nick>");
        if(IsPlayerConnected(id)) return ShowMessage(playerid, red, 2);
        if(GetPVarInt(id, "PMEnabled") == 1) return GameTextForPlayer(playerid, "~n~~n~~r~Player Disabled PM", 3000, 5);
       
        pInfo[playerid][Clicked] = id;
        format(Jstring,sizeof(Jstring),"PM To %s(ID: %d) Type you message:", GetName(id), id);
        ShowPlayerDialog(playerid,DIALOG_PRIVATE_MESSAGE,DIALOG_STYLE_INPUT,"Private Message",Jstring,"Send","Cancel");
    }
    else
    {
        new id,Message[128];
        if(sscanf(params, "us[128]",id, Message)) return SendClientMessage(playerid, lighterblue, "Usage: /pm <PlayerID/Part of Nick> <Message>");
        if(IsPlayerConnected(id)) return ShowMessage(playerid, red, 2);
        if(GetPVarInt(id, "PMEnabled") == 1) return GameTextForPlayer(playerid, "~n~~n~~r~Player Disabled PM", 3000, 5);

        OnPrivateMessage(playerid, id, Message);
    }
    return 1;
}

CMD:pms(playerid, params[])
{
    if(GetPVarInt(playerid, "PMEnabled") == 1)
    {
        SetPVarInt(playerid, "PMEnabled", 0);
        GameTextForPlayer(playerid, "~y~PM ~r~Disabled", 2000, 3);
    }
    else
    {
        SetPVarInt(playerid, "PMEnabled", 1);
        GameTextForPlayer(playerid, "~y~PM ~g~Enabled", 2000, 3);
    }
    return 1;
}
Knackworst - Where should I put if(GetPVarInt(id, "PMEnabled") == 0)?

and to Rafaellos - Not working. It says Player is not connected, when I do /pm [id] Also the dialog has gone its not showing.
Reply
#5

Quote:
Originally Posted by kbalor
Посмотреть сообщение
Rafaellos - Not working. It says Player is not connected, when I do /pm [id] Also the dialog has gone its not showing.
You did /pm ID, but the ID was connected?
Reply
#6

pawn Код:
SetPVarInt(playerid, "PMEnabled", 1) <------ OnPlayerConnect

CMD:pm(playerid,params[])
{
    if(PmDialog == 1)
    {
        new id;
        if(sscanf(params, "u", id)) return SendClientMessage(playerid, lighterblue, "Usage: /pm <PlayerID/Part of Nick>");
        if(IsPlayerConnected(id))
        {
            if(GetPVarInt(id, "PMEnabled") == 0) //changed here
            {
                pInfo[playerid][Clicked] = id;
                format(Jstring,sizeof(Jstring),"PM To %s(ID: %d) Type you message:", GetName(id), id);
                return ShowPlayerDialog(playerid,DIALOG_PRIVATE_MESSAGE,DIALOG_STYLE_INPUT,"Private Message",Jstring,"Send","Cancel");
            }
            return GameTextForPlayer(playerid, "~n~~n~~r~Player Disabled PM", 3000, 5);
        }
        else return ShowMessage(playerid, red, 2);
    }
    else
    {
        new id,Message[128];
        if(sscanf(params, "us[128]",id, Message)) return SendClientMessage(playerid, lighterblue, "Usage: /pm <PlayerID/Part of Nick> <Message>");
        if(IsPlayerConnected(id))
        {
            if(GetPVarInt(id, "PMEnabled") == 0) //and here too
            {
                return OnPrivateMessage(playerid, id, Message);
            }
            return GameTextForPlayer(playerid, "~n~~n~~r~Player Disabled PM", 3000, 5);
        }
        else return ShowMessage(playerid, red, 2);
    }
}

CMD:pms(playerid, params[])
{
    if(GetPVarInt(playerid, "PMEnabled") == 1)
    {
        SetPVarInt(playerid, "PMEnabled", 0);
        GameTextForPlayer(playerid, "~y~PM ~r~Disabled", 2000, 3);
    }
    else
    {
        SetPVarInt(playerid, "PMEnabled", 1);
        GameTextForPlayer(playerid, "~y~PM ~g~Enabled", 2000, 3);
    }
    return 1;
}
Reply
#7

Quote:
Originally Posted by ]Rafaellos[
Посмотреть сообщение
You did /pm ID, but the ID was connected?
You had:
pawn Код:
if(IsPlayerConnected(id)) return ShowMessage(playerid, red, 2);
You forgot the exclamation mark (!) before IsPlayerConnected function, so if the player is connected - it returns an error.
Reply
#8

Yeap, you have right I will edit my first post. Copy it from there again, will work.
Reply
#9

]Rafaellos[ - I made some modification, I removed the isplayerconnected so the "player is not connected" will not show again. But still after I disbled my pm. And I do pm myself I can still received it. EDIT: Actually Iam the only one in the server so I tested it from myself.

knackworst - Sorry but what you mean by "changed here"?
Reply
#10

pawn Код:
// OnPlayerConnect:
SetPVarInt(playerid, "PMEnabled", 1);

CMD:pm(playerid,params[])
{
    if(PmDialog == 1)
    {
        new id;
        if(sscanf(params, "u", id)) return SendClientMessage(playerid, lighterblue, "Usage: /pm <PlayerID/Part of Nick>");
        if(!IsPlayerConnected(id)) return ShowMessage(playerid, red, 2);
        if(GetPVarInt(playerid, "PMEnabled") == 0) return GameTextForPlayer(playerid, "~n~~n~~r~Player Disabled PM", 3000, 5);
        pInfo[playerid][Clicked] = id;
        format(Jstring,sizeof(Jstring),"PM To %s(ID: %d) Type you message:", GetName(id), id);
        ShowPlayerDialog(playerid,DIALOG_PRIVATE_MESSAGE,DIALOG_STYLE_INPUT,"Private Message",Jstring,"Send","Cancel");
    }
    else
    {
        new id,Message[128];
        if(sscanf(params, "us[128]",id, Message)) return SendClientMessage(playerid, lighterblue, "Usage: /pm <PlayerID/Part of Nick> <Message>");
        if(!IsPlayerConnected(id)) return ShowMessage(playerid, red, 2);
        if(GetPVarInt(playerid, "PMEnabled") == 0) return GameTextForPlayer(playerid, "~n~~n~~r~Player Disabled PM", 3000, 5);
        OnPrivateMessage(playerid, id, Message);
    }
    return 1;
}

CMD:pms(playerid, params[])
{
    if(GetPVarInt(playerid, "PMEnabled") == 1)
    {
        SetPVarInt(playerid, "PMEnabled", 0);
        GameTextForPlayer(playerid, "~y~PM ~r~Disabled", 2000, 3);
    }
    else
    {
        SetPVarInt(playerid, "PMEnabled", 1);
        GameTextForPlayer(playerid, "~y~PM ~g~Enabled", 2000, 3);
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)