SA-MP Forums Archive
file.inc erase from file? help please. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: file.inc erase from file? help please. (/showthread.php?tid=120402)



file.inc erase from file? help please. - introzen - 11.01.2010

Hey, I'm a newbie when it comes to file_functions..

I've looked on wiki and in the forum but I can't find anything about how to erase something from a file. Example:
Код:
Hello
n00b
password <---------- How to delete this line with fwrite or something?
not
allowed
Thanks.


Re: file.inc erase from file? help please. - [HiC]TheKiller - 11.01.2010

https://sampwiki.blast.hk/wiki/Fdelete_code


Re: file.inc erase from file? help please. - introzen - 11.01.2010

Quote:
Originally Posted by [HiC
I don't understand it...


Re: file.inc erase from file? help please. - [HiC]TheKiller - 11.01.2010

Quote:
Originally Posted by IntrozeN
Quote:
Originally Posted by [HiC
I don't understand it...
What part do you not understand? Just loop through and check if it's the right line then delete it.


Re: file.inc erase from file? help please. - introzen - 11.01.2010

Quote:
Originally Posted by [HiC
TheKiller ]
Quote:
Originally Posted by IntrozeN
Quote:
Originally Posted by [HiC
I don't understand it...
What part do you not understand? Just loop through and check if it's the right line then delete it.
That's what I don't understand. How to check the right line? Also I get an error about fcreate. unknown function =/.


Re: file.inc erase from file? help please. - Calon - 11.01.2010

Like this:

pawn Код:
fdeleteline("happybirthday.ini", "password");
Add this too:

pawn Код:
public fcreate(filename[])
{
  if (fexist(filename)){return false;}
  new File:fhandle = fopen(filename,io_write);
  fclose(fhandle);
  return true;
}



Re: file.inc erase from file? help please. - introzen - 11.01.2010

pawn Код:
dcmd_unsuspendname(playerid,params[])
{
  if(PlayerInfo[playerid][pAdmin] < 1) return 1;
  new pName[MAX_PLAYER_NAME], Name[MAX_PLAYER_NAME], string[128];
  if(sscanf(params,"s",Name)) return SendClientMessage(playerid,COLOR_GREY,".: Usage: /unsuspendname [accountname] :.");
  new File:check = fopen("CLRP/Bans.ban", io_read);
  while(fread(check,string))
  {
        if(strcmp(string,pName,false)) return SendClientMessage(playerid,COLOR_DARKRED,".: Info: Account is not banned :.");
    }
    fdeleteline("CLRP/Bans.ban",pName);
  fclose(check);
  format(string,sizeof(string),".: Info: You have unbanned name %s :.",Name);
    SendClientMessage(playerid,COLOR_LIGHTBLUE,string);
    return 1;
}
That doesn't delete the player name from Bans.ban


Re: file.inc erase from file? help please. - introzen - 12.01.2010

Bump. need help