SA-MP Forums Archive
Find a name inside all existing files - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Find a name inside all existing files (/showthread.php?tid=216004)



Find a name inside all existing files - blackwave - 24.01.2011

I'm trying to load a name, looping all files which exists. I know how to do it, but since my files are numerated like: 0, 1, 2, 3, 4 ... Then I need to know which file of these one the name have been loaded.

pawn Code:
public OnPlayerConnect(playerid)
{
    static str[128];
    Loop(h, MAX_VEHICLES)
    {
       format(file,sizeof(file),local,h);
       if(dini_Exists(file)) // I'm using dini in this cas
       {
           if(!strcmp(GetMyName(playerid), dini_Get(file,"Name"), true)) // Would search on all files
           {
                format(str,sizeof(str),""#red"[CAR SYSTEM]: "#green"Hello %s. You own a vehicle model %i. Your vehicle ID is: %i", // I didn't end here yet.
                Player[playerid][Owner] = 1;
           }
        }
    }
    return 1;
}
So, how can I know what file the name have been loaded from?


Re: Find a name inside all existing files - Vince - 24.01.2011

Add a break statement after 'Player[playerid][Owner] = 1;'. This will jump straight out of the loop once the item is found, and your 'file' variable will still be usable. Assuming that each player can only own 1 car.


Re: Find a name inside all existing files - blackwave - 24.01.2011

I mean: the loop will search on all files on that folder for the name of the player which has connected. But I want to know the file number which has found this player name, since the files are like: 0,1,2,3,4,5,6..


Re: Find a name inside all existing files - blackwave - 24.01.2011

Anyone?


AW: Find a name inside all existing files - Nero_3D - 25.01.2011

pawn Code:
public OnPlayerConnect(playerid)
{
    static str[128];
    Loop(h, MAX_VEHICLES)
    {
        format(file,sizeof(file),local,h);
        if(dini_Exists(file)) // I'm using dini in this cas
        {
            if(!strcmp(GetMyName(playerid), dini_Get(file,"Name"), true)) // Would search on all files
            {
                format(str,sizeof(str),""#red"[CAR SYSTEM]: "#green"Hello %s. You own a vehicle model %i. Your vehicle ID is: %i", // I didn't end here yet.
                Player[playerid][Owner] = 1;
                //Just add your code here, the variable which stores the number is h
            }
        }
    }
    return 1;
}



Re: Find a name inside all existing files - Sergei - 25.01.2011

Use SQLite or MySQL. Files aren't meant to be used like that.