FUNKCIJA:OnLoadBizzFurnitures( )
{
new content[ 512 ],
rows,
i = 0,
id,
count = GetTickCount(),
furnitureTexture1[30],
furnitureTexture2[30],
furnitureTexture3[30],
furnitureTexture4[30],
furnitureTexture5[30],
furnitureNon[] = "-1|-1|-1";
mysql_query( "SELECT * FROM `bfurniture`" );
mysql_store_result( );
rows = mysql_num_rows();
if ( rows )
{
while( mysql_retrieve_row() )
{
mysql_get_field("Id", content);
id = strval( content );
BizzFurniture[ id ][ fId ] = id;
mysql_get_field("ObjectId", content );
BizzFurniture[ id ][ fObjectId ] = strval( content );
mysql_get_field("BizId", content );
BizzFurniture[ id ][ fHouseId ] = strval( content );
mysql_get_field("TxdId0", furnitureTexture1 );
mysql_get_field("TxdId1", furnitureTexture2 );
mysql_get_field("TxdId2", furnitureTexture3 );
mysql_get_field("TxdId3", furnitureTexture4 );
mysql_get_field("TxdId4", furnitureTexture5 );
mysql_get_field("Name", BizzFurniture[ id ][ fName ] );
mysql_get_field("Pos_X", content);
BizzFurniture[ id ][ fPos ][ 0 ] = floatstr( content );
mysql_get_field("Pos_Y", content);
BizzFurniture[ id ][ fPos ][ 1 ] = floatstr( content );
mysql_get_field("Pos_Z", content);
BizzFurniture[ id ][ fPos ][ 2 ] = floatstr( content );
mysql_get_field("Pos_RX", content);
BizzFurniture[ id ][ frPos ][ 0 ] = floatstr( content );
mysql_get_field("Pos_RY", content);
BizzFurniture[ id ][ frPos ][ 1 ] = floatstr( content );
mysql_get_field("Pos_RZ", content);
BizzFurniture[ id ][ frPos ][ 2 ] = floatstr( content );
mysql_get_field("Price", content);
BizzFurniture[ id ][ fPrice ] = strval( content );
foreach(Biznes,b)
{
if( BizzFurniture[ id ][ fHouseId ] == bInfo[ b ][ bID ] )
{
bfObject[ id ] = CreateDynamicObject( BizzFurniture[ id ][ fObjectId ],
BizzFurniture[ id ][ fPos ][ 0 ], BizzFurniture[ id ][ fPos ][ 1 ], BizzFurniture[ id ][ fPos ][ 2 ],
BizzFurniture[ id ][ frPos ][ 0 ], BizzFurniture[ id ][ frPos ][ 1 ], BizzFurniture[ id ][ frPos ][ 2 ],
BUSINESS_VIRTUAL_WORLD+b );
break;
}
}
if( strcmp(furnitureTexture1, furnitureNon, false) )
{
new firstID, firstTexture[20], secondTexture[20], oObject, oTxdName[ 18 ], oTextureName[ 18 ], foColour;
sscanf(furnitureTexture1, "p<|>ds[20]s[20]", firstID, firstTexture, secondTexture);
GetDynamicObjectMaterial( bfObject[ id ], 0,
oObject, oTxdName, oTextureName, foColour );
SetDynamicObjectMaterial(bfObject[ id ], 0,
firstID,
firstTexture,
secondTexture,
foColour );
}
if( strcmp(furnitureTexture2, furnitureNon, false) )
{
new firstID, firstTexture[20], secondTexture[20], oObject, oTxdName[ 18 ], oTextureName[ 18 ], foColour;
sscanf(furnitureTexture2, "p<|>ds[20]s[20]", firstID, firstTexture, secondTexture);
GetDynamicObjectMaterial( bfObject[ id ], 1,
oObject, oTxdName, oTextureName, foColour );
SetDynamicObjectMaterial(bfObject[ id ], 1,
firstID,
firstTexture,
secondTexture,
foColour );
}
if( strcmp(furnitureTexture3, furnitureNon, false) )
{
new firstID, firstTexture[20], secondTexture[20], oObject, oTxdName[ 18 ], oTextureName[ 18 ], foColour;
sscanf(furnitureTexture3, "p<|>ds[20]s[20]", firstID, firstTexture, secondTexture);
GetDynamicObjectMaterial( bfObject[ id ], 2,
oObject, oTxdName, oTextureName, foColour );
SetDynamicObjectMaterial(bfObject[ id ], 2,
firstID,
firstTexture,
secondTexture,
foColour );
}
if( strcmp(furnitureTexture4, furnitureNon, false) )
{
new firstID, firstTexture[20], secondTexture[20], oObject, oTxdName[ 18 ], oTextureName[ 18 ], foColour;
sscanf(furnitureTexture4, "p<|>ds[20]s[20]", firstID, firstTexture, secondTexture);
GetDynamicObjectMaterial( bfObject[ id ], 3,
oObject, oTxdName, oTextureName, foColour );
SetDynamicObjectMaterial(bfObject[ id ], 3,
firstID,
firstTexture,
secondTexture,
foColour );
}
if( strcmp(furnitureTexture5, furnitureNon, false) )
{
new firstID, firstTexture[20], secondTexture[20], oObject, oTxdName[ 18 ], oTextureName[ 18 ], foColour;
sscanf(furnitureTexture5, "p<|>ds[20]s[20]", firstID, firstTexture, secondTexture);
GetDynamicObjectMaterial( bfObject[ id ], 4,
oObject, oTxdName, oTextureName, foColour );
SetDynamicObjectMaterial(bfObject[ id ], 4,
firstID,
firstTexture,
secondTexture,
foColour );
}
i++;
}
}
printf("[BIZNIO BALDAI] Бkrauta %d baldш per %d ms", i, GetTickCount() - count );
}
mysql_get_field("Id", content);
id = strval( content );
BizzFurniture[ id ][ fId ] = id;
mysql_get_field("ObjectId", content );
BizzFurniture[ id ][ fObjectId ] = strval( content );
id = cache_get_field_content_int(content, "Id"); BizzFurniture[ id ][ fId ] = id; BizzFurniture[ id ][ fObjectId ] = cache_get_field_content_int(content, "ObjectId");
FUNKCIJA:OnLoadBizzFurnitures( )
return mysql_tquery(gSQLConnection, "SELECT * FROM bfurniture", "OnLoadBizFurniture", "");
forward OnLoadBizFurniture();
public OnLoadBizFurniture()
{
new
// define everything
if(cache_num_rows())
{
for(new i; i <= cache_num_rows(); i++)
{
// for strings
cache_get_field_content(i, "Id", content);
// for integers
BizzFurniture[ id ][ fObjectId ] = cache_get_field_content_int(i, "ObjectId");
}
}
printf("... print");
return true;
}
|
You should use threaded queries, however they're handled differently. They use callbacks, however you can also save cache for later use outside of it with cache_save, cache_set_active, cache_is_valid, etc.
pawn Код:
|
rezultatas = mysql_query(Handle, "SELECT * FROM `bfurniture`");
rows = cache_num_rows();
if ( rows )
{
while(cache_get_row_count(Handle))
{