At top
Код:
#define COLOR_ADMIN 0x4169FFAA
forward SendClientMessageToAllAdmins(msg[]);
Command for PM, use zcmd if you want, its more faster.
Код:
dcmd_pm(playerid,params[])
{
new string[128];
new ID;
new cmdreason[100];
if(sscanf(params, "us[100]", ID, cmdreason))
{
SendClientMessage(playerid,COLOR_ERROR,"{CACA00}[INFO]{FFFFFF}: /pm (Player Name/ID) (Message)");
return 1;
}
if(ID == INVALID_PLAYER_ID)
{
format(string, sizeof(string), "The Player ID (%d) is not connected to the server.",ID);
SendClientMessage(playerid,COLOR_ERROR,string);
return 1;
}
format(string, sizeof(string), "{66CC00}PM Sent to:{CACA00} %s(%d): %s",PlayerName(ID),ID,cmdreason);
SendClientMessage(playerid,COLOR_YELLOW,string);
format(string, sizeof(string), "{66CC00}PM From:{CACA00} %s(%d): %s",PlayerName(playerid),playerid,cmdreason);
SendClientMessage(ID,COLOR_YELLOW,string);
format(string, sizeof(string), "PM From: %s(%d) to %s(%d): %s",PlayerName(playerid),playerid,PlayerName(ID),ID,cmdreason);
SendClientMessageToAllAdmins(string);
printf("PM From: %s(%d) to %s(%d): %s",PlayerName(playerid),playerid,PlayerName(ID),ID,cmdreason);
PlayerPlaySound(ID,1085,0.0,0.0,0.0);
return 1;
}
Function to send pm to online admins, Use foreach if you want,
Foreach is more faster to loop through all online players.
At Bottom
Код:
public SendClientMessageToAllAdmins(msg[])
{
for(new i=0; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(pInfo[i][pAdmin] >= 4)) // Change 4 to admin level, you want to send pm to...
{
SendClientMessage(i,COLOR_ADMIN,msg);
}
}
}
}
Код:
stock PlayerName(playerid) {
new name[255];
GetPlayerName(playerid, name, 255);
return name;
}