Mysql house system
#1

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;
}
Reply
#2

what is the MAX_HOUSE number?
Reply
#3

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
Reply
#4

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..
Reply
#5

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?
Reply
#6

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

can someone please help me? I need this now.
Reply
#8

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
Reply
#9

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

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)