SA-MP Forums Archive
Pickup loading in wrong place. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Pickup loading in wrong place. (/showthread.php?tid=535661)



Pickup loading in wrong place. - Blademaster680 - 05.09.2014

When I create a house, it will create the house and everything fine, but the position is wrong,
it is a few metres to the left, as you can see in the picture... Were my guy is standing is
where I created the house yet it is far on the left... Please help

Image:


Code:
Code:
stock Load_House(houseid)
{
	new Query[512], savestr[25], rows, fields;
	mysql_format(dbHandle,Query, sizeof(Query), "SELECT * FROM `Houses` WHERE `ID` = '%d'", houseid);
    mysql_query(dbHandle,Query);
	cache_get_data(rows, fields);
    if(rows)
	{
		cache_get_field_content(0, "ID", savestr);				hInfo[houseid][hID] = strval(savestr);
		cache_get_field_content(0, "Owner", savestr);			hInfo[houseid][hOwner] = savestr;
		cache_get_field_content(0, "Level", savestr);			hInfo[houseid][hLevel] = strval(savestr);
		cache_get_field_content(0, "Price", savestr);			hInfo[houseid][hPrice] = strval(savestr);
		cache_get_field_content(0, "PosX", savestr);			hInfo[houseid][hPos][0] = strval(savestr);
		cache_get_field_content(0, "PosY", savestr);			hInfo[houseid][hPos][1] = strval(savestr);
		cache_get_field_content(0, "PosZ", savestr);			hInfo[houseid][hPos][2] = strval(savestr);
		cache_get_field_content(0, "IPosX", savestr);			hInfo[houseid][hIPos][0] = strval(savestr);
		cache_get_field_content(0, "IPosY", savestr);			hInfo[houseid][hIPos][1] = strval(savestr);
		cache_get_field_content(0, "IPosZ", savestr);			hInfo[houseid][hIPos][2] = strval(savestr);
		cache_get_field_content(0, "Interior", savestr);		hInfo[houseid][hInt] = strval(savestr);
		cache_get_field_content(0, "VirtualWorld", savestr);	hInfo[houseid][hVW] = strval(savestr);
		
		Create_DynamicHouse(houseid);
		HouseCreated[houseid] = 1;
	}
}

stock Create_DynamicHouse(houseid)
{
	new string[50];
	format(string, sizeof(string), "Owner: %s \nPrice: $%i \nLevel: %i", hInfo[houseid][hOwner], hInfo[houseid][hPrice], hInfo[houseid][hLevel]);
	hInfo[houseid][hTextID] = CreateDynamic3DTextLabel(string, COLOR_YELLOW, hInfo[houseid][hPos][0], hInfo[houseid][hPos][1], hInfo[houseid][hPos][2]+0.7,10.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 1, 0, 0, 0);
	hInfo[houseid][hPickup] = CreateDynamicPickup(1273, 23, hInfo[houseid][hPos][0], hInfo[houseid][hPos][1], hInfo[houseid][hPos][2], 0);
	return 1;
}
CreateHouse command:
Code:
CMD:housecreate(playerid, params[])
{
	new Query[500], amount, level, rows, fields, houseid = 0, str[24];
	if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You are not authorised to use that command.");
	if(sscanf(params, "id", level, amount)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /housecreate [level] [price]");
	new Float: x, Float: y, Float: z;
	new Float: ix, Float: iy, Float: iz;
	GetPlayerPos(playerid, x, y, z);
	ix = 2259.38; iy = -1135.77; iz = 1050.64;
	if(level == 1)
	{
	
		strcat(Query,"INSERT INTO `houses`(`ID`, `Owner`, `Level`, `Price`,`PosX`,`PosY`,`PosZ`, `IPosX`, `IPosY`, `IPosZ`, `Interior`, `VirtualWorld`)");
		strcat(Query," VALUES (NULL, '%s', '%d', '%d', '%f', '%f', '%f', '%f', '%f', '%f', 10, 0)");
		mysql_format(dbHandle, Query, sizeof(Query), Query, "Server", level, amount, x, y, z, ix+1, iy, iz);
		mysql_query(dbHandle, Query, false);
		
		for(new i = 0; i<= MAX_HOUSES; i++)
		{
			mysql_format(dbHandle,Query, sizeof(Query), "SELECT * FROM `Houses` WHERE `ID` = '%d'", i);
			mysql_query(dbHandle,Query);
			cache_get_data(rows, fields);
			if(rows)
			{
				houseid = i;
			}
		}
		Load_House(houseid);
		format(str, sizeof(str), "Created house ID: %i", houseid);
		SendClientMessage(playerid, COLOR_GREY, str);
	}
        return 1;
}