How to optimize this function? -
liptakrazvan - 01.03.2018
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_tquery( g_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 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;
}
function LoadClanVehicles( ) {
new rows, i;
cache_get_row_count(rows);
for(new i; i < serverClanVehicles; i++) {
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( i );
} printf( "Clan Vehicles: %d", serverClanVehicles );
return true; }
Re: How to optimize this function? -
liptakrazvan - 27.03.2018
UP PLEASE
Re: How to optimize this function? -
ForCop - 27.03.2018
Код:
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;
}
Re: How to optimize this function? -
Sithis - 27.03.2018
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?
Re: How to optimize this function? -
liptakrazvan - 23.04.2018
No, separately, columns from database is another
Re: How to optimize this function? -
UFF - 23.04.2018
Код:
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;
}
Re: How to optimize this function? -
Dayrion - 23.04.2018
Yes, you can.
PHP код:
public LoadBizz()
{
new bussines = cache_num_rows();
for(new i = 1, b; i <= bussines; i++, 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 i; i < serverClanVehicles; i++)
{
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( i );
}
printf( "Clan Vehicles: %d", serverClanVehicles );
return true;
}
I let you make comparisons.