27.12.2013, 11:13
Could someone help me make one:L
//the macro
new str8hgn86[256];
#define SFM(%0,%1,%2,%3) format(str8hgn86, sizeof(str8hgn86),%2,%3) && SendClientMessage(%0, %1, str8hgn86)
//the function
stock GetName(playerid)
{
new n[MAX_PLAYER_NAME];
GetPlayerName(playerid, n, MAX_PLAYER_NAME);
return n;
}
//the cmd
YCMD:pm(playerid, params[], help)
{
if(help) return SendClientMessage(playerid,gray,"/pm is used to send private messages");
new i;
if(sscanf(params,"ds[150]",i,params)) return SendClientMessage(playerid,red,"USAGE: /pm [ID] [MSG]");
if(!IsPlayerConnected(i)) return SendClientMessage(playerid,red,"That ID doesn't exist.");
SFM(playerid,yellow,"TO %s:{FFFFFF} %s",GetName(i),params);
SFM(i,orange,"FROM %s: {FFFFFF}%s",GetName(playerid),params);
return 1;
}
new cmd[256];
new tmp[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", cmd, true) == 0)
{
tmp = strtok(cmdtext,idx);
if(!strlen(tmp) || strlen(tmp) > 5) {
SendClientMessage(playerid,ADMINFS_MESSAGE_COLOR,"TIPP: /pm (ID) (Text)");
return 1;
}
new id = strval(tmp);
gMessage = strrest(cmdtext,idx);
if(!strlen(gMessage)) {
SendClientMessage(playerid,ADMINFS_MESSAGE_COLOR,"TIPP: /pm (ID) (Text)");
return 1;
}
if(!IsPlayerConnected(id)) {
SendClientMessage(playerid,ADMINFS_MESSAGE_COLOR,"/pm : Diese ID exestiert nicht");
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,PM_OUTGOING_COLOR,Message);
format(Message,sizeof(Message),"** %s(%d): %s",pName,playerid,gMessage);
SendClientMessage(id,PM_INCOMING_COLOR,Message);
}
else {
SendClientMessage(playerid,ADMINFS_MESSAGE_COLOR,"Du kannst keine PM an dich selbst senden xD");
}
return 1;
}
#include zcmd ------- CMD:pm(playerid, params[]) { new id, message[1024]; if(sscanf(params,"ds[1024]",id,message))return SendClientMessage(playerid, COLOR_RED, ""COL_RED"[ERROR]: "COL_WHITE"Usage: /pm <playerid> <message>"); if (!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_RED, ""COL_RED"[ERROR]: "COL_WHITE"Player is not connected."); if(playerid != id) { new PlayerName[MAX_PLAYER_NAME]; GetPlayerName(playerid, PlayerName, sizeof(PlayerName)); new ReturnName[MAX_PLAYER_NAME]; new szString[128]; GetPlayerName(id, ReturnName, sizeof(ReturnName)); format(szString,sizeof(szString), ">> PM To %s (ID:%d): %s", ReturnName, id, message); SendClientMessage(playerid, COLOR_YELLOW, szString); format(szString,sizeof(szString),"<< PM From %s (ID:%d): %s",PlayerName, playerid, message); SendClientMessage(id, COLOR_YELLOW, szString); PlayerPlaySound(id, 1085, 0.0, 0.0, 0.0); } else { SendClientMessage(playerid, COLOR_RED, "ERROR: You cannot PM yourself"); } return 1; }
new _cmdtext[50], params[200]; sscanf(cmdtext, "s[50]s[200]" , _cmdtext, params); if (strcmp("/pm", _cmdtext, true) == 0) { new idp, playerName[MAX_PLAYER_NAME], texte[220], string[255]; if(sscanf(params, "is[220]", idp, texte)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /pm [idjoueur] [texte]"); GetPlayerName(playerid, playerName, MAX_PLAYER_NAME); format(string, sizeof(string), "%s[%i]: ((%s))", playerName, playerid, texte); if(IsPlayerConnected(idp)) { SendClientMessage(idp, COLOR_ORANGE, string); SendClientMessage(playerid, COLOR_ORANGE, "PM envoye"); } else { SendClientMessage(playerid, COLOR_ORANGE, "[PM] Le joueur n'est pas connecte"); } return 1; }