SQL house system -
TheDarkBlade - 26.09.2016
PHP код:
forward OnHousesLoaded();
public OnHousesLoaded()
{
//Here we check how many results were found after our query. If no results are found, return so that it doesn't execute the other code down below
if(!cache_get_row_count()) return print("No houses were loaded."); //If there are no results, let's print it in the console and log to inform you about it
else
{
new houses = cache_get_row_count(); //If we have results, create a variable that holds the amount of results
printf("%d houses Loaded!",houses);
new PropertyString[250];
for(new i = 0 ; i < houses; i++) //Now loop through the results, and assign the results to their corresponding variables
{
HouseInfo[i][hID] = cache_get_field_content_int(i,"ID");
cache_get_field_content(i,"Owner",HouseInfo[i][hOwner],sql,129);
HouseInfo[i][hPrice] = cache_get_field_content_int(i,"Price");
cache_get_field_content(i,"Name",HouseInfo[i][hDiscription],sql,129);
HouseInfo[i][hInteriorX] = cache_get_field_content_float(i,"InteriorX");
HouseInfo[i][hInteriorY] = cache_get_field_content_float(i,"InteriorY");
HouseInfo[i][hInteriorZ] = cache_get_field_content_float(i,"InteriorZ");
HouseInfo[i][hExteriorX] = cache_get_field_content_float(i,"ExteriorX");
HouseInfo[i][hExteriorY] = cache_get_field_content_float(i,"ExteriorY");
HouseInfo[i][hExteriorZ] = cache_get_field_content_float(i,"ExteriorZ");
HouseInfo[i][hOwned] = cache_get_field_content_int(i,"Owned");
HouseInfo[i][hRentabil] = cache_get_field_content_int(i,"Rentabil");
HouseInfo[i][hRentPrice] = cache_get_field_content_int(i,"RentPrice");
HouseInfo[i][hLevel] = cache_get_field_content_int(i,"Level");
if(HouseInfo[i][hOwned] == 0)
{
Delete3DTextLabel(HouseLabel[i]);
format(PropertyString, sizeof(PropertyString),"{347235}House {FFFFFF}%d \n{347235}Aceasta casa este de vanzare ! \nDescriere: {FFFFFF}%s \n{347235}Pret: {FFFFFF}$%d \n{347235}Level: {FFFFFF}%d \n{347235}to buy this house type /buyhouse",HouseInfo[i][hID],HouseInfo[i][hDiscription],HouseInfo[i][hPrice],HouseInfo[i][hLevel]);
HouseLabel[i] = Create3DTextLabel(PropertyString ,0x09FF00FF,HouseInfo[i][hExteriorX], HouseInfo[i][hExteriorY], HouseInfo[i][hExteriorZ],40,0);
}
else if(HouseInfo[i][hOwned] == 1)
{
if(HouseInfo[i][hRentabil] == 1)
{
Delete3DTextLabel(HouseLabel[i]);
format(PropertyString, sizeof(PropertyString),"{FFFFFF}%s\n {347235}House {FFFFFF}%d \n{347235}Aceasta casa ii apartine lui {FFFFFF}%s \n{347235}Rent: {FFFFFF}$%d \n{347235}Level: {FFFFFF}%d \n{347235}to rent a room type /rentroom",HouseInfo[i][hDiscription],HouseInfo[i][hID],HouseInfo[i][hOwner],HouseInfo[i][hRentPrice],HouseInfo[i][hLevel]);
HouseLabel[i] = Create3DTextLabel(PropertyString ,0x09FF00FF,HouseInfo[i][hExteriorX], HouseInfo[i][hExteriorY], HouseInfo[i][hExteriorZ],40,0);
}
else
{
Delete3DTextLabel(HouseLabel[i]);
format(PropertyString, sizeof(PropertyString),"{FFFFFF}Descriere :%s\n {347235}House {FFFFFF}%d \n{347235}Aceasta casa ii apartine lui {FFFFFF}%s \n{347235}Level: {FFFFFF}%d",HouseInfo[i][hDiscription],HouseInfo[i][hID],HouseInfo[i][hOwner], HouseInfo[i][hLevel]);
HouseLabel[i] = Create3DTextLabel(PropertyString ,0x09FF00FF,HouseInfo[i][hExteriorX], HouseInfo[i][hExteriorY], HouseInfo[i][hExteriorZ],40,0);
}
}
}
} //Now we print in the console how much houses were loaded, letting you know that it worked
return 1; //Always return 1, this way the result is automatically freed I believe
}
Right now i have 3 houses loaded in my database
And for some reason just the last house textdraw is beeing added .
So house 3 has texdraw but house 1 and 2 do not .
Re: SQL house system -
TheDarkBlade - 26.09.2016
Bump
Re: SQL house system -
TheDarkBlade - 26.09.2016
Bump
Re: SQL house system -
Konstantinos - 26.09.2016
I doubt the limit (1024) was reached. After creating the 3D text label, print what it returned:
pawn Код:
HouseLabel[i] = Create3DTextLabel(PropertyString ,0x09FF00FF,HouseInfo[i][hExteriorX], HouseInfo[i][hExteriorY], HouseInfo[i][hExteriorZ],40,0);
printf("3D text label ID: %i", _: HouseLabel[i]);
If the number is not 65535, then the problem is somewhere else. Check where
HouseLabel array is used, perhaps the 3D text label is destroyed somewhere after loading.
Re: SQL house system -
TheDarkBlade - 26.09.2016
it printed
PHP код:
[20:02:55] 3 houses Loaded!
[20:02:55] 3D text label ID: 0
[20:02:55] 3D text label ID: 0
[20:02:55] 3D text label ID: 0
Btw this is my variable for the labels
PHP код:
new Text3D:HouseLabel[sizeof(HouseInfo)];
Re: SQL house system -
jlalt - 26.09.2016
PHP код:
Delete3DTextLabel(HouseLabel[i]);
if I am not worng this HouseLabel[i] var value is always 0 so its removing / deleteing label id 0 try deleting them and see result.
PHP код:
forward OnHousesLoaded();
public OnHousesLoaded()
{
//Here we check how many results were found after our query. If no results are found, return so that it doesn't execute the other code down below
if(!cache_get_row_count()) return print("No houses were loaded."); //If there are no results, let's print it in the console and log to inform you about it
else
{
new houses = cache_get_row_count(); //If we have results, create a variable that holds the amount of results
printf("%d houses Loaded!",houses);
new PropertyString[250];
for(new i = 0 ; i < houses; i++) //Now loop through the results, and assign the results to their corresponding variables
{
HouseInfo[i][hID] = cache_get_field_content_int(i,"ID");
cache_get_field_content(i,"Owner",HouseInfo[i][hOwner],sql,129);
HouseInfo[i][hPrice] = cache_get_field_content_int(i,"Price");
cache_get_field_content(i,"Name",HouseInfo[i][hDiscription],sql,129);
HouseInfo[i][hInteriorX] = cache_get_field_content_float(i,"InteriorX");
HouseInfo[i][hInteriorY] = cache_get_field_content_float(i,"InteriorY");
HouseInfo[i][hInteriorZ] = cache_get_field_content_float(i,"InteriorZ");
HouseInfo[i][hExteriorX] = cache_get_field_content_float(i,"ExteriorX");
HouseInfo[i][hExteriorY] = cache_get_field_content_float(i,"ExteriorY");
HouseInfo[i][hExteriorZ] = cache_get_field_content_float(i,"ExteriorZ");
HouseInfo[i][hOwned] = cache_get_field_content_int(i,"Owned");
HouseInfo[i][hRentabil] = cache_get_field_content_int(i,"Rentabil");
HouseInfo[i][hRentPrice] = cache_get_field_content_int(i,"RentPrice");
HouseInfo[i][hLevel] = cache_get_field_content_int(i,"Level");
if(HouseInfo[i][hOwned] == 0)
{
format(PropertyString, sizeof(PropertyString),"{347235}House {FFFFFF}%d \n{347235}Aceasta casa este de vanzare ! \nDescriere: {FFFFFF}%s \n{347235}Pret: {FFFFFF}$%d \n{347235}Level: {FFFFFF}%d \n{347235}to buy this house type /buyhouse",HouseInfo[i][hID],HouseInfo[i][hDiscription],HouseInfo[i][hPrice],HouseInfo[i][hLevel]);
HouseLabel[i] = Create3DTextLabel(PropertyString ,0x09FF00FF,HouseInfo[i][hExteriorX], HouseInfo[i][hExteriorY], HouseInfo[i][hExteriorZ],40,0);
}
else if(HouseInfo[i][hOwned] == 1)
{
if(HouseInfo[i][hRentabil] == 1)
{
format(PropertyString, sizeof(PropertyString),"{FFFFFF}%s\n {347235}House {FFFFFF}%d \n{347235}Aceasta casa ii apartine lui {FFFFFF}%s \n{347235}Rent: {FFFFFF}$%d \n{347235}Level: {FFFFFF}%d \n{347235}to rent a room type /rentroom",HouseInfo[i][hDiscription],HouseInfo[i][hID],HouseInfo[i][hOwner],HouseInfo[i][hRentPrice],HouseInfo[i][hLevel]);
HouseLabel[i] = Create3DTextLabel(PropertyString ,0x09FF00FF,HouseInfo[i][hExteriorX], HouseInfo[i][hExteriorY], HouseInfo[i][hExteriorZ],40,0);
}
else
{
format(PropertyString, sizeof(PropertyString),"{FFFFFF}Descriere :%s\n {347235}House {FFFFFF}%d \n{347235}Aceasta casa ii apartine lui {FFFFFF}%s \n{347235}Level: {FFFFFF}%d",HouseInfo[i][hDiscription],HouseInfo[i][hID],HouseInfo[i][hOwner], HouseInfo[i][hLevel]);
HouseLabel[i] = Create3DTextLabel(PropertyString ,0x09FF00FF,HouseInfo[i][hExteriorX], HouseInfo[i][hExteriorY], HouseInfo[i][hExteriorZ],40,0);
}
}
}
} //Now we print in the console how much houses were loaded, letting you know that it worked
return 1; //Always return 1, this way the result is automatically freed I believe
}
Re: SQL house system -
Konstantinos - 26.09.2016
jlalt is correct. You should always reset with an invalid value to avoid removing valid things.
pawn Код:
new Text3D:HouseLabel[sizeof(HouseInfo)] = {Text3D:INVALID_3DTEXT_ID, ...};