/ban CMD
#9

I made this quickly, I tested it and it works, this is 100% compatible, if you're using sscanf2 that is, if you're not then simply remove the '[64]' in the sscanf check.
pawn Код:
COMMAND:ban(playerid, params[])
{
    new targetId, banReason[64];
    if(!IsPlayerAdmin(playerid) /* Or change to a variable */) return SendClientMessage(playerid, COLOR_RED, "You're not an administrator!");
    else if(sscanf(params, "us[64]", targetId, banReason)) return SendClientMessage(playerid, COLOR_ORANGE, "Usage: /ban [id][reason]");
    else if(!IsPlayerConnected(targetId)) return SendClientMessage(playerid, COLOR_RED, "That player isn't connected!");
    else
    {
        new playerName[MAX_PLAYER_NAME], targetName[MAX_PLAYER_NAME], banMessage[128];
       
        GetPlayerName(playerid, playerName, sizeof(playerName));
        GetPlayerName(targetId, targetName, sizeof(targetName));
       
        format(banMessage, sizeof(banMessage), "Administrator %s(%d) has banned player %s(%d). Reason: %s", playerName, playerid, targetName, targetId, banReason);
        SendClientMessageToAll(COLOR_RED, banMessage);
        print(banMessage);
       
        format(banMessage, sizeof(banMessage), "Banned by %s. Reason: %s", playerName, banReason);
        BanEx(targetId, banMessage);
    }
    return 1;
}
Also, make sure you have the colours red and orange defined, if not, they're here.

pawn Код:
#define COLOR_RED 0xFF0000FF
#define COLOR_ORANGE 0xFF8000FF
What's up with this Anthony?

Quote:
Originally Posted by Anthony ©
Посмотреть сообщение
pawn Код:
CMD:ban(playerid, params[])
{
    new pID, reason[68], msg[128], name[MAX_PLAYER_NAME], bannername[MAX_PLAYER_NAME];
    if(sscanf(params, "us", pID, reason)) return SendClientMessage(playerid, 0xDF0000FF, "USAGE: /ban [playerid] [reason]");
    {
        GetPlayerName(pID, name, sizeof(name));
        GetPlayerName(pID, bannername, sizeof(bannername));
        format(msg, sizeof(msg), "[AdmCmd]: %s has been banned by %s, reason: %s", name, bannername, reason);
        SendClientMessageToAll(0xDF0000FF, msg);
        BanEx(pID, reason);
    }
    return 1;
}
Seriously? You're getting the name of the same player twice, and ANYONE can execute this command, even regular players, it's worth adding a RCON admin check in there.
Reply


Messages In This Thread
/ban CMD - by Louris - 20.11.2012, 15:55
Re: /ban CMD - by vernz - 20.11.2012, 15:56
Re: /ban CMD - by Louris - 20.11.2012, 16:00
Re: /ban CMD - by tyler12 - 20.11.2012, 16:02
Re: /ban CMD - by vernz - 20.11.2012, 16:02
Re: /ban CMD - by Anthony © - 20.11.2012, 16:08
Re: /ban CMD - by gtakillerIV - 20.11.2012, 16:09
Re: /ban CMD - by Louris - 20.11.2012, 16:54
Re: /ban CMD - by Bicentric - 20.11.2012, 16:59
Re: /ban CMD - by Louris - 20.11.2012, 17:08

Forum Jump:


Users browsing this thread: 5 Guest(s)