Serach users from ini files
#1

Hello all,

I want to find some users and I know part of name I don't know how to do search in ini files only with part of name users.
like this:
[R]Worson.txt
how can I do it?
Reply
#2

go to your gamemod derictory/scriptfiles/users/you'll find there the users.ini ( most servers use this system)
Reply
#3

I don't use in users.ini, if player register to server that's open new txt file I want do command to find all of txt files with part of name - Loop.
Reply
#4

i dont get your idea 100 percent , but i would say , go to your gamemod / registration system , whene player register(put his password and logins ) find the write"file.txt" system you'll find ther fopen("file..."); and his path,
Reply
#5

I don't actually know if this is possible with Y_INI, I mean obviously it would be possible in some way, but it would be a shit load of loops and data usage etc.

The best option is to go with MySQL or SQLite, which for your convenience, I don't have very much experience in. I'm fairly sure this is possible in MySQL without some bitch-ass code to fill your entire script.
Reply
#6

https://sampwiki.blast.hk/wiki/Strfind
Reply
#7

I have 3,000 users, I can't do it now. What about 3000 users ?
I mean to this:
PHP код:

    
if(!strcmp(cmd,"/fineuser",true))
    {
    
format(string,sizeof(string),"Users/%s.txt",/*part of name*/);
    if(!
DOF2_FileExists(string)) return SendClientMessage(playerid,COLOR_RED,"Invalid Name.");
        for(new 
i3000i++)
        {
         
//the closest name
         
format(string,sizeof(string),"%s");
         }
    return 
1;
    } 
I do not know how to make it because it's hard for me to give you a simpler example.
Understood ?
Reply
#8

The only way this would be possible with strfind is if you had a text file that contained the names of every single player that has registered to your server.

pawn Код:
//OnPlayerRegister
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    new str[30];
    format(str, sizeof(str), "%s\r\n", name);
    new File:text = fopen("Players.txt", io_append);
    fwrite(text, str);
    fclose(text);
    //Continue..

//Example with ZCMD of how you would use it:
CMD:findplayer(playerid, params[])
{
    if(!strlen(params) || strlen(params) > MAX_PLAYER_NAME) return SendClientMessage(playerid, 0xFF0000FF, "USAGE: /findplayer [part of name]");
    new count = 0, File:text = fopen("Players.txt", io_read), string[50];
    format(string, sizeof(string), "Player Names Containing '%s'", params);
    SendClientMessage(playerid, 0x00FF00FF, string);
    while(fread(text, string))
    {
        if(strfind(string, params, true) != -1)
        {
            SendClientMessage(playerid, 0xFFFF00FF, string);
            count++;
        }
    }
    if(count == 0) return SendClientMessage(playerid, 0xFF0000FF, "No matches found.");
    return 1;
}
Should work.
Reply
#9

Thank you very much.
Do I understand correctly that there is no other way?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)