Searching through all userfiles and getting a value
#1

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 adminlvlstring[64];
// Some shit to search through all userfiles in the folder "users"
adminlvl // "Admin=" value grabbed from the file
if(adminlvl 0)
{
      
format(stringsizeof(string), "Name: %s | Level: %d"/*file name*/adminlvl);
      
SendClientMessage(playeridShitColorstring); 

Any ideas?
Reply
#2

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

What about writing everything inside a unique file? It would be simpler and more efficient.
Reply
#4

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

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

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

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

Then you could simply just write all the admin names to file instead of looping through every file to get one key.
Reply
#9

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

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?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)