14.02.2014, 00:34
pawn Код:
CMD:banip(playerid, params[])
{
if(pInfo[playerid][Adminlevel] < 3) return SendClientMessage(playerid, -1, "You are not authorised to use this command.");
new id, reason[50];
if(sscanf(params, "uS(No Reason)[50]", id, reason)) return SendClientMessage(playerid, -1, "USAGE: /banip [playerid] [Optional: reason]");
new banned[MAX_PLAYER_NAME], string[150];
GetPlayerName(id, banned, sizeof(banned));
format(string, sizeof(string), "[DarkyBot] %s(%d) has been banned by %s(%d) | Reason: %s", banned, id, GetName(playerid), playerid, reason);
SendClientMessageToAll(COLOR_RED, string);
BanEx(id, reason);
return 1;
}
CMD:rbanip(playerid, params[]) //Range ban IP
{
if(pInfo[playerid][Adminlevel] < 3) return SendClientMessage(playerid, -1, "You are not authorised to use this command.");
new id, reason[50];
if(sscanf(params, "uS(No Reason)[50]", id, reason)) return SendClientMessage(playerid, -1, "USAGE: /banip [playerid] [Optional: reason]");
new banned[MAX_PLAYER_NAME], string[150];
GetPlayerName(id, banned, sizeof(banned));
format(string, sizeof(string), "[DarkyBot] %s(%d) has been range-banned by %s(%d) | Reason: %s", banned, id, GetName(playerid), playerid, reason);
SendClientMessageToAll(COLOR_RED, string);
BanEx(id, reason);
new ip[16];
GetPlayerIp(id, ip, sizeof(ip));
format(string, sizeof(string), "banip %s", ConvertToRangeIP(ip));
SendRconCommand(string);
return 1;
}
stock ConvertToRangeIP(ip[])
{
new str[15];
format(str, sizeof(str), "%s", ip);
new count = 0;
for(new i = 0; i < strlen(str); i++)
{
if(str[i] == '.')
{
count++;
if(count == 3)
{
strdel(str, i + 1, strlen(str));
strins(str, "*", i + 1);
break;
}
}
}
return str;
}