file.inc erase from file? help please.
#1

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.
Reply
#2

https://sampwiki.blast.hk/wiki/Fdelete_code
Reply
#3

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

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.
Reply
#5

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 =/.
Reply
#6

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

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
Reply
#8

Bump. need help
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)