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;
}
pawn Код:
|
for(new i = 0; i < sizeof(szRows); i++)
for (new i = 0; i < szRows; i ++)
You are using "sizeof(szRows)" within the loop. The loop only runs once because using "sizeof" with a non-array variable returns 1, so try changing:
pawn Код:
pawn Код:
|
factionid factionname 12 Corrupt 11 Fire Department 10 Health Department
Loaded faction: Corrupt (12) Loaded faction: Corrupt (11) Loaded faction: Corrupt (10)
Also, are you saying dont use "szRows"? Ive seen so many mysql scripts use them!
|
Then those "many mysql scripts" (link?) are also doing it wrong. There seems to be some misinformation going around the community regarding "sz". I think some just use it to seem professional or profound, without having the slightest idea what it means (no offense to you intended).
|