Admin Message Command
#2

The reason normal players can do it is because when you check to see if they are an admin; your 'else'(which basically means if the player is not admin) still sends the message. You need the else to send the player an error message stating that this command is for administrators only.

Your code should be something like this;
pawn Код:
CMD:am(playerid, params[])
{
    if(IsAdmin(playerid))
    {
        new toid, message[128];
        if(sscanf(params, "us[128]", toid, message)) return Syntax(playerid, "[a]dmin[m]essage: [playerid] [message]");
        if(strlen(message) > 65) return Error(playerid, "Your message cannot be longer than 65 characters.");
        if(!IsPlayerConnected(toid)) return Error(playerid, "That player is not connected!");
        new string[128];
        format(string, sizeof(string), "Admin message from %s: %s", GetPlayerNameEx(playerid), message);
        SendClientMessageEx(toid, COLOR_GREEN, string);
        format(string, sizeof(string), "Admin %s [%d] > %s [%d]: %s", GetPlayerNameEx(playerid), playerid,   GetPlayerNameEx(toid), toid, message);
        SendAdminMessage(COLOR_GREEN,string);
    }
    else
    {
       SendClientMessage(playerid, COLOR_RED, "ERROR: This message is for administrators only!");
    }
    return 1;
}
Reply


Messages In This Thread
Admin Message Command - by Drago987 - 14.09.2013, 21:45
Re: Admin Message Command - by EiresJason - 14.09.2013, 23:21
Re: Admin Message Command - by Drago987 - 15.09.2013, 11:50
Re: Admin Message Command - by EiresJason - 15.09.2013, 12:54
Re: Admin Message Command - by Drago987 - 15.09.2013, 13:13
Re: Admin Message Command - by Drago987 - 15.09.2013, 13:15
Re: Admin Message Command - by EiresJason - 15.09.2013, 14:07
Re: Admin Message Command - by Drago987 - 15.09.2013, 14:24
Re: Admin Message Command - by EiresJason - 15.09.2013, 15:24
Re: Admin Message Command - by Konstantinos - 15.09.2013, 15:30

Forum Jump:


Users browsing this thread: 2 Guest(s)