retrieving data MySQL R39
#1

Hello, I'm making a house system.. the house is made fine, data is also stored in MySQL..


But when the server restarts, it isn't getting the data from MySQL(House checkpoint gets destroyed, and isn't being retrieved from MySQL)



Here's my code under OnGameModeInit
Код:
for(new i = 0; i < MAX_HOUSES; i++)
	    {
	 	hInfo[i][HouseEX] = cache_get_field_content_float(0, "HouseEX");
 		hInfo[i][HouseEY] = cache_get_field_content_float(0, "HouseEY");
		hInfo[i][HouseEZ] = cache_get_field_content_float(0, "HouseEZ");
		cache_get_field_content_int(0, "HouseID", hInfo[i][HouseID]);
		hInfo[i][HouseCP] = CreateDynamicCP(hInfo[i][HouseEX], hInfo[i][HouseEZ], hInfo[i][HouseEZ], 1.5, .worldid = 0, .interiorid = 0, .streamdistance = 20.0);
		}
Completely unsure if it should work or not, but someone told me it would work fine..
Reply
#2

1) First parameter in cache_get_field_content* functions is rowid. You only retrieve from first row:
Код:
cache_get_field_content_float(0,
2) Wrong loop. It should be "i < rows" where rows are retrieved with cache_get_row_count/cache_num_rows before. Otherwise you will receive "no active cache" error in mysql logs.
3) In OnGameModeInit? If you do not execute a query before or even use mysql_tquery/mysql_pquery (without a callback), you will receive "no active cache" error again. If mysql_query was used, it is bad practice- always use threaded query.
4) Check if there are more rows than the size of hInfo array otherwise run time error 4.
Reply
#3

What should I do now?
Reply
#4

Quote:
Originally Posted by div
Посмотреть сообщение
What should I do now?
Fix the code? I pointed out 4 mistakes, you do the rest.
Reply
#5

How can i retrieve with any other way btw?
Reply
#6

well this loading code doesnt evne work do even understand what are you doing?
how can use max_houses for loading houses?
and when you dont understand nothing then you should build something simplier
Reply
#7

Quote:
Originally Posted by CodeStyle175
Посмотреть сообщение
well this loading code doesnt evne work do even understand what are you doing?
how can use max_houses for loading houses?
Fixed that.


EDIT: Problem isn't fixed yet..
Reply
#8

How about this?
Код:
forward LoadHouses();
public LoadHouses()
{
    	new rows = cache_get_row_count();
    	for(new i = 0; i < rows; i++)
	    {
	    
	 	hInfo[i][HouseEX] = cache_get_field_content_float(0, "HouseEX");
 		hInfo[i][HouseEY] = cache_get_field_content_float(0, "HouseEY");
		hInfo[i][HouseEZ] = cache_get_field_content_float(0, "HouseEZ");
		cache_get_field_content_int(0, "HouseID", hInfo[i][HouseID]);
		hInfo[i][HouseCP] = CreateDynamicCP(hInfo[i][HouseEX], hInfo[i][HouseEZ], hInfo[i][HouseEZ], 1.5, .worldid = 0, .interiorid = 0, .streamdistance = 20.0);
		}

}

Код:
mysql_tquery(dbHandle, "SELECT * FROM `houses`", "LoadHouses", "");
Reply
#9

help please
Reply
#10

Read #1 from the list again. rowid = i (iteration variable) not 0.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)