PDA

View Full Version : PM command


Noles2197
27/02/2013, 09:40 PM
When you PM a player offline, it still sends the PM.
How do I fix this?

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;
}

Strier
27/02/2013, 09:46 PM
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