27.12.2016, 06:52
MySQL factions database has 5 rows but where it says [] theres supposed to be text there for each one.
for example Row 2-5 is "Empty" but Row 1 is "LSPD".
here is how the factions are being loaded below
Seems like the loop is working as intended for the factions thats about it I believe, as its not really loading from my database, although from looking at the code it should be, since ongamemodeinit ive got it running through LoadFactions();
for example Row 2-5 is "Empty" but Row 1 is "LSPD".
Code:
[20:38:29] Factions MySQL Database Loading... [20:38:29] Loading Rows from Factions (Row 1) [] [20:38:30] Loading Rows from Factions (Row 2) [] [20:38:30] Loading Rows from Factions (Row 3) [] [20:38:30] Loading Rows from Factions (Row 4) [] [20:38:30] Loading Rows from Factions (Row 5) [] [20:38:30] Loaded 5 Rows from Factions MySQL Database
pawn Code:
enum E_FACTIONS
{
ID,
Name,
Empty,
Cache: Cache_ID
};
new Factions[MAX_FACTIONS][E_FACTIONS];
public LoadFactions()
{
new loadquery[512], count, EMPTY;
printf("Factions MySQL Database Loading...");
for(new i = 1; i < MAX_FACTIONS; i++)
{
mysql_format(g_SQL, loadquery, sizeof loadquery, "SELECT * FROM `factions` WHERE `id` = '%d' LIMIT 1", Factions[i][ID]);
mysql_tquery(g_SQL, loadquery, "OnFactionsLoaded", "d", i);
Factions[i][ID] = i;
if(Factions[i][ID] == -1 || Factions[i][ID] == EMPTY)
{
printf("ERROR Loading Data from Factions (Row %i) MySQL Database", Factions[i][ID]);
}
if(Factions[i][Empty] == 1)
{
//format(EmptyString, sizeof(EmptyString),"Empty");
//printf("(Row %i) [%s]",Factions[i][ID], EmptyString);
}
else if(Factions[i][Empty] == 0)
{
i = Factions[i][ID];
printf("Loading Rows from Factions (Row %i) [%s]",Factions[i][ID], Factions[i][Name]);
}
count = count +1;
}
printf("Loaded %i Rows from Factions MySQL Database", count);
return 1;
}
public OnFactionsLoaded(i)
{
if(cache_num_rows() > 0)
{
cache_get_value(0, "id", Factions[i][ID], 2);
cache_get_value(0, "name", Factions[i][Name], 18);
cache_get_value(0, "empty", Factions[i][Empty], 1);
Factions[i][Cache_ID] = cache_save();
}
else
{
//no rows
}
return 1;
}