help me with /admin command!
#2

You are using ZCMD (CMIIW), There is already "params" parameter, which contain input from the command after space symbol (e.g. /admin <params>). You don't need to use strrest code placed on the command.
So just do this:
pawn Код:
CMD:admin(playerid, params[])
{
    if(!IsPlayerConnected(playerid)) return 0; // Player is not connected.
    if(Player[playerid][AdminLevel] >= 1) // Better check first if it's an admin
    {
        new sendername[MAX_PLAYER_NAME];
        GetPlayerName(playerid, sendername, sizeof(sendername)); // I'm not sure what are you going to use this at, But it might be replaced on function "RemoveUnderScore(playerid)" instead?
        if(!strlen(params))
        {
            SendClientMessage(playerid, COLOR_WHITE, "USAGE: (/a)dmin [admin chat]");
            return 1;
        }
        new atext[20]; // This only need 20 because the longest string, "Junior Administrator" length is 20
        switch(Player[playerid][AdminLevel])
        {
            case 1: atext = "Junior Moderator";
            case 2: atext = "Moderator";
            case 3: atext = "Lead Moderator";
            case 4: atext = "Junior Administrator";
            case 5: atext = "Administrator";
            case 6: atext = "Lead Administrator";
            case 7: atext = "Owner";
        }
        format(string, sizeof(string), "[%s] %s (%d):"COL_WHITE" %s", atext, RemoveUnderScore(playerid) /* Isn't this supposed to be "sendername"? */, playerid, params);
        SendAdminMessage(COLOR_NICEGREEN, string);
    }
    else SendClientMessage(playerid, COLOR_WHITE, "You are not an admin!"); // or "return 0;" here
    return 1;
}
I've also corrected some code, so only admin can send it, and optimized the variable usage. Although it's not tested yet, but i'm sure it will work.
Reply


Messages In This Thread
help me with /admin command! - by magent - 15.03.2014, 02:13
Re: help me with /admin command! - by RoboN1X - 15.03.2014, 04:28

Forum Jump:


Users browsing this thread: 1 Guest(s)