PDA

View Full Version : MYSQL R7 only loading one row


MattSlater
25/09/2013, 10:41 PM
case THREAD_LOAD_FACTIONS:
{
new rows, szLabel[128];
cache_get_data(rows, szFields);

for(new row = 0; row < szRows; szRows++)
{
cache_get_field_content(row,"faction_id", szResult); FactionInfo[szRows][fI_iSQLID] = szRows;
cache_get_field_content(row,"badge_colour", szResult); FactionInfo[szRows][fI_bColour] = strval(szResult);
cache_get_field_content(row,"name", szResult); format(FactionInfo[szRows][fI_Name], 40, szResult);
cache_get_field_content(row,"motd", szResult); format(FactionInfo[szRows][fI_MOTD], 64, szResult);
cache_get_field_content(row,"leader", szResult); format(FactionInfo[szRows][fI_Leader], 24, szResult);
cache_get_field_content(row,"type", szResult); FactionInfo[szRows][fI_iType] = strval(szResult);
cache_get_field_content(row,"leader_rank", szResult); FactionInfo[szRows][fI_LRank] = strval(szResult);
cache_get_field_content(row,"balance", szResult); FactionInfo[szRows][fI_vBalance] = strval(szResult);
cache_get_field_content(row,"lock_stock", szResult); FactionInfo[szRows][fI_wStock] = strval(szResult);
cache_get_field_content(row,"lock_vw", szResult); FactionInfo[szRows][fI_vVW] = strval(szResult);
cache_get_field_content(row,"lock_intid", szResult); FactionInfo[szRows][fI_vIntID] = strval(szResult);
cache_get_field_content(row,"lock_posX", szResult); FactionInfo[szRows][fI_vPos][0] = floatstr(szResult);
cache_get_field_content(row,"lock_posY", szResult); FactionInfo[szRows][fI_vPos][1] = floatstr(szResult);
cache_get_field_content(row,"lock_posZ", szResult); FactionInfo[szRows][fI_vPos][2] = floatstr(szResult);

for(new r = 0; r < MAX_FACTION_RANK; r++) { format(szLabel, sizeof(szLabel), "rank_%d", r); cache_get_field_content(0, szLabel, FactionRanks[szRows][r], MainPipeline); }
for(new w = 0; w < MAX_FACTION_WEAPON; w++) { format(szLabel, sizeof(szLabel), "weapon_%d", w+1); cache_get_field_content(0, szLabel, szResult); FactionInfo[szRows][fI_Weapons][w] = strval(szResult); }
for(new d = 0; d < MAX_FACTION_DIVISION; d++) { format(szLabel, sizeof(szLabel), "division_%d", d+1); cache_get_field_content(0, szLabel, FactionDivisions[szRows][d], MainPipeline); }
for(new pay = 0; pay < MAX_FACTION_RANK; pay++) { format(szLabel, sizeof(szLabel), "pay_%d", pay+1); cache_get_field_content(0, szLabel, szResult); FactionPay[szRows][pay] = strval(szResult); }

DestroyDynamic3DTextLabel(FactionInfo[szRows][fI_vLabel]);
format(szLabel, sizeof(szLabel), "[ %s Locker ]", FactionInfo[szRows][fI_Name]);
FactionInfo[szRows][fI_vLabel] = CreateDynamic3DTextLabel(szLabel, COLOR_WHITE, FactionInfo[szRows][fI_vPos][0], FactionInfo[szRows][fI_vPos][1], FactionInfo[szRows][fI_vPos][2], 10.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 1,FactionInfo[szRows][fI_vVW], FactionInfo[szRows][fI_vIntID], -1);
DestroyDynamic3DTextLabel(FactionInfo[szRows][fI_vLabel]);
FactionInfo[szRows][fI_vPickup] = CreateDynamicPickup(1239, 23, FactionInfo[szRows][fI_vPos][0], FactionInfo[szRows][fI_vPos][1], FactionInfo[szRows][fI_vPos][2], FactionInfo[szRows][fI_vVW]);
FactionInfo[szRows][fI_vLabel] = CreateDynamic3DTextLabel(szLabel, COLOR_WHITE, FactionInfo[szRows][fI_vPos][0], FactionInfo[szRows][fI_vPos][1], FactionInfo[szRows][fI_vPos][2], 10, -1, -1, 1,FactionInfo[szRows][fI_vVW], FactionInfo[szRows][fI_vIntID], -1);

printf("[SERVER]: %d factions were loaded.", szRows);
}
}


Basically, if I have one faction in the database then it loads fine, but if I have 2 or more then the loading messes up and doesn't load them all.

Any help, please?

magnusburton
25/09/2013, 10:52 PM
Shouldn't this solve it?
for(new row = 0; row < szRows; row++)

MattSlater
25/09/2013, 11:03 PM
Shouldn't this solve it?
for(new row = 0; row < szRows; row++)

That helped actually, I made it print the name of the faction names and it prints both of them, although in-game it only has 1 loaded which is weird since I printed the actual "FactionInfo[szRows][fI_Name]", so IDK how its getting deleted or something and 1 ends up loading again

SuperViper
25/09/2013, 11:33 PM
You store your rows in the rows variable but you loop through [B]szRows[B].

MattSlater
25/09/2013, 11:47 PM
"row" is different to "rows"

szRows is the same as rows

zPain
26/09/2013, 03:19 AM
Change:
FactionInfo[szRows]

for:
FactionInfo[row]

MattSlater
26/09/2013, 02:55 PM
Change:
FactionInfo[szRows]

for:
FactionInfo[row]

Well, I currently have 2 factions in the database.

It only loads the second one, and it loads the second faction into the first slot in-game.

Any idea now?

(PS. Thanks for all help)

MattSlater
26/09/2013, 07:42 PM
Anyone? :(