SA-MP Forums Archive
Delete File - 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: Delete File (/showthread.php?tid=109166)



Delete File - Marshew_DD - 18.11.2009

I'm trying to delete the accounts banned. But when this function opens the file, some accounts have the value 1 or 0. But when he finds the value 1 it does not delete the account but sends the printf.


Код:
	new cmdt[256];
	new idx;
	cmdt = strtok(cmd, idx);
    if(strcmp(cmd,"delbans",true)==0){
 	    new File:fp = fopen("allplayers.txt", io_read), tmp[128];
		while(fread(fp, tmp, sizeof tmp)){
	  	  printf("Player File: %s", tmp);
	  	  new File:file=fopen(PlayerFile(tmp),io_read);
	  	  new valor = strval(GetValue(PlayerFile(tmp),"Ban"));
	  	  printf("Ban Value: %d", valor);
	  	  if(valor == 1){
	  	    fremove(PlayerFile(tmp));
	 	  	printf("ACC %s deleted", tmp);
	  	  }
	  	  fclose(file);
		}
	 }
Код:
stock PlayerFile(name[]){
	new str[50];
	format(str,sizeof(str),"Players/%s",name);
	return str;
}



Re: Delete File - Marshew_DD - 18.11.2009

UP!


Re: Delete File - Marshew_DD - 18.11.2009

Код:
	new File:fp = fopen("allplayers.txt", io_read), tmp[128];
	while(fread(fp, tmp, sizeof tmp)){
	  	printf("Player File: %s", tmp);
	  	file=fopen(PlayerFile(tmp),io_read);
	  	value = strval(GetValue(PlayerFile(tmp),"Ban"));
	  	printf("Ban: %d", value);
  	  }
  	  fclose(file);
  	  fclose(fp);
  	  if(value == 1){
  	  	format(path, sizeof path, "Players/%s", tmp);
 	  	  printf("Acc %s deleted", tmp);
 	  	  fremove(path);
		}



Re: Delete File - Ritchie999 - 18.11.2009




Re: Delete File - dice7 - 18.11.2009

fremove(file);