How to randomly read from files?
#1

So as the title says i dont know how to randomly read from files that are located in scriptfiles.

So for example in scriptfiles i have like: File1.ini, File2.ini and File3.ini

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    new string[128];
    if (strcmp("/load", cmdtext, true, 10) == 0)
    {
        format(string, sizeof(string), "%s.ini");
        new rand = random(string);
        fopen(string, io_read);
        {
            /* etc */
        }
    }
    return 0;
}
Something like this, hope i explained well. Please help.
Reply
#2

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    new string[128];
    if (strcmp("/load", cmdtext, true, 10) == 0)
    {
        new rand = 1+random(3);
        format(string, sizeof(string), "File%d.ini", rand);
        fopen(string, io_read);
        {
            /* etc */
        }
    }
    return 0;
}
I didn't test it.
Reply
#3

Hmm, that could work, thank you
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)