Not looping through all factions in database.
#1

So I have tried to set it up so it gathers all the information from the table factions. It is meant to create a little 'i' icon for the player in the game at the x y z of the factions. The function "LoadFactions" is called ongamemodeinit, and then successfully calls the net function. Only one symbol is created in the game for one of the factions and not for the second, ect ect.

PHP Code:
forward LoadFactions();
public 
LoadFactions()
{
    new 
DB_Query[900];
    
mysql_format(DatabaseDB_Querysizeof(DB_Query), "SELECT * FROM `factions`");
    
mysql_tquery(DatabaseDB_Query"FactionsRecieved");
    print(
DB_Query);
}
forward FactionsRecieved();
public 
FactionsRecieved()
{
    if(
cache_num_rows() == 0) print("No factions have been made");
    else
    {
         for(new 
0cache_num_rows(); i++)
        {
            
//cache_get_value_int(0, "fID", factionInfo[fID][fID]);
            
cache_get_value(0"facName"factionInfo[fID][facName],32);
            
cache_get_value_name_float(0"facX"factionInfo[fID][facX]);
            
cache_get_value_name_float(0"facY"factionInfo[fID][facY]);
            
cache_get_value_name_float(0"facZ"factionInfo[fID][facZ]);
            
CreateDynamicPickup(12391factionInfo[fID][facX], factionInfo[fID][facY], factionInfo[fID][facZ], 00);
        }
          
printf("[INFO]: Loaded %d groups from the database."cache_num_rows());
    }
    return 
true;

Reply
#2

pawn Code:
cache_get_value(0, ..
cache_get_value_name_float(0,
first parameter is rowid and you only retrieve from first row. Replace 0 with i.

You also commented out a line but you use fID as array index. Never rely on that, it's only a way to identify an iten IN database so use i there instead.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)