31.01.2015, 03:52
Hello, i have a little problem here. I have this cmd, but everyone can see /am messages, and the admins should be the only ones able to see it!
pawn Код:
CMD:am(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] >= 1)
{
new toid, message[80];
if(sscanf(params, "us[80]", toid, message)) return SendClientMessageEx(playerid, COLOR_WHITE,"USAGE: /[a]dmin[m]essage [playerid] [message]");
if(strlen(message) > 80) return SendClientMessageEx(playerid, COLOR_RED,"Your message cannot be longer than 80 characters.");
if(!IsPlayerConnected(toid)) return SendClientMessageEx(playerid, COLOR_RED,"That player is not connected!");
new string[128];
format(string, sizeof(string), "Admin message from %s: %s", GetPlayerNameEx(playerid), message);
SendClientMessageEx(AMReplyId[playerid], COLOR_GREEN, string);
for(new i=0; i<MAX_PLAYERS; i++)
{
if(PlayerInfo[i][pAdmin] >= 1)
{
format(string, sizeof(string), "Admin %s [%d] > %s [%d]: %s", GetPlayerNameEx(playerid), playerid, GetPlayerNameEx(toid), toid, message);
SendClientMessageEx(i,COLOR_GREEN,string);
}
}
}
else
{
new message[80];
if(sscanf(params, "s[80]", message)) return SendClientMessageEx(playerid, COLOR_WHITE,"USAGE: /am [message]");
if(strlen(message) > 80) return SendClientMessageEx(playerid, COLOR_RED,"Your message cannot be longer than 80 characters.");
new string[128];
for(new i=0; i<MAX_PLAYERS; i++)
{
if(PlayerInfo[i][pAdmin] >= 1)
{
format(string, sizeof(string), "Admin message from %s [%d]: %s", GetPlayerNameEx(playerid), playerid, message);
SendClientMessageEx(i,COLOR_GREEN,string);
AMReplyId[i] = playerid;
}
}
format(string, sizeof(string), "Your message, %s, has been sent.", message);
SendClientMessageEx(playerid, COLOR_GREEN, string);
format(string, sizeof(string), "Player %s [%d] > Admins: %s", GetPlayerNameEx(playerid), playerid, message);
}
return 1;
}