[MySQL] Threaded loading houses
#1

The "LoadHouses" function is ran under "OnGameModeInit". I have looked at other threads and can't fix the issue.
The "OnHousesLoad" function is not called but "LoadHouses" is. Similar MySQL queries function correctly.

Код:
public LoadHouses() {
	mysql_tquery(databaseConnection, "SELECT * FROM `houses`", "OnHousesLoad");
	print("test"); // Prints
	return 1;
}
Код:
forward OnHousesLoad(); 
public OnHousesLoad() {
	print("Callback test"); // Does not print
	new name[128], string[64];
	for(new i = 0, j = cache_get_row_count(); i <= j; i++) {
	print("loop test"); // Does not print
		Houses[i][SQLID] = cache_get_field_content_int(i, "SQLID", databaseConnection);
		Houses[i][CharacterSQLID] = cache_get_field_content_int(i, "CharacterSQLID", databaseConnection);
		Houses[i][Price] = cache_get_field_content_int(i, "Price", databaseConnection);
		Houses[i][Interior] = cache_get_field_content_int(i, "Interior", databaseConnection);
		Houses[i][VirtualWorld] = cache_get_field_content_int(i, "VirtualWorld", databaseConnection);
		Houses[i][hEnteranceX] = cache_get_field_content_float(i, "EnteranceX", databaseConnection);
		Houses[i][hEnteranceY] = cache_get_field_content_float(i, "EnteranceY", databaseConnection);
		Houses[i][hEnteranceZ] = cache_get_field_content_float(i, "EnteranceZ", databaseConnection);
		Houses[i][hExitX] = cache_get_field_content_float(i, "ExitX", databaseConnection);
		Houses[i][hExitY] = cache_get_field_content_float(i, "ExitY", databaseConnection);
		Houses[i][hExitZ] = cache_get_field_content_float(i, "ExitZ", databaseConnection);
		cache_get_field_content(i, "Name", name, databaseConnection, sizeof(name));

		CreatePickup(1272, 1, Houses[i][hEnteranceX], Houses[i][hEnteranceY], Houses[i][hEnteranceZ], i);
		format(string, sizeof(string), "%s\nOwner:%s", name, GetCharacterName(Houses[i][CharacterSQLID]));
		Create3DTextLabel(string, -1, Houses[i][hEnteranceX], Houses[i][hEnteranceY], Houses[i][hEnteranceZ], 25, 0, 0);

		housesTotal++;
		printf("Houses loaded: %d ID: %d X: %f Y: %f Z: %f", housesTotal, Houses[i][SQLID], Houses[i][hEnteranceX], Houses[i][hEnteranceY], Houses[i][hEnteranceZ]);
	}
}
Reply
#2

Check mysql_log. Also check that connection handle is in fact valid.
Reply
#3

Код:
[19:45:41] [DEBUG] mysql_tquery - connection: 0, query: "SELECT * FROM `houses`", callback: "OnHousesLoad", format: "(null)"
[19:45:41] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[19:45:41] [DEBUG] mysql_connect - host: "127.0.0.1", user: "root", database: "db", password: "****", port: 3306, autoreconnect: true, pool_size: 2
[19:45:41] [DEBUG] CMySQLHandle::Create - creating new connection..
[19:45:41] [DEBUG] CMySQLHandle::CMySQLHandle - constructor called
[19:45:41] [DEBUG] CMySQLHandle::Create - connection created (id: 1)
[19:45:41] [DEBUG] CMySQLConnection::Connect - establishing connection to database...
[19:45:41] [DEBUG] CMySQLConnection::Connect - connection was successful
[19:45:41] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been enabled
[19:45:41] [DEBUG] mysql_errno - connection: 1
[19:45:41] [DEBUG] CMySQLConnection::Connect - establishing connection to database...
[19:45:41] [DEBUG] CMySQLConnection::Connect - establishing connection to database...
[19:45:41] [DEBUG] CMySQLConnection::Connect - establishing connection to database...
[19:45:41] [DEBUG] CMySQLConnection::Connect - connection was successful
[19:45:41] [DEBUG] CMySQLConnection::Connect - connection was successful
[19:45:41] [DEBUG] CMySQLConnection::Connect - connection was successful
[19:45:41] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been enabled
[19:45:41] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been enabled
The handle is correct as other Queries execute successfully and the server can access the database.
Reply
#4

Quote:

[19:45:41] [ERROR] mysql_tquery - invalid connection handle (id: 0)

LoadHouses seems to be called before mysql_connect
Reply
#5

Any idea why only the first House is loading?

EDIT: floats aren't being loaded.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)