Searching through all userfiles and getting a value -
iRage - 23.04.2012
I've tried to look at YSF's functions but I can't really manage to understand them.
What I'm basically trying to do is searching through the whole "users/" directory, file by file, extracting admin value and showing it on a Client Message if it's above 1.
Ex:
PHP код:
new adminlvl, string[64];
// Some shit to search through all userfiles in the folder "users"
adminlvl = // "Admin=" value grabbed from the file
if(adminlvl > 0)
{
format(string, sizeof(string), "Name: %s | Level: %d", /*file name*/, adminlvl);
SendClientMessage(playerid, ShitColor, string);
}
Any ideas?
Re: Searching through all userfiles and getting a value -
2KY - 23.04.2012
Well, if you're using Y_INI, just parse all of the data if the file exists (
if ( fexist ( ... ) ) ) inside of a loop and then store the information.
Re: Searching through all userfiles and getting a value -
notepad - 23.04.2012
What about writing everything inside a unique file? It would be simpler and more efficient.
Re: Searching through all userfiles and getting a value -
2KY - 23.04.2012
Quote:
Originally Posted by notepad
What about writing everything inside a unique file? It would be simpler and more efficient.
|
You know, that's a good idea.
Quote:
Originally Posted by admins.cfg
Admin1 = 5
Admin2 = 1
Admin3 = 2
Admin4 = 6
|
Then you could parse the data and use it...
Re: Searching through all userfiles and getting a value -
iRage - 23.04.2012
@2KY I'm trying to search through ALL userfiles, no certain file. If it was the case of a certain file it wouldn't be a problem at all.
@notepad & 2KY
I'm actually trying to find out if ANY userfile has an admin level.
Assigning their names to a file is a good idea but it won't be effecient if the admin level was set to the userfile via FTP.
Re: Searching through all userfiles and getting a value -
2KY - 24.04.2012
Quote:
Originally Posted by iRage
@2KY I'm trying to search through ALL userfiles, no certain file. If it was the case of a certain file it wouldn't be a problem at all.
@notepad & 2KY
I'm actually trying to find out if ANY userfile has an admin level.
Assigning their names to a file is a good idea but it won't be effecient if the admin level was set to the userfile via FTP.
|
1: Loop through all of the files, problem solved.
2: It'd be more efficient just to update two files and have the server go through writing a file and reading a file again than looping through 10,000+ user files.
Re: Searching through all userfiles and getting a value -
iRage - 24.04.2012
Quote:
Originally Posted by 2KY
1: Loop through all of the files, problem solved.
2: It'd be more efficient just to update two files and have the server go through writing a file and reading a file again than looping through 10,000+ user files.
|
1: That's what I'm exactly having a problem at. Can't manage to get it done.
2: I don't care much about the speed as I do about the check accuracy.
Making it save names into a file is pretty easy, but it doesn't get the job done which is detecting ALL admins in the users folder.
I wouldn't make it put someone's name into the file once he logs in neither as it still won't be accurate until he connects to the server.
Re: Searching through all userfiles and getting a value -
ReneG - 24.04.2012
Then you could simply just write all the admin names to file instead of looping through every file to get one key.
Re: Searching through all userfiles and getting a value -
iRage - 24.04.2012
Quote:
Originally Posted by VincentDunn
Then you could simply just write all the admin names to file instead of looping through every file to get one key.
|
If you can actually read I've stated million times before that it wouldn't be accurate if the key was set via FTP.
Re: Searching through all userfiles and getting a value -
iRage - 24.04.2012
Quote:
Originally Posted by ******
You are pulling data from many different locations. Files are TERRIBLE at this because the disk access is so slow (and for once we're not talking minor slow-downs, this is MAJOR). Either just use one file to get all the data from one place (at which files are good), or use a system that is good at pulling data from many different locations (i.e. a database).
|
Maybe you can show me a system example?