Problem with my house system.
#5

Code:
0
[07:17:07] INSERT INTO `HOUSES` ( 'ID', 'NAPRODAJU', 'VLASNIK', 'CIJENA', ADRESA', 'X', 'Y', 'Z', 'INZX', 'INTY', 'INTZ', 'MATS', 'DROGA',
[07:17:07] UPDATE `HOUSES` SET VLASNIK = '0', CIJENA = '10000', ADRESA = 'Spawn', X = '1366.969726', Y = '-1383.997680', Z = '13.678855' W
[07:17:07] UPDATE `HOUSES` SET INTX = '2324.419921', INTY = '-1145.568359', INTZ = '1050.710083', MATS = '0', DROGA = '0', NOVAC = '0', BR
[07:17:07] UPDATE `HOUSES` SET INT = '12', RENTABIL = '0', RENT = '0', ALARM = '0' WHERE `ID` = '1' 
[07:17:07] 00
[07:17:07] SELECT * FROM `HOUSES` WHERE `ID` = '1'
Code:
stock LoadHouse(i)
{
	new Query[150], Field[16], DBResult:Result, string[64];
    format(Query, sizeof(Query), "SELECT * FROM `HOUSES` WHERE `ID` = '%d'", i);
	Result = db_query(Database, Query);
 	format(string, sizeof string, "%s", i);
 	print(string);
 	print(Query);
 	if(db_num_rows(Result))
  	{
		HouseInfo[i][ID] = i;
		db_get_field_assoc(Result, "NAPRODAJU", Field, 30);
		HouseInfo[i][KucaNaProdaju] = strval(Field);
		db_get_field_assoc(Result, "VLASNIK", Field, 30);
		HouseInfo[i][Vlasnik] = strval(Field);
		db_get_field_assoc(Result, "CIJENA", Field, 30);
		HouseInfo[i][Cijena] = strval(Field);
		db_get_field_assoc(Result, "VRSTAKUCE", Field, 30);
		HouseInfo[i][VrstaKuce] = strval(Field);
		db_get_field_assoc(Result, "ADRESA", Field, 30);
		HouseInfo[i][Adresa] = strval(Field);
		db_get_field_assoc(Result, "X", Field, 30);
		HouseInfo[i][kX] = strval(Field);
		db_get_field_assoc(Result, "Y", Field, 30);
		HouseInfo[i][kY] = strval(Field);
		db_get_field_assoc(Result, "Z", Field, 30);
		HouseInfo[i][kZ] = strval(Field);
		db_get_field_assoc(Result, "INTX", Field, 30);
		HouseInfo[i][IntX] = strval(Field);
		db_get_field_assoc(Result, "INTY", Field, 30);
		HouseInfo[i][IntY] = strval(Field);
		db_get_field_assoc(Result, "INTZ", Field, 30);
		HouseInfo[i][IntZ] = strval(Field);
		db_get_field_assoc(Result, "MATS", Field, 30);
		HouseInfo[i][kMats] = strval(Field);
		db_get_field_assoc(Result, "DROGA", Field, 30);
		HouseInfo[i][kDroga] = strval(Field);
		db_get_field_assoc(Result, "NOVAC", Field, 30);
		HouseInfo[i][kNovac] = strval(Field);
		db_get_field_assoc(Result, "BRAVA", Field, 30);
		HouseInfo[i][Brava] = strval(Field);
		db_get_field_assoc(Result, "INT", Field, 30);
		HouseInfo[i][Interior] = strval(Field);
		db_get_field_assoc(Result, "RENTABIL", Field, 30);
		HouseInfo[i][Rentabil] = strval(Field);
		db_get_field_assoc(Result, "RENT", Field, 30);
		HouseInfo[i][Rent] = strval(Field);
		db_get_field_assoc(Result, "ALARM", Field, 30);
		HouseInfo[i][Alarm] = strval(Field);
		if(HouseInfo[i][KucaNaProdaju] == 1)
  		{
			format(KucniLabel, sizeof(KucniLabel), ""ZELENA"Kuca na PRODAJU!\nOpis:"BIJELA" %s\n"ZELENA"Adresa: "BIJELA"%s\n"ZELENA"Cijena: "BIJELA"$%i",HouseInfo[i][VrstaKuce],HouseInfo[i][Adresa],HouseInfo[i][Cijena]);
   			HouseInfo[i][LabelKuce] = Create3DTextLabel(KucniLabel,-1,HouseInfo[i][kX], HouseInfo[i][kY], HouseInfo[i][kZ]+1,30.0,0,1);
      	}
      	if(HouseInfo[i][KucaNaProdaju] == 0 && HouseInfo[i][Rentabil] == 1)
		{
			format(KucniLabel,sizeof(KucniLabel),""ZELENA"Vlasnik: {FFFFFF}%s\n"ZELENA"Rent: {FFFFFF}%d$\n"ZELENA"Adresa: "BIJELA"%s", HouseInfo[i][Vlasnik],HouseInfo[i][Rent],HouseInfo[i][Adresa]);
			HouseInfo[i][LabelKuce] = Create3DTextLabel(KucniLabel ,0x00FFFFAA,HouseInfo[i][kX], HouseInfo[i][kY], HouseInfo[i][kZ]+0.5,15.0, 0, 1);
		}
       	else
        {
        	format(KucniLabel, sizeof(KucniLabel), ""ZELENA"Vlasnik: "BIJELA"%s\n"ZELENA"Opis: "BIJELA"%s\n"ZELENA"Adresa: "BIJELA"%s",HouseInfo[i][Vlasnik],HouseInfo[i][VrstaKuce],HouseInfo[i][Adresa]);
         	HouseInfo[i][LabelKuce] = Create3DTextLabel(KucniLabel,-1,HouseInfo[i][kX], HouseInfo[i][kY], HouseInfo[i][kZ]+1,30.0,0,1);
        }
	}
	return 1;
}

stock CreateHouse(cijena, Float:X, Float:Y, Float:Z, Float:kIntX, Float:kIntY, Float:kIntZ, adresa[], intid)
{
    new Field[16], DBResult:Result;
 	
 	new Query[128], i, string[64];
    new DBResult:qresult;
    qresult = db_query(Database,"SELECT * FROM `HOUSES`");
    format(Query,sizeof(Query),"%d", db_num_rows(qresult));
    format(string, sizeof string, "%d", i);
 	print(string);

 	HouseInfo[i][ID] = i+1;
	HouseInfo[i][Cijena] = cijena;
	HouseInfo[i][kX] = X;
	HouseInfo[i][kY] = Y;
	HouseInfo[i][kZ] = Z;
	HouseInfo[i][IntX] = kIntX;
	HouseInfo[i][IntY] = kIntY;
	HouseInfo[i][IntZ] = kIntZ;
	HouseInfo[i][Interior] = intid;
 	db_free_result(qresult);

	format(Query, sizeof(Query), "INSERT INTO `HOUSES` ( 'ID', 'NAPRODAJU', 'VLASNIK', 'CIJENA', ADRESA', 'X', 'Y', 'Z', 'INZX', 'INTY', 'INTZ', 'MATS', 'DROGA', 'NOVAC', 'BRAVA', 'INT', 'RENTABIL', 'RENT', 'ALARM') VALUES('%s','%s')", HouseInfo[i][ID], 0);
 	db_query(Database, Query);
 	print(Query);

	format(Query, sizeof(Query), "UPDATE `HOUSES` SET VLASNIK = '0', CIJENA = '%d', ADRESA = '%s', X = '%f', Y = '%f', Z = '%f' WHERE `ID` = '%d' ", HouseInfo[i][Cijena], adresa, HouseInfo[i][kX], HouseInfo[i][kY], HouseInfo[i][kZ], HouseInfo[i][ID]);
 	db_query(Database, Query);
 	print(Query);

 	format(Query, sizeof(Query), "UPDATE `HOUSES` SET INTX = '%f', INTY = '%f', INTZ = '%f', MATS = '%d', DROGA = '%d', NOVAC = '%d', BRAVA = '%d', NAPRODAJU = '1' WHERE `ID` = '%d' ", HouseInfo[i][IntX], HouseInfo[i][IntY], HouseInfo[i][IntZ], HouseInfo[i][kMats], HouseInfo[i][kDroga], HouseInfo[i][kNovac], HouseInfo[i][Brava], HouseInfo[i][ID]);
 	db_query(Database, Query);
 	print(Query);
 	
 	format(Query, sizeof(Query), "UPDATE `HOUSES` SET INT = '%d', RENTABIL = '%d', RENT = '%d', ALARM = '%d' WHERE `ID` = '%d' ", HouseInfo[i][Interior], HouseInfo[i][Rentabil], HouseInfo[i][Rent], HouseInfo[i][Alarm], HouseInfo[i][ID]);
 	db_query(Database, Query);
 	print(Query);

    db_get_field_assoc(Result, "ADRESA", Field, 30);
	HouseInfo[i][Adresa] = strval(Field);
	LoadHouse(HouseInfo[i][ID]);
	format(KucniLabel, sizeof(KucniLabel), ""ZELENA"Kuca na PRODAJU!\n"ZELENA"Adresa: "BIJELA"%s\n"ZELENA"Cijena: "BIJELA"$%i",HouseInfo[i][VrstaKuce],HouseInfo[i][Adresa],HouseInfo[i][Cijena]);
	HouseInfo[i][LabelKuce] = Create3DTextLabel(KucniLabel,LIGHTBLUE,HouseInfo[i][kX], HouseInfo[i][kY], HouseInfo[i][kZ]+0.1,15.0,0,1);
	return 1;
}
and how i did it.
Reply


Messages In This Thread
Problem with my house system. - by Danijel. - 24.06.2012, 04:50
Re: Problem with my house system. - by ReneG - 24.06.2012, 04:51
Re: Problem with my house system. - by Danijel. - 24.06.2012, 04:59
Re: Problem with my house system. - by ReneG - 24.06.2012, 05:02
Re: Problem with my house system. - by Danijel. - 24.06.2012, 05:07
Re: Problem with my house system. - by Danijel. - 24.06.2012, 11:17
Re: Problem with my house system. - by Danijel. - 25.06.2012, 12:23
Re: Problem with my house system. - by Jonny5 - 25.06.2012, 12:35
Re: Problem with my house system. - by Danijel. - 25.06.2012, 13:13
Re: Problem with my house system. - by Jonny5 - 25.06.2012, 13:17

Forum Jump:


Users browsing this thread: 3 Guest(s)