forward LoadHouses(); public LoadHouses() { new PlayerName1[MAX_PLAYER_NAME], str[500]; for(new id=1; id<sizeof(HouseInfo); id++) { HouseInfo[id][ID]= cache_get_field_content_int(dbhandle, "ID"); HouseInfo[id][Owner] = cache_get_field_content(id, "Owner", PlayerName1, dbhandle); strmid(HouseInfo[id][Owner], PlayerName1, 0, sizeof(PlayerName1), sizeof(PlayerName1)); HouseInfo[id][HouseX]= cache_get_field_content_float(dbhandle, "HX"); HouseInfo[id][HouseY]= cache_get_field_content_float(dbhandle, "HY"); HouseInfo[id][HouseZ]= cache_get_field_content_float(dbhandle, "HZ"); HouseInfo[id][HouseXX]= cache_get_field_content_float(dbhandle, "HouseXX"); HouseInfo[id][HouseYY]= cache_get_field_content_float(dbhandle, "HouseYY"); HouseInfo[id][HouseZZ]= cache_get_field_content_float(dbhandle, "HouseZZ"); HouseInfo[id][World]= cache_get_field_content_int(dbhandle, "World"); HouseInfo[id][Price]= cache_get_field_content_int(dbhandle, "Price"); HouseInfo[id][ForSale]= cache_get_field_content_int(dbhandle, "ForSale"); if(HouseInfo[id][ForSale] == 1) { HouseInfo[id][Pickup] = AddStaticPickup(1273, 23, HouseInfo[id][HouseX], HouseInfo[id][HouseY], HouseInfo[id][HouseZ], HouseInfo[id][World]); format(str, sizeof(str), "House\nPrice: %d\nType /buyhouse to purchase it\nType /enter to go inside", HouseInfo[id][Price]); HouseTxt[id]=CreateDynamic3DTextLabel(str ,COLOR_ORANGE, HouseInfo[id][HouseX], HouseInfo[id][HouseY], HouseInfo[id][HouseZ],30.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 7.0); return 1; } if(HouseInfo[id][ForSale] == 0) { HouseInfo[id][Pickup] = AddStaticPickup(1273, 23, HouseInfo[id][HouseX], HouseInfo[id][HouseY], HouseInfo[id][HouseZ], HouseInfo[id][World]); format(str, sizeof(str), "House\nOwner: %s\nType /enter to go inside", HouseInfo[id][Owner]); HouseTxt[id]=CreateDynamic3DTextLabel(str ,COLOR_ORANGE, HouseInfo[id][HouseX], HouseInfo[id][HouseY], HouseInfo[id][HouseZ],30.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 7.0); return 1; } } return 1; }
for(new id=0, rows = cache_get_row_count(); id<rows; id++)
{
HouseInfo[id][ID]= cache_get_field_content_int(id, "ID", dbhandle);
cache_get_field_content(id, "Owner", HouseInfo[id][Owner], dbhandle, MAX_PLAYER_NAME);
HouseInfo[id][HouseX]= cache_get_field_content_float(id, "HX", dbhandle);
...
}
https://sampwiki.blast.hk/wiki/MySQL/R3..._field_content
https://sampwiki.blast.hk/wiki/MySQL/R3...ld_content_int https://sampwiki.blast.hk/wiki/MySQL/R3..._content_float First parameter is row, not connection handle. The loop is wrong, it must start from index 0 until rows-1 otherwise you are trying to retrieve data from an invalid row. Strings are passed by reference, the function does not return any specific value. You will need to use the length parameter when using enum-arrays. pawn Код:
|
forward LoadHouses(); public LoadHouses() { new PlayerName1[MAX_PLAYER_NAME], str[500]; //for(new id=1; id<sizeof(HouseInfo); id++) for(new id=0, rows = cache_get_row_count(); id<rows; id++) { HouseInfo[id][ID]= cache_get_field_content_int(id, "ID", dbhandle); cache_get_field_content(id, "Owner", HouseInfo[id][Owner], dbhandle, MAX_PLAYER_NAME); HouseInfo[id][HouseX]= cache_get_field_content_float(id, "HX", dbhandle); HouseInfo[id][HouseY]= cache_get_field_content_float(id, "HY", dbhandle); HouseInfo[id][HouseZ]= cache_get_field_content_float(id, "HZ", dbhandle); HouseInfo[id][HouseXX]= cache_get_field_content_float(id, "HouseXX", dbhandle); HouseInfo[id][HouseYY]= cache_get_field_content_float(id, "HouseYY", dbhandle); HouseInfo[id][HouseZZ]= cache_get_field_content_float(id, "HouseZZ", dbhandle); HouseInfo[id][World]= cache_get_field_content_int(id, "HWorld", dbhandle); HouseInfo[id][Price]= cache_get_field_content_int(id, "Price", dbhandle); HouseInfo[id][ForSale]= cache_get_field_content_int(id, "ForSale", dbhandle); /* HouseInfo[id][ID]= cache_get_field_content_int(dbhandle, "ID"); HouseInfo[id][Owner] = cache_get_field_content(id, "Owner", PlayerName1, dbhandle); strmid(HouseInfo[id][Owner], PlayerName1, 0, sizeof(PlayerName1), sizeof(PlayerName1)); HouseInfo[id][HouseX]= cache_get_field_content_float(dbhandle, "HX"); HouseInfo[id][HouseY]= cache_get_field_content_float(dbhandle, "HY"); HouseInfo[id][HouseZ]= cache_get_field_content_float(dbhandle, "HZ"); HouseInfo[id][HouseXX]= cache_get_field_content_float(dbhandle, "HouseXX"); HouseInfo[id][HouseYY]= cache_get_field_content_float(dbhandle, "HouseYY"); HouseInfo[id][HouseZZ]= cache_get_field_content_float(dbhandle, "HouseZZ"); HouseInfo[id][World]= cache_get_field_content_int(dbhandle, "HWorld"); HouseInfo[id][Price]= cache_get_field_content_int(dbhandle, "Price"); HouseInfo[id][ForSale]= cache_get_field_content_int(dbhandle, "ForSale");*/ if(HouseInfo[id][ForSale] == 1) { HouseInfo[id][Pickup] = AddStaticPickup(1273, 23, HouseInfo[id][HouseX], HouseInfo[id][HouseY], HouseInfo[id][HouseZ], HouseInfo[id][World]); format(str, sizeof(str), "House\nPrice: %d\nType /buyhouse to purchase it\nType /enter to go inside", HouseInfo[id][Price]); HouseTxt[id]=CreateDynamic3DTextLabel(str ,COLOR_ORANGE, HouseInfo[id][HouseX], HouseInfo[id][HouseY], HouseInfo[id][HouseZ],30.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 7.0); return 1; } if(HouseInfo[id][ForSale] == 0) { HouseInfo[id][Pickup] = AddStaticPickup(1273, 23, HouseInfo[id][HouseX], HouseInfo[id][HouseY], HouseInfo[id][HouseZ], HouseInfo[id][World]); format(str, sizeof(str), "House\nOwner: %s\nType /enter to go inside", HouseInfo[id][Owner]); HouseTxt[id]=CreateDynamic3DTextLabel(str ,COLOR_ORANGE, HouseInfo[id][HouseX], HouseInfo[id][HouseY], HouseInfo[id][HouseZ],30.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 7.0); return 1; } return 1; } return 1; }
Remove return 1; from the two if statements and at the end of the loop.
|