PM message is sending the Sender's ID
#1

Hey guys, today I was editing and testing my script, and I noticed that when I use my PM command, it sends the person who is sending the message, his ID with the message to the receiver.

How may I fix this? I have tried deleting the parameters but that didn't seem to help.

PS: Please don't add an sscanf solution, I have no idea on how to install the plugin and don't intend spending time to install, then learn how to use.

pawn Код:
dcmd_pm(playerid,params[])
{
    new id,string[256],pName[MAX_PLAYER_NAME],pName2[MAX_PLAYER_NAME];
    //id = strval(params);
    if(strlen(params) == 0)
    {
        SendClientMessage(playerid, COLOR_ERROR,"ERROR: /pm [id][message]");
        PlayerPlaySound(playerid, 1053, 0.0, 0.0, 0.0);
    }
    if(GetPVarInt(id,"NoPM") == 1)
    {
        SendClientMessage(playerid, COLOR_ERROR,"ERROR: Currently, that player's PM is set to: OFF!");
        PlayerPlaySound(playerid, 1053, 0.0, 0.0, 0.0);
    }
    GetPlayerName(playerid,pName,sizeof(pName));
    GetPlayerName(id,pName2,sizeof(pName2));
    format(string,sizeof(string),"PM from %s: %s",pName,params);
    SendClientMessage(id,0xFFFF00FF,string);
    PlayerPlaySound(playerid,1085,0.0,0.0,0.0);
    format(string,sizeof(string),"PM sent to %s: %s",pName2,params);
    SendClientMessage(playerid,0xF2A337FF,string);
    SetPVarInt(id,"LastID",playerid);
    return 1;
}
Reply
#2

Params contains everything that's typed behind the command. That includes the id. I recommend using sscanf.
Reply
#3

Ok, well how can I fix this using sscanf? I have no idea on how to install, but I guess I could learn, or find a tutorial.
Reply
#4

PHP код:
dcmd_pm(playerid,params[])
{
   if(
GetPVarInt(id,"NoPM") == 0)
   {
   new 
id,string[256],pName[MAX_PLAYER_NAME],pName2[MAX_PLAYER_NAME], pMessage;
   if( 
sscanfparams"us[126]" idpMessage )) return SendClientMessageplayerid, -1"Usage: /pm [ID] (message)" );
   if( 
id == playerid ) return SendClientMessageplayerid, -1"You cant PM yourselfe!");
   if( 
IsPlayerConnectedid )
   {
      
GetPlayerName(playeridpNamesizeof(pName));
      
GetPlayerName(idpName2sizeof(pName2));
      
format(stringsizeof( string ), "PM From %s(%d): %s"pNameplayeridpMessage);
      
SendClientMessage(id, -1string);
      
PlayerPlaySound(playerid,1085,0.0,0.0,0.0);
      
format(stringsizeof( string ), "PM To %s(%d): %s"pName2idpMessage);
      
SendClientMessage(playerid, -1string);
      
SetPVarInt(id,"LastID",playerid);
   }else return 
SendClientMessage(playerid, -1"That player is not connected!");
   else
   {
       
SendClientMessage(playeridCOLOR_ERROR,"ERROR: Currently, that player's PM is set to: OFF!");
       
PlayerPlaySound(playerid10530.00.00.0);
   }
   return 
1;

Reply
#5

here's a SSCANF version.
pawn Код:
dcmd_pm(playerid,params[])
{
    new id,string[256],pName[MAX_PLAYER_NAME],pName2[MAX_PLAYER_NAME], sendmessage[64];
    if(!sscanf(params, "us[64]", id, params[2]);
    {
        if(GetPVarInt(id,"NoPM") == 1)
        {
            SendClientMessage(playerid, COLOR_ERROR,"ERROR: Currently, that player's PM is set to: OFF!");
            PlayerPlaySound(playerid, 1053, 0.0, 0.0, 0.0);
            return 1;
        }
        if(!IsPlayerConnected(id)
        {
            SendClientMessage(playerid, COLOR_ERROR,"ERROR: That ID is not connected.");
            return 1;
        }
        GetPlayerName(playerid ,pName, sizeof(pName));
        GetPlayerName(id, pName2, sizeof(pName2));
        format(string, sizeof(string), "PM from %s: %s", pName, params[2]);
        SendClientMessage(id, 0xFFFF00FF, string);
        PlayerPlaySound(playerid,1085,0.0,0.0,0.0);
        format(string, sizeof(string), "PM sent to %s: %s", pName2, params[2]);
        SendClientMessage(playerid, 0xF2A337FF, string);
        SetPVarInt(id, "LastID", playerid);
    }
    else
    {
        SendClientMessage(playerid, -1, "USAGE: /PM [PlayerID/PartOfName] [Message]");
    }
    return 1;
}
Not tested... - May or May not work.
Reply
#6

Dubya your script wont work.
Basicly player will be able to PM himselfe.
°________°
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)