stock LoadHouses() { new query[256]; mysql_format(g_SQL, query, sizeof(query), "SELECT * FROM `houses` WHERE `HouseStatus` = 1"); mysql_tquery(g_SQL, query, "LoadHousesCb", ""); } public LoadHousesCb() { new rows, fields, string[512]; cache_get_row_count(rows); cache_get_field_count(fields); if(rows) { new temphid, tempowner, tempprice, tempinterior, Float:tempx, Float:tempy, Float:tempz, templock, templevel, tempstatus; for(new x = 0; x < cache_num_rows(); x++) { cache_get_value_name_int(x, "HouseID", temphid); House[houses][HouseID] = temphid; cache_get_value_name(x, "HouseOwner", "tempowner", sizeof(tempowner)); House[houses][HouseOwner] = tempowner; cache_get_value_name_int(x, "HousePrice", tempprice); House[houses][HousePrice] = tempprice; cache_get_value_name_int(x, "HouseInterior", tempinterior); House[houses][HouseInterior] = tempinterior; cache_get_value_name_float(x, "HouseEntranceX", tempx); House[houses][HouseEntranceX] = tempx; cache_get_value_name_float(x, "HouseEntranceY", tempy); House[houses][HouseEntranceY] = tempy; cache_get_value_name_float(x, "HouseEntranceZ", tempz); House[houses][HouseEntranceZ] = tempz; cache_get_value_name_int(x, "isLocked", templock); House[houses][isLocked] = templock; cache_get_value_name_int(x, "HouseLevel", templevel); House[houses][HouseLevel] = templevel; cache_get_value_name_int(x, "HouseStatus", tempstatus); House[houses][HouseStatus] = tempstatus; } houses++; } printf("Loaded %d houses.", houses); }
forward LoadHousesCb( );
public LoadHousesCb( )
{
new rows;
cache_get_row_count( rows );
if( rows )
{
new id, houses;
while( houses < rows )
{
cache_get_value_int( houses, "ID", id );
House[ id ][ HouseID ] = id;
cache_get_value_name( houses, "HouseOwner", House[ id ][ HouseOwner ], .max_len = 48 );
cache_get_value_int( houses, "HousePrice", House[ id ][ HousePrice ] );
cache_get_value_int( houses, "HouseInterior", House[ id ][ HouseInterior ] );
cache_get_value_int( houses, "isLocked", House[ id ][ isLocked ] );
cache_get_value_int( houses, "HouseLevel", House[ id ][ HouseLevel ] );
cache_get_value_int( houses, "HouseStatus", House[ id ][ HouseStatus ] );
cache_get_value_float( houses, "HouseEntranceX", House[ id ][ HouseEntranceX ] );
cache_get_value_float( houses, "HouseEntranceY", House[ id ][ HouseEntranceY ] );
cache_get_value_float( houses, "HouseEntranceZ", House[ id ][ HouseEntranceZ ] );
houses ++;
}
printf( "Loaded %d houses.", houses );
}
return 1;
}
That.. i will never do something like this when i'll want to load something, but that's the way i will do it, that's the way i already do so here is:
PHP код:
|
House[houses][HouseID]=id;
cache_get_value_name(houses, "HouseOwner", House[houses][HouseOwner], .max_Len = 48);
// ...