Dynamic Faction Problem
#1

Hi,

I have a problem where on /factions it shows but the Members says something like 48 here is my code:

pawn Код:
CMD:factions(playerid, params[])
{
    new string[678];
    SendClientMessage(playerid, COLOR_ORANGE, "___ FACTIONS OF QUANTUM GAMING NETWORK ___");
    format(string,sizeof(string),"1. %s | Leader: %s | Members: %d", FactionInfo[0][FactionName], FactionInfo[0][FactionLeader], FactionInfo[0][FactionMembers]);
    SendClientMessage(playerid, COLOR_WHITE, string);
    format(string,sizeof(string),"2. %s | Leader: %s | Members: %d", FactionInfo[1][FactionName], FactionInfo[1][FactionLeader], FactionInfo[1][FactionMembers]);
    SendClientMessage(playerid, COLOR_WHITE, string);
    format(string,sizeof(string),"3. %s | Leader: %s | Members: %d", FactionInfo[2][FactionName], FactionInfo[2][FactionLeader], FactionInfo[2][FactionMembers]);
    SendClientMessage(playerid, COLOR_WHITE, string);
    format(string,sizeof(string),"4. %s | Leader: %s | Members: %d", FactionInfo[3][FactionName], FactionInfo[3][FactionLeader], FactionInfo[3][FactionMembers]);
    SendClientMessage(playerid, COLOR_WHITE, string);
    format(string,sizeof(string),"5. %s | Leader: %s | Members: %d", FactionInfo[4][FactionName], FactionInfo[4][FactionLeader], FactionInfo[4][FactionMembers]);
    SendClientMessage(playerid, COLOR_WHITE, string);
    format(string,sizeof(string),"6. %s | Leader: %s | Members: %d", FactionInfo[5][FactionName], FactionInfo[5][FactionLeader], FactionInfo[5][FactionMembers]);
    SendClientMessage(playerid, COLOR_WHITE, string);
    format(string,sizeof(string),"7. %s | Leader: %s | Members: %d", FactionInfo[6][FactionName], FactionInfo[6][FactionLeader], FactionInfo[6][FactionMembers]);
    SendClientMessage(playerid, COLOR_WHITE, string);
    format(string,sizeof(string),"8. %s | Leader: %s | Members: %d", FactionInfo[7][FactionName], FactionInfo[7][FactionLeader], FactionInfo[7][FactionMembers]);
    SendClientMessage(playerid, COLOR_WHITE, string);
    format(string,sizeof(string),"9. %s | Leader: %s | Members: %d", FactionInfo[8][FactionName], FactionInfo[8][FactionLeader], FactionInfo[8][FactionMembers]);
    SendClientMessage(playerid, COLOR_WHITE, string);
    format(string,sizeof(string),"10. %s | Leader: %s | Members: %d", FactionInfo[9][FactionName], FactionInfo[9][FactionLeader], FactionInfo[9][FactionMembers]);
    SendClientMessage(playerid, COLOR_WHITE, string);
    return 1;
}
it says on the first one

1. Los Santos Police Department | Leader: None | Members: 48
Reply
#2

There's obviously something wrong with your code where you save the factionmembers, or add it to or something. it's got nothing to do with that code.
Reply
#3

All I have at the moment is a Loading Function, /factions and the factions.cfg I am converting it from static to dynamic.

EDIT: I have noticed I put FactionMembers in the wrong place on saving.
Reply
#4

still does it

pawn Код:
stock LoadFactions() {

    if(!fexist("factions.cfg")) return 1;

    new
        szFileStr[512],
        iIndex,
        File: iFileHandle = fopen("factions.cfg", io_read);

    while (iIndex < sizeof(FactionInfo) && fread(iFileHandle, szFileStr)) {

        sscanf(szFileStr, "p<|>is[42]s[65]s[24]is[20]s[20]s[20]s[20]s[20]s[20]s[20]ii",
            FactionInfo[iIndex][FactionTaken],
            FactionInfo[iIndex][FactionName],
            FactionInfo[iIndex][FactionMOTD],
            FactionInfo[iIndex][FactionLeader],
            FactionInfo[iIndex][FactionBank],
            FactionInfo[iIndex][FactionType],
            FactionInfo[iIndex][FactionMembers],
            FactionInfo[iIndex][FactionRank0],
            FactionInfo[iIndex][FactionRank1],
            FactionInfo[iIndex][FactionRank2],
            FactionInfo[iIndex][FactionRank3],
            FactionInfo[iIndex][FactionRank4],
            FactionInfo[iIndex][FactionRank5],
            FactionInfo[iIndex][FactionRank6],
            FactionInfo[iIndex][FactionColor]
        );
        ++iIndex;
    }
    return fclose(iFileHandle);
}
Saving:

pawn Код:
stock SaveFactions()
{
    new idx;
    new File: file2;
    while (idx < sizeof(FactionInfo))
    {
        new coordsstring[512];
        format(coordsstring, sizeof(coordsstring), "%d|%s|%s|%s|%d|%s|%s|%s|%s|%s|%s|%s|%d|%d\n",
        FactionInfo[iIndex][FactionTaken],
        FactionInfo[iIndex][FactionName],
        FactionInfo[iIndex][FactionMOTD],
        FactionInfo[iIndex][FactionLeader],
        FactionInfo[iIndex][FactionBank],
        FactionInfo[iIndex][FactionType],
        FactionInfo[iIndex][FactionMembers],
        FactionInfo[idx][FactionRank0],
        FactionInfo[idx][FactionRank1],
        FactionInfo[idx][FactionRank2],
        FactionInfo[idx][FactionRank3],
        FactionInfo[idx][FactionRank4],
        FactionInfo[idx][FactionRank5],
        FactionInfo[idx][FactionRank6],
        FactionInfo[idx][FactionColor]);
        if(idx == 0)
        {
            file2 = fopen("factions.cfg", io_write);
        }
        else
        {
            file2 = fopen("factions.cfg", io_append);
        }
        fwrite(file2, coordsstring);
        idx++;
        fclose(file2);
    }
    return 1;
}
Enums:

pawn Код:
enum FacInfo
{
    FactionTaken,
    FactionName[42],
    FactionMOTD[65],
    FactionLeader[MAX_PLAYER_NAME],
    FactionBank,
    FactionType,
    FactionMembers,
    FactionRank0[20],
    FactionRank1[20],
    FactionRank2[20],
    FactionRank3[20],
    FactionRank4[20],
    FactionRank5[20],
    FactionRank6[20],
    FactionColor
}
new FactionInfo[MAX_FACTIONS][FacInfo];
Reply
#5

Anyone help? It still does it but in the factions.cfg it says 0.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)