SA-MP Forums Archive
PM command - 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: PM command (/showthread.php?tid=419208)



PM command - Noles2197 - 27.02.2013

When you PM a player offline, it still sends the PM.
How do I fix this?

pawn Код:
CMD:pm(playerid, params[])
{
    new str[128],str2[128],message[100],id;
    if(sscanf(params,"is",id,message)) SendClientMessage(playerid,COLOR_GRAY,"USAGE: /pm [ID] [message]");
    if(!IsPlayerConnected(id)) SendClientMessage(playerid,COLOR_RED,"Invalid player ID!");
    if(id!=playerid){
        format(str,sizeof(str),"(( PM to [%i] %s: %s ))",id,GetName(id),message);
        format(str2,sizeof(str2),"(( PM from [%i] %s: %s ))",id,GetName(id),message);
        SendClientMessage(playerid,0xBF4C00AA,str);
        SendClientMessage(id,COLOR_ORANGE,str2);
        PlayerPlaySound(id,1058,0,0,0);
    }
    return 1;
}



Respuesta: PM command - Strier - 27.02.2013

pawn Код:
if(!IsPlayerConnected(id)) return SendClientMessage(playerid,COLOR_RED,"Invalid player ID!");
//By this you're saying that !IsPlayerConnected is true, but if you add the return it prevents the command to be sent. while the other player is offline