SA-MP Forums Archive
House loading with mysql. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: House loading with mysql. (/showthread.php?tid=290544)



House loading with mysql. - budelis - 16.10.2011

Hello peoples.I need some help with my house system. I want to load my house,but i don't know how to start.Maybe somebody can give me a little code how need start?


Re: House loading with mysql. - TheLazySloth - 16.10.2011

https://sampforum.blast.hk/showthread.php?tid=159785


Re: House loading with mysql. - budelis - 16.10.2011

I not need a mysql,i talk about house load with mysql...


Re: House loading with mysql. - TheLazySloth - 16.10.2011

Then you need to understand how MySQL works...
https://sampforum.blast.hk/showthread.php?tid=159785
Is a great guide on how to make a MySQL system.


Re: House loading with mysql. - budelis - 16.10.2011

I know how works mysql,but i don't know how to do it ...

Код:
for(new house=0; house<pickups[1][HousePickup]+1; house++)
{
new Query[200];
format(Query, sizeof(Query), "SELECT * FROM houses WHERE `houseid` = '%d'",house);
mysql_query(Query);
mysql_store_result();
new savingstring[ 20 ];
while(!mysql_retrieve_row())
{
//If house pickup is not own.
houseDB[house][HouseLabel] = Create3DTextLabel("",-1,HousePickups[house][0],HousePickups[house][1],HousePickups[house][2],25, 0, 1);
format(text,sizeof(text),"House: %d\nPrice: %d",house,houseDB[house][nprice]);
Update3DTextLabelText(houseDB[house][HouseLabel],-1,text);
continue;
}
//If house pickup is belong for person.
mysql_fetch_field_row( houseDB[house][owner_name], "Owner");
mysql_fetch_field_row( savingstring, "Interior"); houseDB[house][ninterior] =  strval(savingstring);
mysql_fetch_field_row( savingstring, "HouseX"); houseDB[house][HouseX] = floatstr(savingstring);
mysql_fetch_field_row( savingstring, "HouseY"); houseDB[house][HouseY] = floatstr(savingstring);
mysql_fetch_field_row( savingstring, "HouseZ"); houseDB[house][HouseZ] = floatstr(savingstring);
houseDB[house][HouseLabel] = Create3DTextLabel("",-1,HousePickups[house][0],HousePickups[house][1],HousePickups[house][2],25, 0, 1);
format(file,sizeof(file),"House: %d\nPrice: %d\nOwner: %s",house,houseDB[house][nprice],houseDB[house][owner_name]);
Update3DTextLabelText(houseDB[house][HouseLabel],-1,file);
mysql_free_result();
}
}
But this not work...What can be wrong here?


Re: House loading with mysql. - TheLazySloth - 16.10.2011

Yes I can see that, do you have a way to contact you outside the forum?


Re: House loading with mysql. - budelis - 16.10.2011

Yes, contact me with pm.


Re: House loading with mysql. - [HiC]TheKiller - 16.10.2011

Quote:
Originally Posted by budelis
Посмотреть сообщение
I know how works mysql,but i don't know how to do it ...

Код:
for(new house=0; house<pickups[1][HousePickup]+1; house++)
{
new Query[200];
format(Query, sizeof(Query), "SELECT * FROM houses WHERE `houseid` = '%d'",house);
mysql_query(Query);
mysql_store_result();
new savingstring[ 20 ];
while(!mysql_retrieve_row())
{
//If house pickup is not own.
houseDB[house][HouseLabel] = Create3DTextLabel("",-1,HousePickups[house][0],HousePickups[house][1],HousePickups[house][2],25, 0, 1);
format(text,sizeof(text),"House: %d\nPrice: %d",house,houseDB[house][nprice]);
Update3DTextLabelText(houseDB[house][HouseLabel],-1,text);
continue;
}
//If house pickup is belong for person.
mysql_fetch_field_row( houseDB[house][owner_name], "Owner");
mysql_fetch_field_row( savingstring, "Interior"); houseDB[house][ninterior] =  strval(savingstring);
mysql_fetch_field_row( savingstring, "HouseX"); houseDB[house][HouseX] = floatstr(savingstring);
mysql_fetch_field_row( savingstring, "HouseY"); houseDB[house][HouseY] = floatstr(savingstring);
mysql_fetch_field_row( savingstring, "HouseZ"); houseDB[house][HouseZ] = floatstr(savingstring);
houseDB[house][HouseLabel] = Create3DTextLabel("",-1,HousePickups[house][0],HousePickups[house][1],HousePickups[house][2],25, 0, 1);
format(file,sizeof(file),"House: %d\nPrice: %d\nOwner: %s",house,houseDB[house][nprice],houseDB[house][owner_name]);
Update3DTextLabelText(houseDB[house][HouseLabel],-1,file);
mysql_free_result();
}
}
But this not work...What can be wrong here?
Use print to determine what values it is printing. I also saw that you're not putting a value into the 3DTextLabel which isn't the best idea
Quote:

Important Note: If text[] is empty, the server/clients next to the text might crash!

I also recommend that you use one single query to get all of the information rather than multiple queries.


Re: House loading with mysql. - budelis - 16.10.2011

I try print owner name,interior and this not work too....