SA-MP Forums Archive
Mysql house system - 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: Mysql house system (/showthread.php?tid=542103)



Mysql house system - jeffery30162 - 16.10.2014

I am switching my houses to mysql from ini file storage thing.



I currently have 2 houses stored into the database and when the server restarts and loads the houses, only the first house loads not any others.

Please help me

here is my load feature:

Код:
stock LoadHouse()
{
new idx = 1;
		while(idx < MAX_HOUSE)
		{
		    new query[500];
    		mysql_format(MySQLCon, query, sizeof(query), "SELECT * FROM `houses` WHERE `ID` = '%d'", idx);
    		mysql_query(MySQLCon, query);
		    HouseInfo[idx][hStatus] = cache_get_field_content_int(0, "Status");
		    HouseInfo[idx][hType] = cache_get_field_content_int(0, "Type");
		    HouseInfo[idx][hOwner]= cache_get_field_content(0, "Owner");
		    HouseInfo[idx][hX] = cache_get_field_content_float(0, "X");
		    HouseInfo[idx][hY] = cache_get_field_content_float(0, "Y");
		    HouseInfo[idx][hZ] = cache_get_field_content_float(0, "Z");
		    HouseInfo[idx][hMoney] = cache_get_field_content_int(0, "Money");
		    HouseInfo[idx][hLevel] = cache_get_field_content_int(0, "Level");
		    HouseInfo[idx][hPrice] = cache_get_field_content_int(0, "Price");
		    HouseInfo[idx][hXp] = cache_get_field_content_int(0, "XP");
		    HouseInfo[idx][hTrashX] = cache_get_field_content_float(0, "TrashX");
            HouseInfo[idx][hTrashY] = cache_get_field_content_float(0, "TrashY");
            HouseInfo[idx][hTrashZ] = cache_get_field_content_float(0, "TrashZ");
		    HouseInfo[idx][hRemovalYear] = cache_get_field_content_int(0, "RemovalYear");
		    HouseInfo[idx][hRemovalDay] = cache_get_field_content_int(0, "RemovalDay");
		    HouseInfo[idx][hLockStatus] = cache_get_field_content_int(0, "LockStatus");
			idx++;
	    }
	print("Houses loaded successfully.");
	return 1;
}



Re: Mysql house system - Eth - 17.10.2014

what is the MAX_HOUSE number?


Re: Mysql house system - jeffery30162 - 17.10.2014

Thats not the problem, everything was loading and saving correctly until I changed to mysql, no with mysql, everything is saving correctly buy its not loading correctly


Re: Mysql house system - austin070 - 17.10.2014

This is a longshot because I'm not too familiar with MySQL R33, but shouldn't it be:

pawn Код:
cache_get_field_content_int(idx, "Status");
etc..


Re: Mysql house system - TakeiT - 17.10.2014

Quote:
Originally Posted by austin070
Посмотреть сообщение
This is a longshot because I'm not too familiar with MySQL R33, but shouldn't it be:

pawn Код:
cache_get_field_content_int(idx, "Status");
etc..
No he has it right.

Are you sure the ones you create are actually saving?


Re: Mysql house system - jeffery30162 - 17.10.2014

yes everything else is working correctly, its just the loading because it only loads the first houose in the myswl which is idx = 1


Re: Mysql house system - jeffery30162 - 19.10.2014

can someone please help me? I need this now.


Re: Mysql house system - jeffery30162 - 21.10.2014

I think the problem has to do with the ammount of times mysql can be accessed at once. Because it loads the first house correctly and then after that it stops. Is there any solution to my problem? Please help


Re: Mysql house system - jeffery30162 - 25.10.2014

Could someone please give me an answer, I need this to be solved for I can continue working on my server.


Re: Mysql house system - Neil. - 26.10.2014

If I may, I suggest you read up the tutorials about MySQL with multi-threading and caching. How you implemented it was wrong, once you do a (SELECT) query, you're supposed to send it to a callback to fetch the result in that active cache. Lastly, fetching a string result from the result set isn't done by
pawn Код:
HouseInfo[idx][hOwner]= cache_get_field_content(0, "Owner");
You have to specify the size of the variable if you're using an enum to store the string data into.

https://sampwiki.blast.hk/wiki/MySQL/R33
https://sampwiki.blast.hk/wiki/MySQL/R33#mysql_tquery
https://sampwiki.blast.hk/wiki/MySQL/R33..._field_content