04.02.2016, 05:41
Hello, I've made a function "public" to load the houses in my "houses" mysql table, but I've put the function OnGameModeInit, and no thing was loaded.
Can someone tell me how to load them and where to put this function.
This the script:
Can someone tell me how to load them and where to put this function.
This the script:
Код:
forward Load_houses(); public Load_houses() { new rows, fields; cache_get_data(rows, fields, mysql); if(rows == 0) { printf("No houses were found in the database."); } else { for(new i = 0; i < rows; i++) { if(rows <= MAX_HOUSES) { hInfo[i][hID] = cache_get_field_content_int(0, "ID"); hInfo[i][hOwned] = cache_get_field_content_int(0, "Owned"); hInfo[i][hPrice] = cache_get_field_content_int(0, "Price"); hInfo[i][hEntranceX] = cache_get_field_content_float(0, "EntranceX"); hInfo[i][hEntranceY] = cache_get_field_content_float(0, "EntranceY"); hInfo[i][hEntranceZ] = cache_get_field_content_float(0, "EntranceZ"); hInfo[i][hExitX] = cache_get_field_content_float(0, "ExitX"); hInfo[i][hExitY] = cache_get_field_content_float(0, "ExitY"); hInfo[i][hExitZ] = cache_get_field_content_float(0, "ExitZ"); hInfo[i][InteriorID] = cache_get_field_content_int(0, "InteriorID"); cache_get_field_content(0, "Pass", hInfo[i][hPass]); cache_get_field_content(0, "Owner", hInfo[i][hOwner]); hInfo[i][EntranceCP] = CreateDynamicCP(hInfo[i][hEntranceX], hInfo[i][hEntranceY], hInfo[i][hEntranceZ], 1.5, -1, -1, -1, 50.0); hInfo[i][ExitCP] = CreateDynamicCP(hInfo[i][hExitX], hInfo[i][hExitY], hInfo[i][hExitZ], 1.5, hInfo[i][hID], hInfo[i][InteriorID], -1, 100.0); new labelstring[200]; switch(hInfo[i][hOwned]) { case 0: { format(labelstring, sizeof(labelstring), "{FFFFFF}Home(%d)\n"COL_GOLD"Owner:{FFFFFF} No-one\n"COL_GOLD"Price:{FFFFFF} %s", hInfo[i][hID], AC(hInfo[i][hPrice])); hInfo[i][HouseLabel] = CreateDynamic3DTextLabel(labelstring, COLOR_WHITE, hInfo[i][hEntranceX], hInfo[i][hEntranceY], hInfo[i][hEntranceZ], 35.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 35.0); } case 1: { format(labelstring, sizeof(labelstring), "{FFFFFF}Home(%d)\n"COL_GOLD"Owner:{FFFFFF} %s\n"COL_GOLD"Price:{FFFFFF} %s", hInfo[i][hID], hInfo[i][hOwner], AC(hInfo[i][hPrice])); hInfo[i][HouseLabel] = CreateDynamic3DTextLabel(labelstring, COLOR_WHITE, hInfo[i][hEntranceX], hInfo[i][hEntranceY], hInfo[i][hEntranceZ], 35.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 35.0); } } hInfo[i][ExitLabel] = CreateDynamic3DTextLabel("[EXIT]", COLOR_WHITE, hInfo[i][hExitX], hInfo[i][hExitY], hInfo[i][hExitZ], 35.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, hInfo[i][hID], -1, -1, 35.0); LoadedHouses++; } } } }