SA-MP Forums Archive
Factions not saving... - 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: Factions not saving... (/showthread.php?tid=349664)



Factions not saving... - cloudysky - 09.06.2012

Fixed, for now :L


AW: Factions not saving... - JhnzRep - 09.06.2012

Does the file show up in your scriptfiles?


Re: Factions not saving... - cloudysky - 09.06.2012

No it does not


AW: Factions not saving... - JhnzRep - 09.06.2012

Never used dini, so I'm horrible with it.


Re: Factions not saving... - cloudysky - 09.06.2012

It appears I am too :P


Re : Factions not saving... - ricardo178 - 09.06.2012

Example of how i do...

pawn Код:
enum fInfo
{
    FName,
    HQX,
    HQY,
    HQZ,
    HQInt,
    HQVw,
    HQIntX,
    HQIntY,
    HQIntZ,
    Leader,
    Rank1,
    Rank2,
    Rank3,
    Rank4,
    Rank5,
    Rank6,
    Rank7,
    HQLock,
    HQMaterials,
    HQWeapon1,
    HQWeapon2,
    HQWeapon3,
    HQWeapon4,
    HQWeapon5,
    HQWeapon6,
}
new FactionInfo[50][fInfo];

enum fInfo2
{
    topnumber,
}
new Factions[fInfo2];


//Save Factions Info
forward SaveFactionsInfo();
public SaveFactionsInfo()
{
    format(file, sizeof(file), "RRP/factions/Findex.ini");
    if(fexist(file))
    {
        dini_IntSet(file, "topnumber", Factions[topnumber]);
    }
    return 1;
}
//Load Factions Info
forward LoadFactionsInfo();
public LoadFactionsInfo()
{
    format(file, sizeof(file), "RRP/factions/Findex.ini");
    if(fexist(file))
    {
        Factions[topnumber] = dini_Int(file, "topnumber");
    }
    return 1;
}
//Save Factions
forward SaveFactions();
public SaveFactions()
{
    for(new i = 1; i < sizeof(FactionInfo); i++)
    {
        format(file, sizeof(file), "RRP/factions/%d.ini", i);
        if(fexist(file))
        {
            dini_Set(file, "FName", FactionInfo[i][FName]);
            dini_FloatSet(file, "HQX", FactionInfo[i][HQX]);
            dini_FloatSet(file, "HQY", FactionInfo[i][HQY]);
            dini_FloatSet(file, "HQZ", FactionInfo[i][HQZ]);
            dini_IntSet(file, "HQLock", FactionInfo[i][HQLock]);
            dini_Set(file, "Leader", FactionInfo[i][Leader]);
            dini_Set(file, "Rank1", FactionInfo[i][Rank1]);
            dini_Set(file, "Rank2", FactionInfo[i][Rank2]);
            dini_Set(file, "Rank3", FactionInfo[i][Rank3]);
            dini_Set(file, "Rank4", FactionInfo[i][Rank4]);
            dini_Set(file, "Rank5", FactionInfo[i][Rank5]);
            dini_Set(file, "Rank6", FactionInfo[i][Rank6]);
            dini_Set(file, "Rank7", FactionInfo[i][Rank7]);
            dini_IntSet(file, "HQMaterials", FactionInfo[i][HQMaterials]);
            dini_IntSet(file, "HQWeapon1", FactionInfo[i][HQWeapon1]);
            dini_IntSet(file, "HQWeapon2", FactionInfo[i][HQWeapon2]);
            dini_IntSet(file, "HQWeapon3", FactionInfo[i][HQWeapon3]);
            dini_IntSet(file, "HQWeapon4", FactionInfo[i][HQWeapon4]);
            dini_IntSet(file, "HQWeapon5", FactionInfo[i][HQWeapon5]);
            dini_IntSet(file, "HQWeapon6", FactionInfo[i][HQWeapon6]);
        }
    }
    return 1;
}
//Load Factions
forward LoadFactions();
public LoadFactions()
{
    for(new i = 1; i < sizeof(FactionInfo); i++)
    {
        format(file, sizeof(file), "RRP/factions/%d.ini", i);
        if(fexist(file))
        {
            FactionInfo[i][FName] = dini_Int(file, "FName");
            FactionInfo[i][HQX] = dini_Int(file, "HQX");
            FactionInfo[i][HQY] = dini_Int(file, "HQY");
            FactionInfo[i][HQZ] = dini_Int(file, "HQZ");
            FactionInfo[i][HQLock] = dini_Int(file, "HQLock");
            FactionInfo[i][Leader] = dini_Int(file, "Leader");
            FactionInfo[i][Rank1] = dini_Int(file, "Rank1");
            FactionInfo[i][Rank2] = dini_Int(file, "Rank2");
            FactionInfo[i][Rank3] = dini_Int(file, "Rank3");
            FactionInfo[i][Rank4] = dini_Int(file, "Rank4");
            FactionInfo[i][Rank5] = dini_Int(file, "Rank5");
            FactionInfo[i][Rank6] = dini_Int(file, "Rank6");
            FactionInfo[i][Rank7] = dini_Int(file, "Rank7");
            FactionInfo[i][HQMaterials] = dini_Int(file, "HQMaterials");
            FactionInfo[i][HQWeapon1] = dini_Int(file, "HQWeapon1");
            FactionInfo[i][HQWeapon2] = dini_Int(file, "HQWeapon2");
            FactionInfo[i][HQWeapon3] = dini_Int(file, "HQWeapon3");
            FactionInfo[i][HQWeapon4] = dini_Int(file, "HQWeapon4");
            FactionInfo[i][HQWeapon5] = dini_Int(file, "HQWeapon5");
            FactionInfo[i][HQWeapon6] = dini_Int(file, "HQWeapon6");
        }
    }
    return 1;
}


Under OnGameModeInit,

LoadFactions();



Re: Factions not saving... - [ABK]Antonio - 09.06.2012

pawn Код:
format(Factionfile, sizeof(Factionfile), "factions/%s.ini", i);
Is why it doesn't load


Re: Factions not saving... - cloudysky - 09.06.2012

Quote:
Originally Posted by [ABK]Antonio
Посмотреть сообщение
pawn Код:
format(Factionfile, sizeof(Factionfile), "factions/%s.ini", i);
Is why it doesn't load
Ok thank you, can you see any reason why it won't save?


Re : Re: Factions not saving... - ricardo178 - 09.06.2012

Quote:
Originally Posted by cloudysky
Посмотреть сообщение
Ok thank you, can you see any reason why it won't save?
Are factions supposed to save as factionname.ini or a number like 1.ini?

If is a number, than replace %s.ini with %d.ini....


Re: Factions not saving... - [ABK]Antonio - 09.06.2012

Quote:
Originally Posted by cloudysky
Посмотреть сообщение
pawn Код:
if( sscanf( params, "s[50]s[50]s[50]s[50]s[50]s[50]s[50]s[50]", fname, r1, r2, r3, r4, r5, r6, r7))
        CreateFaction(fname, r1, r2, r3, r4, r5, r6, r7);
Could be a reason it doesn't save - i would add a return 1 or something after that if statement