SA-MP Forums Archive
ParseFile problems? - 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)
+--- Thread: ParseFile problems? (/showthread.php?tid=318601)



ParseFile problems? - 2KY - 15.02.2012

I've run into one problem, although I'm not sure if it's an enum problem anymore.. I think the problem is with INI_ParseFile, which I'm assuming I'm not using it correctly. Help? Please?

pawn Code:
#define         MAX_FACTIONS                100

enum E_facVars
{
    facName[64],
    facType,
    facRank1[32],
    facRank2[32],
    facRank3[32],
    facRank4[32],
    facRank5[32]
}
new
    facInfo[MAX_FACTIONS][E_facVars];

public OnGameModeInit()
{
    new
        facStr[32];
           
    for( new f = 0; f < MAX_FACTIONS; f++ )
    {
        format(facStr, sizeof(facStr), "RPMod/Factions/%d.ini", f);
        if(fexist(facStr))
        {
            INI_ParseFile(facStr, "LoadFaction");
            printf("[LOAD] Faction %d loaded; Name: %s | Type: %d", f, facInfo[f][facName], facInfo[f][facType]);
        }
    }
    return true;
}

public OnGameModeExit()
{
    new
        facStr[15];
           
    for( new f = 0; f < MAX_FACTIONS; f++ )
    {
        format(facStr, sizeof(facStr), "RPMod/Factions/%d.ini", f);
        if(fexist(facStr))
        {
            new
                INI:facFile = INI_Open(facStr);
                   
            INI_WriteString(facFile, "Name", facInfo[f][facName]);
            INI_WriteInt(facFile, "Type", facInfo[f][facType]);
            INI_WriteString(facFile, "Rank1", facInfo[f][facRank1]);
            INI_WriteString(facFile, "Rank2", facInfo[f][facRank2]);
            INI_WriteString(facFile, "Rank3", facInfo[f][facRank3]);
            INI_WriteString(facFile, "Rank4", facInfo[f][facRank4]);
            INI_WriteString(facFile,  "Rank5", facInfo[f][facRank5]);
                       
            INI_Close(facFile);
        }
    }
    return true;
}

forward LoadFactions(name[], value[]);
public LoadFactions(name[], value[])
{
    for ( new f = 0; f < MAX_FACTIONS; f++ )
    {
        INI_String("Name", facInfo[f][facName], 64);
        INI_Int("Type", facInfo[f][facType]);
        INI_String("Rank1", facInfo[f][facRank1], 32);
        INI_String("Rank2", facInfo[f][facRank2], 32);
        INI_String("Rank3", facInfo[f][facRank3], 32);
        INI_String("Rank4", facInfo[f][facRank4], 32);
        INI_String("Rank5", facInfo[f][facRank5], 32);
    }
    return true;
}
What am I doing wrong? I'm so close, yet so far.