17.01.2016, 10:37
Here is the PM Command
pawn Код:
COMMAND:pm(playerid, params[]) {
if(GetPVarInt(playerid, "Muted") == 1) return SendClientMessage(playerid, COLOR_LIGHTRED, "SERVER: You are currently muted.");
new message[128],
user;
if(sscanf(params, "us[128]", user, message)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /pm [playerid] [message]");
if(user == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_GREY, "Invalid playerID (Submitted playerID is either invalid or a maskID).");
if(!IsPlayerConnected(user)) return SendClientMessage(playerid, COLOR_GREY, "Invalid playerID (Submitted playerID is not connected).");
if(IsPlayerNPC(user)) return SendClientMessage(playerid, COLOR_GREY, "Invalid playerID (Submitted playerID points at NPC).");
if(user == playerid) return SendClientMessage(playerid, COLOR_GREY, "You cannot send yourself private messages.");
if(GetPVarInt(user, "TogglePM") == 1 && PlayerInfo[playerid][pAdminlevel] == 0 && PlayerInfo[playerid][pModLevel] == 0) return SendClientMessage(playerid, COLOR_GREY, "The Private Messages of this user are currently blocked.");
new len = strlen(message);
if(len + MAX_PLAYER_NAME + 30 > 128) {
new buffer[128],
msg[128];
strmid(buffer, message, 0, 128 - MAX_PLAYER_NAME - 30 - 4);
format(msg, sizeof(msg), "(( PM sent to%s %s{E5C43E} [ID: %i]: %s ... ))", GetPVarInt(user, "AdminDuty") != 0? ("{CC9900}") : ("{E5C43E}"), GetNameWithSpace(user), user, buffer);
SendClientMessage(playerid, COLOR_DARKYELLOW, msg);
format(msg, sizeof(msg), "(( PM from%s %s{F0F000} [ID: %i]: %s ... ))", GetPVarInt(playerid, "AdminDuty") != 0? ("{CC9900}") : ("{F0F000}"), GetNameWithSpace(playerid), playerid, buffer);
SendClientMessage(user, COLOR_YELLOW, msg);
strdel(message, 0, 128 - MAX_PLAYER_NAME - 30 - 4);
format(msg, sizeof(msg), "(( PM sent to%s %s{E5C43E} [ID: %i]: ... %s ))",GetPVarInt(user, "AdminDuty") != 0? ("{CC9900}") : ("{E5C43E}"), GetNameWithSpace(user), user, message);
SendClientMessage(playerid, COLOR_DARKYELLOW, msg);
format(msg, sizeof(msg), "(( PM from%s %s{F0F000} [ID: %i]: ... %s ))", GetPVarInt(playerid, "AdminDuty") != 0? ("{CC9900}") : ("{F0F000}"), GetNameWithSpace(playerid), playerid, message);
SendClientMessage(user, COLOR_YELLOW, msg);
} else {
new buffer[128];
format(buffer, sizeof(buffer), "(( PM sent to%s %s{E5C43E} [ID: %i]: %s ))",GetPVarInt(user, "AdminDuty") != 0? ("{CC9900}") : ("{E5C43E}") , GetNameWithSpace(user), user, message);
SendClientMessage(playerid, COLOR_DARKYELLOW, buffer);
format(buffer, sizeof(buffer), "(( PM from%s %s{F0F000} [ID: %i]: %s ))", GetPVarInt(playerid, "AdminDuty") != 0? ("{CC9900}") : ("{F0F000}"), GetNameWithSpace(playerid), playerid, message);
SendClientMessage(user, COLOR_YELLOW, buffer);
}
SetPVarInt(user, "lpm", playerid);
return 1;
}