21.01.2019, 14:57
Code:
public LoadHouses() { new str[250]; new query[1000]; new rows = cache_get_row_count(dbhandle); for(new i = 0; i < rows && i < MAX_HOUSES; i ++) { DestroyPickup(HouseInfo[i][hPickup]); DestroyDynamic3DTextLabel(HouseInfo[i][hLabel]); cache_get_field_content(i, "Owner", HouseInfo[i][hOwner], dbhandle, MAX_PLAYER_NAME); HouseInfo[i][hID] = cache_get_field_content_int(i, "ID", dbhandle); HouseInfo[i][hOutPos][0] = cache_get_field_content_float(i, "Out_X", dbhandle); HouseInfo[i][hOutPos][1] = cache_get_field_content_float(i, "Out_Y", dbhandle); HouseInfo[i][hOutPos][2] = cache_get_field_content_float(i, "Out_Z", dbhandle); HouseInfo[i][hIntPos][0] = cache_get_field_content_float(i, "Int_X", dbhandle); HouseInfo[i][hIntPos][1] = cache_get_field_content_float(i, "Int_Y", dbhandle); HouseInfo[i][hIntPos][2] = cache_get_field_content_float(i, "Int_Z", dbhandle); HouseInfo[i][hOutInterior] = cache_get_field_content_int(i, "OutInt", dbhandle); HouseInfo[i][hOutWorld] = cache_get_field_content_int(i, "OutWorld", dbhandle); HouseInfo[i][hInsideInterior] = cache_get_field_content_int(i, "InsideInt", dbhandle); HouseInfo[i][hInsideWorld] = cache_get_field_content_int(i, "InsideWorld", dbhandle); HouseInfo[i][hLocked] = cache_get_field_content_int(i, "Locked", dbhandle); HouseInfo[i][hForSell] = cache_get_field_content_int(i, "ForSell", dbhandle); HouseInfo[i][hPrice] = cache_get_field_content_int(i, "Price", dbhandle); if(HouseInfo[i][hForSell] == 1) { HouseInfo[i][hPickup] = CreatePickup(1273, 23, HouseInfo[i][hOutPos][0], HouseInfo[i][hOutPos][1], HouseInfo[i][hOutPos][2], -1); format(str, sizeof(str), "This house is for sell!\nPrice: %d\nType /buyhouse to buy it.\nType /enter to go inside.", HouseInfo[i][hPrice]); HouseInfo[i][hLabel] = CreateDynamic3DTextLabel(str ,COLOR_ORANGE, HouseInfo[i][hOutPos][0], HouseInfo[i][hOutPos][1], HouseInfo[i][hOutPos][2],30.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 7.0); } else { HouseInfo[i][hPickup] = CreatePickup(1273, 23, HouseInfo[i][hOutPos][0], HouseInfo[i][hOutPos][1], HouseInfo[i][hOutPos][2], -1); format(str, sizeof(str), "House\nOwner: %s\nTo enter inside type /enter.", HouseInfo[i][hOwner]); HouseInfo[i][hLabel] = CreateDynamic3DTextLabel(str ,COLOR_ORANGE, HouseInfo[i][hOutPos][0], HouseInfo[i][hOutPos][1], HouseInfo[i][hOutPos][2],30.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 7.0); } printf("%d houses loaded.", rows); } return 1; }