fdeleteline
#1

I have /ban when someone ban with /ban it save their ban ip in bans.ini
now i have create /unbanip and in order to avoid the ban checking in unban user
i have to delete the lines in Bans.ini
Perfect timing i found fdeleteline somewhere in SAMP Forums.

The problem is i don't know how to use for my /unbanip
Can someone tell me how to do it?

pawn Код:
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");
}
Reply
#2

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?
Reply
#3

Quote:
Originally Posted by Vince
Посмотреть сообщение
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?
+1 I use them too. Just not for the temp ban and account blockage.

Quote:
Originally Posted by Vince
If your topic says "Help", I ignore it. Choose a descriptive title.
Lmfao xD. I Understand.
Reply
#4

The reason why i use custom ban function is i want to replace the ban message. instead of banning their ip with rcon banip plus i'm not the one who edit fdeleteline i found it somewhere.
Reply
#5

BUMP
Reply
#6

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;
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)