Search for a file
#1

Kinda simple and fast explanatory;

How to search for a file in the scriptfiles folder?

E.g. : I want every account to be found so I can open them all afterwards, easy for setting variables for every account.

- KnooL
Reply
#2

This is not possible except by generating random file names and checking if they exist ( https://sampwiki.blast.hk/wiki/Fexist ). Set all the values you need to at account creation or have a list where you store all account file names and then read them from that list
Reply
#3

Yeah it's impossible. You should know that, Zir KnooL! You have FAILED! FAILED!
Reply
#4

Quote:
Originally Posted by JaloNik
Посмотреть сообщение
Yeah it's impossible. You should know that, Zir KnooL! You have FAILED! FAILED!
fuck ur spam nikolaj
Reply
#5

It isn't impossible, is it?

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
   new cmd[256], tmp[256], Pfile[50], idx;
   cmd = strtok(cmdtext, idx);
   if(!strcmp(cmd, "/searchfile", true))
   {
      tmp = strtok(cmdtext, idx);
      if(!strlen(tmp)) return SendClientMessage(playerid, 0xFF0000, "Usage: /searchfile [filename]");
      new search = strval(tmp);
      format(Pfile, sizeof(Pfile), "Users/%s.txt", search); // or whatever your user files are
      if(fexists(Pfile)) return SendClientMessage(playerid, 0xFF0000, "The file exists!");
      if(!fexists(Pfile)) return SendClientMessage(playerid, 0xFF0000, "The file doesn't exists!");
      return 1;
   }
}
Not tested
Reply
#6

The server is supposed to browse and list the files in the folder for setting variables of each file.
Thanks anyway.
Reply
#7

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
   new cmd[256], Pfile[50], idx;
   cmd = strtok(cmdtext, idx);
   if(!strcmp(cmd, "/searchfiles", true))
   {
      SendClientMessage(playerid, 0xFF0000, "User Files:");
      new Msg[40];
      for(new search[MAX_PLAYER_NAME]; search < MAX_PLAYER_NAME; search++)
      {
         format(Pfile, sizeof(Pfile), "Users/%s.txt", search); // or whatever your user files are
         format(Msg, sizeof(Msg), "Founded: %s");
         SendClientMessage(playerid, 0xFF0000, Msg);
      }
      return 1;
   }
}
It will list like:
Код:
Founded: 111
Founded: 234
Founded: 542
But I don't know how to find names, well I know, if the player is in the server...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)