Command_ban(playerid, params[])
{
if(IsPlayerConnected(id))
{
if(IsPlayerAdmin(playerid))
{
new id;
if(!sscanf(params, "ui", id))
{
new string[64];
new name[MAX_PLAYER_NAME], PlayerName[MAX_PLAYER_NAME], text[PLAYER_TEXT];
GetPlayerName(playerid, name, sizeof(name));
GetPlayerName(id, PlayerName, sizeof(PlayerName));
GetPlayerText(playerid, text, sizeof(text));
format(string, sizeof(string), "You has been banned by %s, reason %d", name, text);
SendClientMessage(playerid, 0x0259EAAA, string);
format(string, sizeof(string), "You banned %s.)
SendClientMessage(playerid, 0x0259EAAA, string);
BanPlayer(id);
}
else return SendClientMessage(playerid, 0x0259EAAA, "USAGE: /ban [PlayerId/PartOfName] [Reason]");
}
else return SendClientMessage(playerid, 0x0259EAAA, "You are not admin.");
}
else return SendClientMessage(playerid, 0x0259EAAA, "Player is not connected.");
}
CMD:ban( playerid, params[ ] )
{
new ID, string[128], reason[66];
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0x0259EAAA, "You are not admin.");
if(sscanf(params, "uS(No Reason Given)[65]", ID, reason)) return SendClientMessage(playerid, 0x0259EAAA, "USAGE: /ban [PlayerID] [reason]");
if(IsPlayerConnected(ID) && ID != INVALID_PLAYER_ID && ID != playerid)
{
format(string,sizeof(string), "You have been Banned by Administrator \"%s\" Reason: %s", pName(playerid),reason);
SendClientMessage(ID, 0x0259EAAA, string);
format(string, sizeof(string), "You have Banned \"%s\" Reason: %s", pName(ID), reason);
SendClientMessage(playerid, 0x0259EAAA , string);
format(string, sizeof(string), "Administrator \"%s\" has Banned \"%s\" Reason: %s",pName(playerid),pName(ID),reason);
SendClientMessageToAll( 0x0259EAAA , string );
TogglePlayerControllable(ID, false);
Ban(ID);
}
else return SendClientMessage(playerid, -1, "Player is not connected or is yourself");
return 1;
}
stock pName(playerid)
{
new Name[MAX_PLAYER_NAME];
GetPlayerName(playerid, Name, sizeof(Name));
return Name;
}
CMD:ban(playerid, params[])
{
//Is Player Admin script here
{
new pID, Msg[128];
if(sscanf(params, "us[60]", pID, params)) return SendClientMessage(playerid, COLOR_RED, "* Usage: /Ban < Player ID > < Reason >");
if(!IsPlayerConnected(pID)) return SendClientMessage(playerid, COLOR_RED, "That user is not connected!");
format(Msg, sizeof(Msg), "Admin: %s(%d) has banned: %s(%d) for: %s", pName(playerid), playerid, pName(pID), pID, params);
SendClientMessageToAll(COLOR_GREY, Msg);
return BanEx(pID, "Admin Ban!");
}
else return SendClientMessage(playerid, COLOR_RED, "This command is for admin lvl 3 + only!");
}
Clive, your example wouldn't let administrators execute the command, but non-administrators could.
|
COMMAND:iban(playerid, params[])
{
new id;
if(IsPlayerConnected(id))
{
if(IsPlayerAdmin(playerid))
{
if(!sscanf(params, "ui", id))
{
new string[64];
new name[MAX_PLAYER_NAME], PlayerName[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
GetPlayerName(id, PlayerName, sizeof(PlayerName));
format(string, sizeof(string), "You has been banned by %s.", name);
SendClientMessage(playerid, 0x0259EAAA, string);
format(string, sizeof(string), "You banned %s.", id);
SendClientMessage(playerid, 0x0259EAAA, string);
Ban(id);
return 1;
}
else return SendClientMessage(playerid, 0x0259EAAA, "USAGE: /ban [PlayerId/PartOfName]");
}
else return SendClientMessage(playerid, 0x0259EAAA, "You are not admin.");
}
else return SendClientMessage(playerid, 0x0259EAAA, "Player is not connected.");
}