Count # of files (dini)
#1

Hi all. I was just wondering, how can i count how many files are in the Users directory of scriptfiles... they are .ini files. This isnt urgent, but i would really like to know. THANKS!
Reply
#2

I have this question two
Reply
#3

soooo... bump i guess.
Reply
#4

if you have files with names: 1.ini , 2.ini .......n.ini

you can do this:


put your max files value
pawn Код:
#define MAX_FILES 100//you can add more, 100 for example

then function:

pawn Код:
stock FilesCount()
{
    new fCount = 0, str[128];
    for(new i=0; i<MAX_FILES; i++)
    {
        format(str, sizeof str,"%s.ini",i);
        if(dini_Exists(str))
        {
            fCount++;
        }
    }
    return printf("i have %i files",fCount);
}
and put this function into GM init!
Reply
#5

no.. its like.. player names... sooo..., what to do?
Reply
#6

why you need it? per what exactly?
Reply
#7

i just want to do something like this on ONFilterScriptInit()

printf("%d user accounts loaded!", num);
Reply
#8

Open scriptfiles -> ctrl + a = success xd
or create file "Accounts.ini" and if player type /register update Accounts get+1 and set
Reply
#9

ok. hehe .
Reply
#10

Or from the beginning make a...

new useraccounts;

ongamemodeinit
{
if(!Dini_Exists("useraccountsfile.ini"))
{
useraccounts = 0;

Dini_Create("useraccountsfile.ini");
Dini_SetInt("useraccountsfile.ini", "AccountsCreated", 0);
}
else
{
useraccounts = Dini_GetInt("useraccountsfile.ini", "AccountsCreated");
}
}
ongamemodeexit
{
if(!Dini_Exists("useraccountsfile.ini"))
{
useraccounts = 0;

Dini_Create("useraccountsfile.ini");
Dini_SetInt("useraccountsfile.ini", "AccountsCreated", 0);
}
else
{
Dini_SetInt("useraccountsfile.ini", "AccountsCreated", useraccounts);
}
}

after account registration make

useraccounts++;

then you can

printf("%d user accounts loaded!", useraccounts);

but... you'd have to make everyone re-register.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)