12.03.2011, 19:49
Use sscanf.. it's simple and efficient
Ops, too late ...
pawn Код:
CMD:pm(playerid, params[])
{
new targetid;
if(sscanf(params, "us[128]", targetid, str128)) return SendClientMessage(playerid, WHITE, "Use: /pm [player] [text]");
if(targetid != INVALID_PLAYER_ID)
{
if(targetid == playerid) SendClientMessage(playerid, LIME, "You cannot PM yourself.");
else CallLocalFunction("OnPlayerPrivmsg", "dds", playerid, targetid, str128);
}
else SendClientMessage(playerid, LIME, "Player is not connected.");
return 1;
}
pawn Код:
PUBLIC:OnPlayerPrivmsg(playerid, recieverid, text[])
{
format(str128, 128, "PM from %s(ID:%d): %s", PlayerName[playerid], playerid, text);
SendClientMessage(recieverid, YELLOW, str128);
format(str128, 128, "PM to %s(ID:%d): %s", PlayerName[recieverid], recieverid, text);
SendClientMessage(playerid, YELLOW, str128);
printf("[pm] %s PM'ed %s: %s", PlayerName[playerid], PlayerName[recieverid], text);
return 0;
}