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++; } } } }
mysql_tquery(mysql, "SELECT * FROM `Table_Name`", "Load_houses", "");
Put
PHP код:
Edit mysql with your connection variable, and the Table_Name with the table inside of your database. |
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(i, "ID");
hInfo[i][hOwned] = cache_get_field_content_int(i, "Owned");
hInfo[i][hPrice] = cache_get_field_content_int(i, "Price");
hInfo[i][hEntranceX] = cache_get_field_content_float(i, "EntranceX");
hInfo[i][hEntranceY] = cache_get_field_content_float(i, "EntranceY");
hInfo[i][hEntranceZ] = cache_get_field_content_float(i, "EntranceZ");
hInfo[i][hExitX] = cache_get_field_content_float(i, "ExitX");
hInfo[i][hExitY] = cache_get_field_content_float(i, "ExitY");
hInfo[i][hExitZ] = cache_get_field_content_float(i, "ExitZ");
hInfo[i][InteriorID] = cache_get_field_content_int(i, "InteriorID");
cache_get_field_content(i, "Pass", hInfo[i][hPass]);
cache_get_field_content(i, "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++;
}
}
}
}
Corrected a small error in your loading code.
PHP код:
|