SA-MP Forums Archive
ID 0 cant 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: ID 0 cant pm (/showthread.php?tid=551630)



ID 0 cant pm - DavidSparks - 20.12.2014

Sup guys.

I have a problem with my new /blockpm feature, ID 0 is auto blocked from every other id.

How to fix this?

Here is the PM command

Код:
CMD:pm(playerid, params[])
{
    new str[128], str2[128], id, Name1[MAX_PLAYER_NAME], Name2[MAX_PLAYER_NAME];
    if(sscanf(params, "us", id, str2))
    {
        SendClientMessage(playerid, COLOR_YELLOW, "Usage: /pm <id> <message>");
        return 1;
    }
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_YELLOW, "ERROR: Player not connected");
    if(BlockPM[playerid] == id) return SendClientMessage(playerid, COLOR_YELLOW, "ERROR: You cannot pm this player because he has blocked you from doing so.");
    if(GetPVarInt(id,"NoPM") == 1) return SendClientMessage(playerid, COLOR_GREY,"ERROR: That player has disabled Private Messages.");
    if(playerid == id) return SendClientMessage(playerid, COLOR_YELLOW, "ERROR: You cannot pm yourself!");
    {
        GetPlayerName(playerid, Name1, sizeof(Name1));
        GetPlayerName(id, Name2, sizeof(Name2));
        sscanf(params, "ds[128]", id, str2);
        format(str, sizeof(str), "(( PM To %s(ID %d): %s ))", Name2, id, str2);
        SendClientMessage(playerid, COLOR_YELLOW, str);
        sscanf(params, "ds[128]", id, str2);
        format(str, sizeof(str), "(( PM From %s(ID %d): %s ))", Name1, playerid, str2);
        SendClientMessage(id, COLOR_YELLOW, str);
    }
    return 1;
}
Here is the /blockpm command and the /unblockpm

Код:
CMD:blockpm(playerid, params[])
{
 new victim;
    if(sscanf(params, "u", victim))
    {
        SendClientMessage(playerid, COLOR_YELLOW, "Usage: /blockpm [playerid]");
        return 1;
    }
 BlockPM[playerid] = victim;
  return 1;
}

CMD:unblockpm(playerid, params[])
{
 new victim;
    if(sscanf(params, "u", victim))
    {
        SendClientMessage(playerid, COLOR_YELLOW, "Usage: /unblockpm [playerid]");
        return 1;
    }
 BlockPM[playerid] = 0;
  return 1;
}
And this is my new...

Код:
new BlockPM[MAX_PLAYERS];
All help is appreciated.


Re: ID 0 cant pm - AdHaM612 - 20.12.2014

pawn Код:
BlockPM[playerid] = 0;
That means that you have blocked ID 0.
The correct one:
pawn Код:
BlockPM[playerid] = -1;
Because there is no ID -1.


Re: ID 0 cant pm - cessil - 20.12.2014

you can default an array values when its created
new BlockPM[MAX_PLAYERS] = { -1, ... };


Re: ID 0 cant pm - DavidSparks - 20.12.2014

Thanks.


Re: ID 0 cant pm - DavidSparks - 20.12.2014

Not working..


Re: ID 0 cant pm - DavidSparks - 20.12.2014

BUMP.


Re: ID 0 cant pm - Abagail - 20.12.2014

pawn Код:
new BlockPM[MAX_PLAYERS] = INVALID_PLAYER_ID;

public OnPlayerConnect(playerid)
{
       BlockPM[playerid] = INVALID_PLAYER_ID;
       return true;
}

public OnPlayerDisconnect(playerid, reason)
{
      #pragma unused reason
      BlockPM[playerid] = INVALID_PLAYER_ID;
      return true;
}



Re: ID 0 cant pm - AmirSlaYeR - 20.12.2014

Quote:

pawn Code:
new BlockPM[MAX_PLAYERS] = INVALID_PLAYER_ID;

public OnPlayerConnect(playerid)
{
BlockPM[playerid] = INVALID_PLAYER_ID;
return true;
}

public OnPlayerDisconnect(playerid, reason)
{
#pragma unused reason
BlockPM[playerid] = INVALID_PLAYER_ID;
return true;
}
__________________

Yes She/He's Right