CMD:unbanip(playerid,params[])
{
new str[128], ip[50];
if(pData[playerid][Login] == 0) return SendClientMessage(playerid, COLOR_RED, "*** Please login first! ***");
if(pData[playerid][Admin] < 4 || IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "*** You are not Forum Desginer/Maker ***");
if(sscanf(params, "s[50]", ip)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /unbanip [ip]");
format(str, sizeof(str), "unbanip %s", ip);
SendRconCommand(str);
return 1;
}
fdeleteline(filename[], line)
{
new count, string[256], File:file, File:temp;
file = fopen(filename, io_read);
temp = fopen("Bans.ini", io_write);
while (fread(file, string))
if (++count != line)
fwrite(temp, string);
fclose(file);
fclose(temp);
file = fopen(filename, io_write);
temp = fopen("Bans.ini", io_read);
while (fread(temp, string))
fwrite(file, string);
fclose(file);
fclose(temp);
fremove("Bans.ini");
}
You were not supposed to edit that function! Now it's screwed up and it will delete your whole file altogether. But, what's the point of that file if you use standard rcon bans?
|
Originally Posted by Vince
If your topic says "Help", I ignore it. Choose a descriptive title.
|
CMD:unbanip(playerid, params[])
{
if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
if(PlayerInfo[playerid][pAdmin] < 4) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
if(!aDuty[playerid]) return SendClientMessage(playerid, COLOR_GREY, "You are not on admin duty.");
new string[128];
if(sscanf(params, "s[16]", params)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /unbanip [ip]");
if(CheckInvalidIP(params)) return SendClientMessage(playerid, COLOR_GREY, "Invalid IP Address.");
new File:ban = fopen("ban.cfg", io_read);
new idx = 1, done;
while(fread(ban, string))
{
if(!strcmp(params, string, true, strlen(params)))
{
fdeleteline("ban.cfg", idx);
format(string, sizeof(string), "AdmWarn: %s has unbanned IP %s", RPN(playerid), params);
SendAdminMessage(COLOR_DARKRED, 1, string);
done = 1;
}
idx++;
}
fclose(ban);
if(!done) SendClientMessage(playerid, COLOR_GREY, "IP is not banned.");
return 1;
}