14.01.2013, 20:15
Hey im needing a little help with a PM system could I get a basic code please it would be appriciated
CMD:pm(playerid, params[])
{
new playerb, string[128], text[128];
if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
if(PlayerInfo[playerid][pAdmin] < 0) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
if(!aDuty[playerid]) return SendClientMessage(playerid, COLOR_GREY, "You are not on admin duty.");
if(sscanf(params, "us[128]", playerb, text)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /pm [playerid] [text]");
if(AntiAdv(playerid, params)) return 1;
if(!strlen(text)) return SendClientMessage(playerid, COLOR_GREY, "You haven't entered any text to PM.");
if(!IsPlayerLoggedIn(playerb)) return SendClientMessage(playerid, COLOR_GREY, "Invalid player id.");
format(string, sizeof(string), "PM to %s: %s", RPN(playerb), text);
SendClientMessage(playerid, COLOR_YELLOW, string);
format(string, sizeof(string), "PM from %s: %s", RPN(playerid), text);
SendClientMessage(playerb, COLOR_YELLOW, string);
format(string, sizeof(string), "PM from %s to %s: %s", RPN(playerid), RPN(playerb), text);
Log("logs/pm.log", string);
foreach(Player, i)
{
if(PlayerInfo[i][pAdmin] >= 6 && PMs[i] && i != playerid && i != playerb)
{
format(string, sizeof(string), "[PM] %s to %s: %s", RPN(playerid), RPN(playerb), text);
SendClientMessage(i, COLOR_YELLOW, string);
}
}
return 1;
}
#define COLOR_YELLOW 0xEAEA15C8
#define NO_PARAMS 0xBEBCD3FF
CMD:pm(playerid, params[])
{
new string[256], text[128], targetid;
if(sscanf(params, "rs[128]", targetid, text)) return SendClientMessage(playerid, NO_PARAMS, "USAGE: /pm [Id or name] [text]");//If no enough params
if(targetid == INVALID_PLAYER_ID) return SendClientMessage(playerid, ERROR, "ERROR: Invalid player ID or Name");//If player wants to PM him self or a not connected player
if(targetid == playerid) return SendClientMessage(playerid, ERROR, "ERROR: You cannot PM yourself");
format(string, sizeof(string), "PM from: %s |Text: %s", Name(playerid), text);//The format of the string
SendClientMessage(targetid, COLOR_YELLOW, string);//sending the message to the targetid
format(string, sizeof(string), "PM to: %s| Text: %s", Name(targetid), text);
SendClientMessage(playerid, COLOR_YELLOW, string);
return 1;
}