07.07.2014, 05:11
So I have this loop inside my query function, after loading the first set of data, it stops. Instead of looping through until it reaches the end of szRows.
The print is printing 3 szRows, but it only loads row 0 and then stops completely, instead of loading the next two.
pawn Код:
stock LoadFactions()
{
format(szQuery, sizeof(szQuery), "SELECT * FROM `factions`");
mysql_tquery(Mysql_factions, szQuery, "Run_query", "d", RESULT_FACTIONS);
return 1;
}
forward Run_query(resultid, extraid, ConnectionHandle);
public Run_query(resultid, extraid, ConnectionHandle)
{
new szRows, szFields;
if(resultid != 0)
{
cache_get_data(szRows, szFields);
}
switch(resultid)
{
case RESULT_FACTIONS:
{
if(szRows)
{
for(new i = 0; i < sizeof(szRows); i++)
{
new factionID;
factionID = cache_get_field_content_int(i, "FactionID", Mysql_factions);
printf("%d", szRows);
FactionData[factionID][Created] = cache_get_field_content_int(0, "Created", Mysql_factions);
cache_get_field_content(0, "FactionName", FactionData[factionID][FactionName], Mysql_factions, 126);
FactionData[factionID][FactionType] = cache_get_field_content_int(0, "FactionType", Mysql_factions);
FactionData[factionID][hqX] = cache_get_field_content_float(0, "hqX", Mysql_factions);
FactionData[factionID][hqY] = cache_get_field_content_float(0, "hqY", Mysql_factions);
FactionData[factionID][hqZ] = cache_get_field_content_float(0, "hqZ", Mysql_factions);
FactionData[factionID][hqInterior] = cache_get_field_content_int(0, "hqInterior", Mysql_factions);
FactionData[factionID][hqWorld] = i;
FactionData[factionID][lockerX] = cache_get_field_content_float(0, "lockerX", Mysql_factions);
FactionData[factionID][lockerY] = cache_get_field_content_float(0, "lockerY", Mysql_factions);
FactionData[factionID][lockerZ] = cache_get_field_content_float(0, "lockerZ", Mysql_factions);
FactionData[factionID][lockerInterior] = cache_get_field_content_int(0, "lockerInterior", Mysql_factions);
FactionData[factionID][lockerWorld] = i;
cache_get_field_content(0, "Rank1", FactionData[factionID][Rank1], Mysql_factions, 126);
cache_get_field_content(0, "Rank2", FactionData[factionID][Rank2], Mysql_factions, 126);
cache_get_field_content(0, "Rank3", FactionData[factionID][Rank3], Mysql_factions, 126);
cache_get_field_content(0, "Rank4", FactionData[factionID][Rank4], Mysql_factions, 126);
cache_get_field_content(0, "Rank5", FactionData[factionID][Rank5], Mysql_factions, 126);
cache_get_field_content(0, "Rank6", FactionData[factionID][Rank6], Mysql_factions, 126);
cache_get_field_content(0, "Division1", FactionData[factionID][Division1], Mysql_factions, 126);
cache_get_field_content(0, "Division2", FactionData[factionID][Division2], Mysql_factions, 126);
cache_get_field_content(0, "Division3", FactionData[factionID][Division3], Mysql_factions, 126);
cache_get_field_content(0, "Division4", FactionData[factionID][Division4], Mysql_factions, 126);
cache_get_field_content(0, "Division5", FactionData[factionID][Division5], Mysql_factions, 126);
cache_get_field_content(0, "Division6", FactionData[factionID][Division6], Mysql_factions, 126);
printf("Loaded faction: %s (%d)", FactionData[factionID][FactionName], factionID);
}
}
}
}
return 1;
}