Delete File
#1

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

UP!
Reply
#3

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

Reply
#5

fremove(file);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)