PDA

View Full Version : A PM system which Admins can also see(not RCON)


Gotham
29/09/2016, 12:22 PM
Hi , how would I make a PM System with the Admins seeing all the PM messages?
Enums:


enum pInfo
{
pPass,
pCash,
pAdmin,
pKills,
pDeaths,
pBanned,
BannedIP[22],
pVip
}
new PlayerInfo[MAX_PLAYERS][pInfo];

Adarsh007
29/09/2016, 12:24 PM
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,c mdreason);
SendClientMessageToAllAdmins(string);
printf("PM From: %s(%d) to %s(%d): %s",PlayerName(playerid),playerid,PlayerName(ID),ID,c mdreason);
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;
}

Dayrion
29/09/2016, 12:48 PM
Also mine is like that if you use ZCMD/IZCMD:
CMD:pm(playerid, params[])
{
new cible,
message[95];

if(sscanf(params,"us[95]", cible, message)) return SCM(playerid, LBLUE, "/pm [player_id/name] [message]");
if(!IsPlayerConnected(cible))
return ErrorMsg(playerid, _, "This player is not connected");

new temp = PmTime[playerid] - gettime();
if(PmTime[playerid] && PmTime[playerid] > gettime())
ErrorMsg(playerid, _, "You must wait %s sec before sending an another PM.", temp);

PmTime[playerid] = gettime() + TPS_PM;
SCMF(playerid, 0xffdd99ff, "[PM] Send to %s : %s", GetName(cible, true), message);
SCMF(cible, 0xffc34dff, "[PM] Recivied from %s : %s", GetName(playerid, true), message);
SendMessageToAdmins(SAUMON, "[Admin] %s %s : '%s'", GetName(playerid, true), GetName(cible, true), message);
return 1;
}
Include y_va from YSI is required for this following functions.

SCMF(const playerid, couleur, const msg[], va_args<>)
{
new
string[145];

va_format(string, sizeof(string), msg, va_start<3>);
return SendClientMessage(playerid, couleur, string);
}

ErrorMsg(playerid, allowed = true, const msg[] = EOS, va_args<>)
{
new message[190];
static const premsg[] = "[Erreur] %s";

if(!allowed)
return SCMF(playerid, REDF, "[Error] You are not allowed to use this command.");

if(numargs() == 2)
return SCMF(playerid, REDF, premsg, msg);

va_format(message, sizeof(message), msg, va_start<3>);

return SCMF(playerid, REDF, "[Erreur] %s", message);
}
GetName(const playerid, id = false)
{
static str[MAX_PLAYER_NAME+9];
GetPlayerName(playerid, str, sizeof(str));
if(id) format(str, sizeof(str), "%s (ID: %i)", str, playerid);
return str;
}
SendMessageToAdmins(color, const msg[], va_args<>)
{
new
string1[190];

va_format(string1, sizeof(string1), msg, va_start<2>);

foreach(new i : Player)
{
if(pAccount[i][pAdmin] < 1) continue;
SCM(i, color, string1);
}

return 1;
}