if(strcmp(cmd, "/pm", true) == 0)
{
tmp = strtok(cmdtext,idx), tmp2 = strtok(cmdtext,idx);
new player1, text;
player1 = strval(tmp);
text = strval(tmp2);
if(!strlen(tmp) && !strlen(tmp2))
{
SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /PM [playerid] [text]");
}
else
{
GetPlayerName(player1, playername, sizeof(playername)); GetPlayerName(playerid, adminname, sizeof(adminname));
format(string,sizeof(string),">> (PM) To %s: %s", player1, text);
SendClientMessage(playerid, COLOR_YELLOW, string);
format(string,sizeof(string),"<< (PM) From %s: %s", adminname, text);
SendClientMessage(player1, COLOR_YELLOW, string);
printf("%s has PMed: %s(%s)",adminname, playername, text);
}
return 1;
}
if(strcmp("/pm", cmd, true) == 0)
{
tmp = strtok(cmdtext,idx);
if(!strlen(tmp) || strlen(tmp) > 5) {
SendClientMessage(playerid,COLOR_YELLOW,"Usage: /pm (id) (message)");
return 1;
}
new id = strval(tmp);
gMessage = strrest(cmdtext,idx);
if(!strlen(gMessage)) {
SendClientMessage(playerid,COLOR_YELLOW,"Usage: /pm (id) (message)");
return 1;
}
if(!IsPlayerConnected(id)) {
SendClientMessage(playerid,COLOR_RED," Bad player ID");
return 1;
}
if(playerid != id) {
GetPlayerName(id,iName,sizeof(iName));
GetPlayerName(playerid,pName,sizeof(pName));
format(Message,sizeof(Message),">> %s(%d): %s",iName,id,gMessage);
SendClientMessage(playerid,COLOR_YELLOW,Message);
format(Message,sizeof(Message),"** %s(%d): %s",pName,playerid,gMessage);
SendClientMessage(id,COLOR_YELLOW,Message);
PlayerPlaySound(id,1085,0.0,0.0,0.0);
printf("PM: %s",Message);
}
else {
SendClientMessage(playerid,COLOR_RED," You cannot PM yourself");
}
return 1;
}
else {
SendClientMessage(playerid,COLOR_RED,"unknown command use ");
}
new cmd[256];
new tmp[256];
new Message[256];
new gMessage[256];
new pName[MAX_PLAYER_NAME+1];
new iName[MAX_PLAYER_NAME+1];
new idx;
cmd = strtok(cmdtext, idx);
if(!strcmp("/pm", cmdtext, true))
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /PM [playerid] [text]");
new player1 = strval(tmp), text = strrest(cmdtext, idx), playername[MAX_PLAYER_NAME], adminname[MAX_PLAYER_NAME], string[128];
if(!strlen(text)) return SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /PM [playerid] [text]");
if(!IsPlayerConnected(player1)) return SendClientMessage(playerid, COLOR_YELLOW, "That player is not connected!");
GetPlayerName(player1, playername, sizeof(playername));
GetPlayerName(playerid, adminname, sizeof(adminname));
format(string, sizeof(string), ">> (PM) To %s: %s", playername, player1, text);
SendClientMessage(playerid, COLOR_YELLOW, string);
format(string, sizeof(string), "<< (PM) From %s: %s", adminname, playerid, text);
SendClientMessage(player1, COLOR_YELLOW, string);
printf("%s has PMed: %s(%s)", adminname, playername, text);
return 1;
}
Use this one this one works
pawn Код:
pawn Код:
|