17.05.2012, 14:11
This is my banip command, check it for an example of fdeleteline usage.
pawn Код:
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;
}

