A PM system which Admins can also see(not RCON)
#1

Hi , how would I make a PM System with the Admins seeing all the PM messages?
Enums:

PHP код:
enum pInfo
{
    
pPass,
    
pCash,
    
pAdmin,
    
pKills,
    
pDeaths,
    
pBanned,
    
BannedIP[22],
    
pVip
}
new 
PlayerInfo[MAX_PLAYERS][pInfo]; 
Reply
#2

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;
}
Reply
#3

Also mine is like that if you use ZCMD/IZCMD:
PHP код:
CMD:pm(playeridparams[])
{
    new 
cible,
        
message[95];

    if(
sscanf(params,"us[95]"ciblemessage)) return SCM(playeridLBLUE"/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(playerid0xffdd99ff"[PM] Send to %s : %s"GetName(cibletrue), message);
    
SCMF(cible0xffc34dff"[PM] Recivied from %s : %s"GetName(playeridtrue), message);
    
SendMessageToAdmins(SAUMON"[Admin] %s » %s : '%s'"GetName(playeridtrue), GetName(cibletrue), message);
    return 
1;

Include y_va from YSI is required for this following functions.
PHP код:
SCMF(const playeridcouleur, const msg[], va_args<>)
{
    new
        
string[145];

    
va_format(stringsizeof(string), msgva_start<3>);
    return 
SendClientMessage(playeridcouleurstring);
}

ErrorMsg(playeridallowed true, const msg[] = EOSva_args<>)
{
    new 
message[190];
    static const 
premsg[] = "[Erreur] %s";

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

    if(
numargs() == 2)
        return 
SCMF(playeridREDFpremsgmsg);

    
va_format(messagesizeof(message), msgva_start<3>);

    return 
SCMF(playeridREDF"[Erreur] %s"message);
}
GetName(const playeridid false)
{
    static 
str[MAX_PLAYER_NAME+9];
    
GetPlayerName(playeridstrsizeof(str));
    if(
idformat(strsizeof(str), "%s (ID: %i)"strplayerid);
    return 
str;
}
SendMessageToAdmins(color, const msg[], va_args<>)
{
    new
        
string1[190];

    
va_format(string1sizeof(string1), msgva_start<2>);

    foreach(new 
Player)
    {
        if(
pAccount[i][pAdmin] < 1) continue;
        
SCM(icolorstring1);
    }

    return 
1;

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)