New mysql house error
#1

Im making a loading system for my houses and when the server loads the houses it only loads the first one in the mysql and then stops.. here is the code

Код:
stock LoadHouse()
{
		new string[256];
	    for(new idx = 1; idx < MAX_HOUSE; idx++)
    	{
		    new query[500];
    		mysql_format(MySQLCon, query, sizeof(query), "SELECT * FROM `houses` WHERE `ID`='%i' LIMIT 1", 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");
	  		////////////////////////////////
	  		if(HouseInfo[idx][hStatus] == 1)
		    {
		    	format(string, sizeof(string), "FOR SALE\n$%d", HouseInfo[idx][hPrice]);
				HouseInfo[idx][hPickup] = CreateDynamicPickup(1273, 1, HouseInfo[idx][hX], HouseInfo[idx][hY], HouseInfo[idx][hZ], 0);
				HouseInfo[idx][hText] = CreateDynamic3DTextLabel(string, COLOR_WHITE, HouseInfo[idx][hX], HouseInfo[idx][hY], HouseInfo[idx][hZ]+0.3, 15);
			}
			if(HouseInfo[idx][hStatus] == 2)
			{
				format(string, sizeof(string), "House of %s", HouseInfo[idx][hOwner]);
				HouseInfo[idx][hPickup] = CreateDynamicPickup(1272, 1, HouseInfo[idx][hX], HouseInfo[idx][hY], HouseInfo[idx][hZ], 0);
				HouseInfo[idx][hText] = CreateDynamic3DTextLabel(string, COLOR_WHITE, HouseInfo[idx][hX], HouseInfo[idx][hY], HouseInfo[idx][hZ]+0.3, 15);
			}
			print("House Loaded");
	    }
	print("Houses loaded successfully.");
	return 1;
}
It like stops loading or something after the first house. it doesn't even show the "Houses loaded successfully." message in the bat
Reply
#2

Quote:
Originally Posted by jeffery30162
Посмотреть сообщение
Im making a loading system for my houses and when the server loads the houses it only loads the first one in the mysql and then stops.. here is the code

Код:
stock LoadHouse()
{
		new string[256];
	    for(new idx = 1; idx < MAX_HOUSE; idx++)
    	{
		    new query[500];
    		mysql_format(MySQLCon, query, sizeof(query), "SELECT * FROM `houses` WHERE `ID`='%i' LIMIT 1", 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");
	  		////////////////////////////////
	  		if(HouseInfo[idx][hStatus] == 1)
		    {
		    	format(string, sizeof(string), "FOR SALE\n$%d", HouseInfo[idx][hPrice]);
				HouseInfo[idx][hPickup] = CreateDynamicPickup(1273, 1, HouseInfo[idx][hX], HouseInfo[idx][hY], HouseInfo[idx][hZ], 0);
				HouseInfo[idx][hText] = CreateDynamic3DTextLabel(string, COLOR_WHITE, HouseInfo[idx][hX], HouseInfo[idx][hY], HouseInfo[idx][hZ]+0.3, 15);
			}
			if(HouseInfo[idx][hStatus] == 2)
			{
				format(string, sizeof(string), "House of %s", HouseInfo[idx][hOwner]);
				HouseInfo[idx][hPickup] = CreateDynamicPickup(1272, 1, HouseInfo[idx][hX], HouseInfo[idx][hY], HouseInfo[idx][hZ], 0);
				HouseInfo[idx][hText] = CreateDynamic3DTextLabel(string, COLOR_WHITE, HouseInfo[idx][hX], HouseInfo[idx][hY], HouseInfo[idx][hZ]+0.3, 15);
			}
			print("House Loaded");
	    }
	print("Houses loaded successfully.");
	return 1;
}
It like stops loading or something after the first house. it doesn't even show the "Houses loaded successfully." message in the bat
for(new idx = 1; idx < MAX_HOUSE; idx++) isn't really the best to use in this type of SQL loading, also, is MAX_HOUSE a define in your gamemode?

IE: #define MAX_HOUSE 2500? Something like that?

Try using something like enum hInfo { //blah }, then start using Iterators, they're always better, and neater. We use Iterators, in my script, and load perfectly
Reply
#3

yes max house is defined. also this syastem used to work perfectly with ini but i am switch to mysql
Reply
#4

this load scriptlet also doesn't work when i use while indstead of for
Reply
#5

Quote:
Originally Posted by jeffery30162
Посмотреть сообщение
this load scriptlet also doesn't work when i use while indstead of for
You should change MYSQL to R39-2. I'd be able to work with that better and provide you a better sample. However, I am not fluent with R33, I learned from gamemode as R39-2.
Reply
#6

i want to stick with mysql. sorry
Reply
#7

Can someone help me
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)