Houses does not load.
#1

Code:
public LoadHouses()
{
	new str[250];
	new query[1000];
	new rows = cache_get_row_count(dbhandle);
	for(new i = 0; i < rows && i < MAX_HOUSES; i ++)
	{
		DestroyPickup(HouseInfo[i][hPickup]);
		DestroyDynamic3DTextLabel(HouseInfo[i][hLabel]);
		cache_get_field_content(i, "Owner", HouseInfo[i][hOwner], dbhandle, MAX_PLAYER_NAME);
		HouseInfo[i][hID] 		      = cache_get_field_content_int(i, "ID", dbhandle);
		HouseInfo[i][hOutPos][0]      = cache_get_field_content_float(i, "Out_X", dbhandle);
		HouseInfo[i][hOutPos][1]      = cache_get_field_content_float(i, "Out_Y", dbhandle);
		HouseInfo[i][hOutPos][2]      = cache_get_field_content_float(i, "Out_Z", dbhandle);
		HouseInfo[i][hIntPos][0]      = cache_get_field_content_float(i, "Int_X", dbhandle);
		HouseInfo[i][hIntPos][1]      = cache_get_field_content_float(i, "Int_Y", dbhandle);
		HouseInfo[i][hIntPos][2]      = cache_get_field_content_float(i, "Int_Z", dbhandle);
		HouseInfo[i][hOutInterior]    = cache_get_field_content_int(i, "OutInt", dbhandle);
		HouseInfo[i][hOutWorld]       = cache_get_field_content_int(i, "OutWorld", dbhandle);
		HouseInfo[i][hInsideInterior] = cache_get_field_content_int(i, "InsideInt", dbhandle);
		HouseInfo[i][hInsideWorld]    = cache_get_field_content_int(i, "InsideWorld", dbhandle);
		HouseInfo[i][hLocked]   	  = cache_get_field_content_int(i, "Locked", dbhandle);
		HouseInfo[i][hForSell]   	  = cache_get_field_content_int(i, "ForSell", dbhandle);
		HouseInfo[i][hPrice]   	  	  = cache_get_field_content_int(i, "Price", dbhandle);
		if(HouseInfo[i][hForSell] == 1)
		{
			HouseInfo[i][hPickup] = CreatePickup(1273, 23, HouseInfo[i][hOutPos][0], HouseInfo[i][hOutPos][1], HouseInfo[i][hOutPos][2], -1);
	        format(str, sizeof(str), "This house is for sell!\nPrice: %d\nType /buyhouse to buy it.\nType /enter to go inside.", HouseInfo[i][hPrice]);
			HouseInfo[i][hLabel] = CreateDynamic3DTextLabel(str ,COLOR_ORANGE, HouseInfo[i][hOutPos][0], HouseInfo[i][hOutPos][1], HouseInfo[i][hOutPos][2],30.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 7.0);
		}
		else
		{
			HouseInfo[i][hPickup] = CreatePickup(1273, 23, HouseInfo[i][hOutPos][0], HouseInfo[i][hOutPos][1], HouseInfo[i][hOutPos][2], -1);
	        format(str, sizeof(str), "House\nOwner: %s\nTo enter inside type /enter.", HouseInfo[i][hOwner]);
			HouseInfo[i][hLabel] = CreateDynamic3DTextLabel(str ,COLOR_ORANGE, HouseInfo[i][hOutPos][0], HouseInfo[i][hOutPos][1], HouseInfo[i][hOutPos][2],30.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 7.0);
		}
		printf("%d houses loaded.", rows);
	}
	return 1;
}
Reply
#2

Only this one: printf("%d houses loaded.", rows);
What did it reveal? Nothing pop ups.
Reply
#3

Is `LoadHouses` called? An error in syntax can prevent the public function from being called. Check mysql logs and verify the name of the callback is correct (where mysql_tquery/mysql_pquery was called).
Reply
#4

That IS the problem. Nothing in mysql log.
Reply
#5

Please provide how you call LoadHouses.
Reply
#6

I managed to fix it, now I am occuring a different error.
Code:
CMD:createhouse(playerid, params[])
{
	new price, Float:x, Float:y, Float:z, query[800], str[350];
	if(PlayerInfo[playerid][pAdmin] < 4) return SendClientMessage(playerid, COLOR_GREY, "Not authorized!");
	if(sscanf(params, "d", price)) return SendClientMessage(playerid, COLOR_GREY, "Usage:{FFFFFF} /createhouse [price]");
	for(new i=1;i<MAX_HOUSES;i++)
	{
		GetPlayerPos(playerid, x, y, z);
		HouseInfo[i][hOutInterior] = GetPlayerInterior(playerid);
		HouseInfo[i][hOutWorld] = GetPlayerVirtualWorld(playerid);
		HouseInfo[i][hOutPos][0] = x;
		HouseInfo[i][hOutPos][1] = y;
		HouseInfo[i][hOutPos][2] = z;
		HouseInfo[i][hPrice] = price;
		format(query, sizeof(query), "INSERT INTO `houses` (`Out_X`, `Out_Y`, `Out_Z`, `OutInt`, `OutWorld`, `Price`) VALUES ('%f', '%f', '%f', '%d', '%d', '%d')", HouseInfo[i][hOutPos][0], HouseInfo[i][hOutPos][1], HouseInfo[i][hOutPos][2], HouseInfo[i][hOutInterior], HouseInfo[i][hOutWorld], HouseInfo[i][hPrice]);
		mysql_function_query(dbhandle, query, true, "LoadHouses", "");	
		format(str, sizeof(str), "You created a house at X: %f, Y: %f, Z: %f, for price of: %d, house ID: %d", x, y, z, price, i);
		SendClientMessage(playerid, COLOR_GREY, str);
		return 1;
	}
	return 1;
}
after creating a house, it does not spawn
Reply
#7

You confuse it with SELECT queries. You cannot execute an INSERT query and expect to retrieve data (excluding the auto generated value). When a house ID is set as primary key and auto increment, you can specify a callback and retrieve it using mysql_insert_id(). The loop is only used to find a free slot for the array index but the house ID is the identifier to the database. If the `houses` table does not have it, then create it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)