How to delete a line in a .txt file?
#6

Since I haven't tested the code, I'm not sure if it will work. However try this:

pawn Код:
CheckName(teamname[], name[])
{
    new string[20];
    new destination[128];
    format(destination, sizeof(destination), "fLogs/%s.fam.log", teamname);
    new File: file = fopen(destination, io_read); // I'm not sure what's the name of the log file.
    while(fread(file, string))
    {
        if (strcmp(name, string, true, strlen(name)) == 0)
        {
            fclose(file);
            return 1;
        }
    }
    fclose(file);
    return 0;
}

RemoveName(teamname[], name[])
{
    if(CheckName(teamname, name) == 1)
    {
        new string[20];
        new destination[128];
        format(destination, sizeof(destination), "fLogs/%s.fam.log", teamname);
        new File: file = fopen(destination, io_read);
        fcreate("TempFamLog.cfg");
        new File: file2 = fopen("TempFamLog.cfg", io_append);
        while(fread(file, string))
        {
            if (strcmp(name, string, true, strlen(name)) != 0 && strcmp("\n", string) != 0)
            {
                fwrite(file2, string);
            }
        }
        fclose(file);
        fclose(file2);
        file = fopen(destination, io_write);
        file2 = fopen("TempFamLog.cfg", io_read);
        while(fread(file2, string))
        {
            fwrite(file, string);
        }
        fclose(file);
        fclose(file2);
        fremove("TempFamLog.cfg");
        return 1;
    }
    return 0;
}

COMMAND:auninvite(playerid, params[])
{
    if(GetAdminLevel(playerid) < 10) return SendClientError(playerid, CANT_USE_CMD);
    new iPlayer;
    if( sscanf ( params, "u", iPlayer)) return SCP(playerid, "[PlayerID/PartOfName]");
    if(!IsPlayerConnected(iPlayer)) return SendClientError(playerid, PLAYER_NOT_FOUND);
   
    new pname[24];
    new dest[128];
    GetPlayerName(iPlayer, pname, sizeof(pname));
    RemoveName(PlayerInfo[iPlayer][PTeamName], pname);
    Uninvite(iPlayer,GetPlayerFaction(iPlayer));
    return 1;
}
Reply


Messages In This Thread
fdeleteline Problem - by Lionel - 14.04.2013, 10:45
AW: How to delete a line in a .txt file? - by Lionel - 14.04.2013, 15:35
Re: How to delete a line in a .txt file? - by LarzI - 14.04.2013, 15:46
AW: How to delete a line in a .txt file? - by Lionel - 14.04.2013, 15:49
Re: How to delete a line in a .txt file? - by LarzI - 14.04.2013, 15:53
Re: How to delete a line in a .txt file? - by JJB562 - 14.04.2013, 15:54
AW: How to delete a line in a .txt file? - by Lionel - 14.04.2013, 15:54
AW: How to delete a line in a .txt file? - by Lionel - 14.04.2013, 16:00
Re: How to delete a line in a .txt file? - by JJB562 - 14.04.2013, 16:02
AW: How to delete a line in a .txt file? - by Lionel - 14.04.2013, 16:03

Forum Jump:


Users browsing this thread: 2 Guest(s)