How to optimize this function?
#1

Hi, this is my first post here well I found you, I went from R39-6 to R41-4
I have a problem as well as I do not know how to optimize these functions, if you help me to stay satisfied, I'm sorry for my bad English.

PHP код:
/////////// This is in OnGameModeInit
    
mysql_tqueryg_SQL"SELECT * FROM `clanVehicles` ORDER BY `clanVehicleID` ASC""LoadClanVehicles""" );
    
mysql_tquery(g_SQL"SELECT * FROM `bizz`""LoadBizz""");
////////////
public LoadBizz()  
{
    new 
PropertyString[256],locked[20];
    
bussines cache_num_rows();
    for(new 
1<= bussinesi++)
    {
        new 
1;
        
cache_get_value_int(b"ID"BizzInfo[i][bID]);
        
cache_get_value_int(b"Owned"BizzInfo[i][bOwned]);
        
cache_get_value_name(b"Owner"BizzInfo[i][bOwner], 130);
        }
    
printf("[LOADING] %d businesses loaded."bussines);
    return 
true;
}
function 
LoadClanVehicles( ) {
        new 
rowsi;
        
cache_get_row_count(rows);
        for(new 
iserverClanVehiclesi++) {
        
cache_get_value_int(i"clanVehicleID"clanVehiclesVariables[i][clanVehicleID]);
        
cache_get_value_int(i"clanVehicleClan"clanVehiclesVariables[i][clanVehicleClan]);
        
cache_get_value_int(i"clanVehicleRank"clanVehiclesVariables[i][clanVehicleRank]);
        
cache_get_value_int(i"clanVehicleModel"clanVehiclesVariables[i][clanVehicleModel]);
        
cache_get_value_int(i"clanVehicleColor1"clanVehiclesVariables[i][clanVehicleColor1]);
        
cache_get_value_int(i"clanVehicleColor2"clanVehiclesVariables[i][clanVehicleColor2]);
        
cache_get_value_float(i"clanVehicleX"clanVehiclesVariables[i][clanVehicleX]);
        
cache_get_value_float(i"clanVehicleY"clanVehiclesVariables[i][clanVehicleY]);
        
cache_get_value_float(i"clanVehicleZ"clanVehiclesVariables[i][clanVehicleZ]);
        
cache_get_value_float(i"clanVehicleA"clanVehiclesVariables[i][clanVehicleA]);
        
createClanVehicle);
    } 
printf"Clan Vehicles: %d"serverClanVehicles );
    return 
true; } 
Reply
#2

UP PLEASE
Reply
#3

Код:
public LoadBizz()   
{ 
    new PropertyString[256],locked[20]; //not used
    new bussines = cache_num_rows(); // add "new"
    for(new i = 1; i <= bussines; i++) 
    { 
        new b = i - 1; 
        cache_get_value_int(b, "ID", BizzInfo[i][bID]); 
        cache_get_value_int(b, "Owned", BizzInfo[i][bOwned]); 
        cache_get_value_name(b, "Owner", BizzInfo[i][bOwner], 130); 
        } 
    printf("[LOADING] %d businesses loaded.", bussines); 
    return true; 
}
Reply
#4

Mind showing us your table structure?

Do you need every vehicle and business to be loaded every time? Do you need all the columns or only specific ones?
Reply
#5

No, separately, columns from database is another
Reply
#6

Код:
public LoadBizz()   
{ 
    new rows = cache_num_rows();
  if(rows)
  {
    new id;
    for(new i; i < rows; ++i) 
    { 
        id = cache_get_field_content_int(i, "ID");
        cache_get_field_content(i, "Owned", BizzInfo[id][bOwned], .max_len = MAX_BUSINESS_NAME); 
        cache_get_field_content(i, "Owner", BizzInfo[id][bOwner], 130); 
     } 
    printf("[LOADING] %d businesses loaded.", rows);
  } 
    return true; 
}
Reply
#7

Yes, you can.
PHP код:
public LoadBizz()   

    new 
bussines cache_num_rows(); 
    for(new 
1b<= bussinesi++, b++) 
    { 
        
cache_get_value_int(b"ID"BizzInfo[i][bID]); 
        
cache_get_value_int(b"Owned"BizzInfo[i][bOwned]); 
        
cache_get_value_name(b"Owner"BizzInfo[i][bOwner], 130); 
    } 
    
printf("[LOADING] %d businesses loaded."bussines); 
    return 
true

PHP код:
function LoadClanVehicles( )

    new 
rows;
    
cache_get_row_count(rows); 
    for(new 
iserverClanVehiclesi++)
    { 
        
cache_get_value_int(i"clanVehicleID"clanVehiclesVariables[i][clanVehicleID]); 
        
cache_get_value_int(i"clanVehicleClan"clanVehiclesVariables[i][clanVehicleClan]); 
        
cache_get_value_int(i"clanVehicleRank"clanVehiclesVariables[i][clanVehicleRank]); 
        
cache_get_value_int(i"clanVehicleModel"clanVehiclesVariables[i][clanVehicleModel]); 
        
cache_get_value_int(i"clanVehicleColor1"clanVehiclesVariables[i][clanVehicleColor1]); 
        
cache_get_value_int(i"clanVehicleColor2"clanVehiclesVariables[i][clanVehicleColor2]); 
        
cache_get_value_float(i"clanVehicleX"clanVehiclesVariables[i][clanVehicleX]); 
        
cache_get_value_float(i"clanVehicleY"clanVehiclesVariables[i][clanVehicleY]); 
        
cache_get_value_float(i"clanVehicleZ"clanVehiclesVariables[i][clanVehicleZ]); 
        
cache_get_value_float(i"clanVehicleA"clanVehiclesVariables[i][clanVehicleA]); 
        
createClanVehicle); 
    }
    
printf"Clan Vehicles: %d"serverClanVehicles ); 
    return 
true;

I let you make comparisons.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)