Houses Crashing Server [MYSQL]
#1

Can someone look at this code and check and see what is wrong?

This is the database code:

Код:
DROP TABLE IF EXISTS `Houses`;
CREATE TABLE IF NOT EXISTS `Houses` (
 `id` smallint(3) NOT NULL auto_increment,
 `owner` varchar(32) NOT NULL default 'None',
`price` int(6) NOT NULL default '0',
`RentPrice` int(6) NOT NULL default '0',
`hLocked` tinyint(2) NOT NULL default '0',
`EnterInt` smallint(3) NOT NULL default '0',
`EnterWorld` smallint(3) NOT NULL default '0',
`hEntranceX` float(10,5) NOT NULL default '0.00000',
`hEntranceY` float(10,5) NOT NULL default '0.00000',
`hEntranceZ` float(10,5) NOT NULL default '0.00000',
`hExitX` float(10,5) NOT NULL default '0.00000',
`hExitY` float(10,5) NOT NULL default '0.00000',
`hExitZ` float(10,5) NOT NULL default '0.00000',
`Owned` tinyint(1) NOT NULL default '0',
`Rentable` tinyint(1) NOT NULL default '0',
 PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=14 ;
-- -------------------------------------------------------


INSERT INTO `Houses` (`id`,`owner`,`price`,`RentPrice`,`hLocked`,`EnterInt`,`EnterWorld`,`hEntranceX`,`hEntranceY`,`hEntranceZ`,`hExitX`,`hExitY`,`hExitZ`,`Owned`,`Rentable`) VALUES
(2,'Eric_Wright',500,500,1,12,0,2459.569335,-1691.648437,13.544087,2324.418457,-1148.761718,1050.710083,1,1),
(3,'None',10000,500,0,15,0,2065.1018,-1703.5829,14.1484,328.2272,1477.9617,1084.4375,0,0),
(4,'None',3000,500,0,15,0,1420.7477,-1849.3765,13.9688,225.7570,1240.0000,1082.1406,0,0);
And this is in my script:

Код:
forward LoadHouses();
public LoadHouses()
{
	new arrCoords[20][32];
	new sql[80];
	new row[512];
	format(sql, sizeof(sql), "SELECT COUNT(*) FROM Houses");
	samp_mysql_query(sql);
	//if (DEBUG) SQLLog(sql);
	samp_mysql_store_result();
	samp_mysql_fetch_row(row);
	totalhouse = strval(row);
	samp_mysql_free_result();
	new idx;
	while (idx < sizeof(HouseInfo))
	{
	  format(sql, sizeof(sql), "SELECT * FROM Houses WHERE id=%d", idx+1);
	  samp_mysql_query(sql);
		//if (DEBUG) SQLLog(sql);
	  samp_mysql_store_result();
	  if (samp_mysql_num_rows() > 0)
	  {
			samp_mysql_fetch_row(row);
			split(row, arrCoords, '|');
			samp_mysql_free_result();
			strmid(HouseInfo[idx][Owner], arrCoords[0], 0, strlen(arrCoords[0]), 255);
			strmid(HouseInfo[idx][Price], arrCoords[1], 0, strlen(arrCoords[1]), 255);
			strmid(HouseInfo[idx][RentPrice], arrCoords[2], 0, strlen(arrCoords[2]), 255);
			HouseInfo[idx][hLocked] = strval(arrCoords[3]);
			HouseInfo[idx][EnterInt] = strval(arrCoords[4]);
			HouseInfo[idx][EnterWorld] = strval(arrCoords[5]);
			HouseInfo[idx][hEntranceX] = floatstr(arrCoords[6]);
			HouseInfo[idx][hEntranceY] = floatstr(arrCoords[7]);
			HouseInfo[idx][hEntranceZ] = floatstr(arrCoords[8]);
			HouseInfo[idx][hExitX] = floatstr(arrCoords[9]);
			HouseInfo[idx][hExitY] = floatstr(arrCoords[10]);
			HouseInfo[idx][hExitZ] = floatstr(arrCoords[11]);
			HouseInfo[idx][Owned] = strval(arrCoords[12]);
			HouseInfo[idx][Rentable] = strval(arrCoords[13]);
			if(HouseInfo[idx][Owned] == 0)
			{
			  CreatePickup(1273, 1, HouseInfo[idx][hEntranceX], HouseInfo[idx][hEntranceY], HouseInfo[idx][hEntranceZ]);
			  Create3DTextLabel("Buyable House!",COLOR_LIGHTBLUE,HouseInfo[idx][hEntranceX], HouseInfo[idx][hEntranceY], HouseInfo[idx][hEntranceZ]+1,40.0, 0, 1);
			  	SetPlayerMapIcon( idx, idx, HouseInfo[idx][hEntranceX], HouseInfo[idx][hEntranceY], HouseInfo[idx][hEntranceZ], 31, 0 );
			}
			else if(HouseInfo[idx][Owned] == 1)
			{
			  CreatePickup(1273, 1, HouseInfo[idx][hEntranceX], HouseInfo[idx][hEntranceY], HouseInfo[idx][hEntranceZ]);
			  Create3DTextLabel("House!",COLOR_RED,HouseInfo[idx][hEntranceX], HouseInfo[idx][hEntranceY], HouseInfo[idx][hEntranceZ]+1,40.0, 0, 1);
			  SetPlayerMapIcon( idx, idx, HouseInfo[idx][hEntranceX], HouseInfo[idx][hEntranceY], HouseInfo[idx][hEntranceZ], 31, 0 );
			}
			if(HouseInfo[idx][Rentable] == 1)
			{
			  Create3DTextLabel("Rentable House!",COLOR_GREEN,HouseInfo[idx][hEntranceX], HouseInfo[idx][hEntranceY], HouseInfo[idx][hEntranceZ]+2,40.0, 0, 1);
			}
			print("---------------------------------");
			printf("House ID %d",idx);
			printf("House Owner %s",HouseInfo[idx][Owner]);
			printf("House Price %s",HouseInfo[idx][Price]);
			printf("House RentPrice %s",HouseInfo[idx][RentPrice]);
			print("---------------------------------");
			idx++;
			}
		}
	return 1;
}
Does anyone see anything wrong?
Reply
#2

samp_mysql_free_result(); crashes it i think
Reply
#3

Quote:
Originally Posted by GTA967
samp_mysql_free_result(); crashes it i think
Just checked, still crashes when i load the houses
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)