Command pm
#1

Hello

Can some one tell me i Would like to add if player is admin (rcon) then he can read all pms.
Below i show you My pM system please tell me how to add it


COMMANDm(playerid,params[])
{
new id,text[128];
if(sscanf(params,"us[128]",id,text))
return SendSyntaxWarning(playerid,"/PM <ID/Name> <Text>");

if(!IsValidPlayer(id) || id==playerid)
return SendSyntaxWarning(playerid,"/PM <ID/Name> <Text>");

PrivateMessage(playerid, id, text);
return 1;
}

Thanks
Reply
#2

try this

sorry for wrong code
stock PlayerName(playerid)
{
new nume[MAX_PLAYER_NAME];
GetPlayerName(playerid, nume, sizeof(nume));
return nume;
}
EDITED:
Код:
COMMAND:pm(playerid,params[])
{
	new id,text[128],str[128];

	if(sscanf(params,"us[128]",id,text))
	return SendSyntaxWarning(playerid,"/PM <ID/Name> <Text>");

	if(!IsValidPlayer(id) || id==playerid)
	return SendSyntaxWarning(playerid,"/PM <ID/Name> <Text>");

	PrivateMessage(playerid, id, text);
	for(new i = 0; i < MAX_PLAYERS; i++)//Loop for all players
	{
		if(IsPlayerAdmin(i))// detect if there is online administrator
		{
			format(str, sizeof(str),"PM From %s(%d) to %s(%d): %s", PlayerName(playerid), playerid, PlayerName(id), id, text);//if you get error here change the "text" to "text[0]"
			SendClientMessage(i, -1, str);
		}
	}
	return 1;
}
Reply
#3

first add this to your system:
pawn Код:
new name[MAX_PLAYER_NAME]; GetPlayerName(id, name, sizeof(name)); // getting the p's name who got the message
new sender[MAX_PLAYER_NAME]; GetPlayerName(playerid, sender, sizeof(sender)); // getting sender's name
but make sure they are under sscanf line
then under blew:
pawn Код:
for(new i = 0; i < MAX_PLAYERS; i++) // looping
{
     if(IsPlayerAdmin(i)) // checking if they are admins only..
     {
           new string[128];
           format(string, sizeof(string), "PM >> %s to %s: %s", sender, name, text); // formating the string..
           SendClientMessage(i, -1, string);// sending the message to admins
     }
}
return 1;
sorry i forget to format it
Reply
#4

Quote:
Originally Posted by AiRaLoKa
Посмотреть сообщение
try this

sorry for wrong code
stock PlayerName(playerid)
{
new nume[MAX_PLAYER_NAME];
GetPlayerName(playerid, nume, sizeof(nume));
return nume;
}
EDITED:
Код:
COMMAND:pm(playerid,params[])
{
	new id,text[128],str[128];

	if(sscanf(params,"us[128]",id,text))
	return SendSyntaxWarning(playerid,"/PM <ID/Name> <Text>");

	if(!IsValidPlayer(id) || id==playerid)
	return SendSyntaxWarning(playerid,"/PM <ID/Name> <Text>");

	PrivateMessage(playerid, id, text);
	for(new i = 0; i < MAX_PLAYERS; i++)//Loop for all players
	{
		if(IsPlayerAdmin(i))// detect if there is online administrator
		{
			format(str, sizeof(str),"PM From %s(%d) to %s(%d): %s", PlayerName(playerid), playerid, PlayerName(id), id, text);//if you get error here change the "text" to "text[0]"
			SendClientMessage(i, -1, str);
		}
	}
	return 1;
}
Hello
i try to add your code but it's give me errores

error 012: invalid function call, not a valid address
warning 215: expression has no effect
error 001: expected token: ";", but found ")"
error 029: invalid expression, assumed zero
fatal error 107: too many error messages on one line

P.s: when i write my old code it's working without any problem.
Thanks
Reply
#5

Eh, dunno if you still need it, but this is my version of the PM:

pawn Код:
CMD:pm(playerid, params[])
{
    new str[256], str2[256], id, Name1[MAX_PLAYER_NAME], Name2[MAX_PLAYER_NAME];
    if(sscanf(params, "us", id, str2))
    {
        SendClientMessage(playerid, 0xFF0000FF, "Usage: /pm <id> <message>");
        return 1;
    }
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid, 0xFF0000FF, "[PM] - Player not connected");
    if(playerid == id) return SendClientMessage(playerid, 0xFF0000FF, "[PM] - You cannot pm yourself!");
    if (dnd { id } ) return SendClientMessage(playerid, COLOR_RED, "[DND] - Target is in DND(Do Not Disturb) mode");//Remove this one(if you dont have it)
    if(PlayerInfo[playerid][pMuted] == 1) return SendClientMessage(playerid, COLOR_RED, "[MUTE] - You can't talk while you're muted!");//Remove this one(if you dont have it)
    {
        GetPlayerName(playerid, Name1, sizeof(Name1));
        GetPlayerName(id, Name2, sizeof(Name2));
        format(str, sizeof(str), "[PM] To %s(ID %d): %s", Name2, id, str2);
        SendClientMessage(playerid, COLOR_YELLOW, str);
        format(str, sizeof(str), "[PM] From %s(ID %d): %s", Name1, playerid, str2);
        SendClientMessage(id, COLOR_YELLOW, str);
        format(str, sizeof(str), "PM From %s[%d] to %s[%d]: %s", Name1, playerid, Name2, id, str2);
        SendMessageToAdmins(str);
    }
    return 1;
}
pawn Код:
stock SendMessageToAdmins(text[])
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerAdmin(i))
        {
            SendClientMessage(i, 0xCA3FBFAA, text);
        }
    }
}
NOTE:
Remove the
pawn Код:
if (dnd { id } ) return SendClientMessage(playerid, COLOR_RED, "[DND] - Target is in DND(Do Not Disturb) mode");
    if(PlayerInfo[playerid][pMuted] == 1) return SendClientMessage(playerid, COLOR_RED, "[MUTE] - You can't talk while you're muted!");
if you don't have a /dnd or a mute command
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)