20.11.2012, 16:59
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.
Also, make sure you have the colours red and orange defined, if not, they're here.
What's up with this Anthony?
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.
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;
}
pawn Код:
#define COLOR_RED 0xFF0000FF
#define COLOR_ORANGE 0xFF8000FF
Quote:
pawn Код:
|